Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ListView + Picker - Item icon support #1959

Merged
merged 29 commits into from
May 1, 2024

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Apr 23, 2024

This example shows both basic and table data sources.

import deephaven.ui as ui


@ui.component
def ui_list_view():
    value, set_value = ui.use_state(["Text 2"])

    text = ui.text("Selection: " + ", ".join(map(str, value)), grid_column="span 2")

    # list_view with text children
    lv = ui.list_view(
        "Text 1",
        "Text 2",
        "Text 3",
        # min_height=1,
        aria_label="List View",
        on_change=set_value,
        selected_keys=value,
    )

    # list_view with item children
    lv2 = ui.list_view(
        ui.item("Item 1", key="Text 1"),
        ui.item("Item 2", key="Text 2"),
        ui.item("Item 3", key="Text 3"),
        aria_label="List View 2",
        on_change=set_value,
        selected_keys=value,
    )
    
    return ui.grid(
        text,
        lv,
        lv2,
        columns="repeat(2, 1fr)",
        rows="min-content",
        height="100%"
    )


lv = ui_list_view()

####################################
import deephaven.ui as ui
from deephaven import time_table
import datetime

icon_names = ['vsAccount']

# Ticking table with initial row count of 200 that adds a row every second
initial_row_count=2000
columns = [
    "Id=new Integer(i)",
    "Display=new String(`Display `+i)",
    "Description=new String(`Description `+i)",
    "Icon=(String) icon_names[0]"
]
# column_types_ticking = time_table("PT1S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count)).update([
#     columns
# )
column_types = empty_table(initial_row_count).update(columns)

@ui.component
def labeled_lv(label, *args, **kwargs):
    return ui.flex(
        ui.text(label),
        ui.list_view(
            *args,
            **kwargs
        ),
        direction="column",
        flex=1,
        min_width=0,
    )

@ui.component
def ui_list_view_table():
    value, set_value = ui.use_state([2, 4, 5])

    lv = labeled_lv(
        "Compact",
        column_types,
        max_height=5000,
        density="compact",
        key_column="Id",
        label_column="Display",
        icon_column="Icon",
        aria_label="List View",
        on_change=set_value,
        selected_keys=value,
    )

    lv2 = labeled_lv(
        "Regular",
        column_types,
        max_height=5000,
        density="regular",
        key_column="Id",
        label_column="Display",
        icon_column="Icon",
        aria_label="List View 2",
        on_change=set_value,
        selected_keys=value,
    )

    lv3 = labeled_lv(
        "Spacious",
        column_types,
        max_height=5000,
        density="spacious",
        key_column="Id",
        label_column="Display",
        icon_column="Icon",
        aria_label="List View 3",
        on_change=set_value,
        selected_keys=value,
    )

    text = ui.text("Selection: " + ", ".join(map(str, value)))

    return ui.flex(
        ui.flex(
            lv,
            lv2,
            lv3,
            direction="row",
            gap=10,
        ),
        text,
        direction="column",
    )

lv_table = ui_list_view_table()

resolves #1890

@bmingles bmingles force-pushed the 1890-description-icon-column-3 branch 2 times, most recently from 92754fc to 8aed8db Compare April 24, 2024 23:10
@bmingles bmingles marked this pull request as ready for review April 24, 2024 23:25
@bmingles bmingles requested a review from mofojed April 25, 2024 20:44
@bmingles bmingles force-pushed the 1890-description-icon-column-3 branch from 2a3a671 to c02cd50 Compare April 29, 2024 23:35
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some docs clean up will help, also question about UIConstants which may warrant a follow up.

} from '@deephaven/components';
import { vsAccount, vsPerson } from '@deephaven/icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { LIST_VIEW_ROW_HEIGHTS } from '@deephaven/utils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know not part of this change... but why are the UIConstants in @deephaven/utils and not @deephaven/components?

Copy link
Contributor Author

@bmingles bmingles Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this module was created before the UI work really started as part of moving some ACL utils to DHC. Looks like all but SPELLCHECK_FALSE_ATTRIBUTE could be moved to @deephaven/components
I created #1973 as a follow up

@bmingles bmingles requested a review from mofojed April 30, 2024 16:50
@bmingles
Copy link
Contributor Author

@mofojed I addressed your comments. I also had to fix an issue in the styleguide

  • Added back the content height check to only render ListView when container is visible
  • Added a fail quick check to detect console errors in styleguide tests

@bmingles bmingles merged commit cb13c60 into deephaven:main May 1, 2024
9 checks passed
@bmingles bmingles deleted the 1890-description-icon-column-3 branch May 1, 2024 13:37
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Picker + ListView - icon_column
3 participants