reflex icon indicating copy to clipboard operation
reflex copied to clipboard

[REF-2253] High level API for rx.table

Open picklelo opened this issue 1 year ago β€’ 4 comments

Currently the API for rx.table is quite verbose. We should explore a way to make a high level API for it.

Instead of

rx.table.root(
    rx.table.header(
        rx.table.row(
            rx.table.column_header_cell("Full name"),
            rx.table.column_header_cell("Email"),
            rx.table.column_header_cell("Group"),
        ),
    ),
    rx.table.body(
        rx.table.row(
            rx.table.row_header_cell("Danilo Sousa"),
            rx.table.cell("[email protected]"),
            rx.table.cell("Developer"),
        ),
        rx.table.row(
            rx.table.row_header_cell("Zahra Ambessa"),
            rx.table.cell("[email protected]"),
            rx.table.cell("Admin"),
        ),
        rx.table.row(
            rx.table.row_header_cell("Jasper Eriksson"),
            rx.table.cell("[email protected]"),
            rx.table.cell("Developer"),
        ),
    ),
)

maybe we can have something like

rx.table(
    [
      ["Full name", "Email", "Group"],
      ["Danilo Sousa", "Zahra Ambessa", "Jasper Eriksson"],
      ...
    ],
)

When designing this, we need to think carefully about how it will work with State vars (and using rx.foreach for dynamic row values).

From SyncLinear.com | REF-2253

picklelo avatar Mar 20 '24 23:03 picklelo

Let me try working on this.

Ifechukwu001 avatar Apr 13 '24 16:04 Ifechukwu001

Looking at the documentation, the granular approach gives a lot of flexibility to the design of the table UI. Are you suggesting the high-level API will generate a default style without a custom design or should custom designs be supported?

Ifechukwu001 avatar Apr 13 '24 16:04 Ifechukwu001

@Ifechukwu001 Agreed that we should keep the current table API. Was mainly wondering if there's improvements we could make for a high-level API on top of it that would have a built in opinionated design/styling.

Similar to how for select we have high level and low level.

The rx.table.root approach would still be there for full control, but perhaps we could have an rx.table component that could take in something simpler. I don't have a final API in mind at the moment though.

picklelo avatar Apr 15 '24 18:04 picklelo

Alright, let me work on a prototype, then we can fine-tune it when I make the PR

Ifechukwu001 avatar Apr 16 '24 13:04 Ifechukwu001

I think we can hold off on this - the original API gives good flexibility and we will add recipes / tutorials to the docs on how to do common operations like working with a data frame.

picklelo avatar Jun 03 '24 02:06 picklelo