-
Notifications
You must be signed in to change notification settings - Fork 21
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
ag-grid PoC #574
ag-grid PoC #574
Conversation
Super cool! This would be a great improvement. |
can we add the deploy tag to play with this grid? also, are we worried about increase in bundle size from adding this dependency? |
Do we have a deploy tag in this repo? I didn't see a label for it. |
oh my bad, didn't realize this was in prime 🤦 |
I updated the PoC to tweak some styles and show how to sort and filter. I also broke out the columns and rows into their props so they could be changed without forcing an entire re-render. You can test it out with the "Remove row" button. CC: @micheal-parks |
I don't think so, but I will do a build to compare. I updated the PoC to use modules provided by |
Added row variants. Only outstanding feature is the |
Updated styles to match more recent table designs. |
Please let me know if there is a use case you would like to see me include in the example. |
data?.variant === 'error', | ||
'!border-green-100 !bg-green-50 !text-green-700': ({ data }) => | ||
data?.variant === 'success', | ||
'!bg-gray-50 !text-gray-500': ({ data }) => data?.variant === 'disabled', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] can we update these to our theme colors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, these were taken straight from the table component but we are tweaking the designs anyway so we should just keep to the theme.
flex: 1, | ||
}, | ||
}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to add table data with custom elements? ie. in the fleet dashboard project, some of the values should be in pills
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is, but we will have to figure out how to make that work with svelte. I can make that the next thing to try in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool PoC! Left some initial thoughts that are primarily concerns about productionization and integrating this into the existing app architecture. So far, I still need convincing that ag-grid
is a good choice for our app - I'm a little worried that, for our needs, it makes the wrong tradeoffs. That being said, my current focus is on the needs of the fleet dashboard specifically, and there my be other functionality needs elsewhere in the app that I'm not familiar with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this lockfile change contains unnecessary changes, it can be regenerated from main
to remove unrelated bumps
git checkout main -- pnpm-lock.yaml
pnpm install
pnpm dedupe
git add pnpm-lock.yaml
I'm showing a much smaller diff after this:
❯ git diff --stat main -- pnpm-lock.yaml
pnpm-lock.yaml | 925 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------
1 file changed, 579 insertions(+), 346 deletions(-)
{ | ||
id: 1, | ||
first_name: 'Bobette', | ||
last_name: 'Dankov', | ||
email: '[email protected]', | ||
ip_address: '212.10.172.113', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling to see how this proposed API of the component would be used by the machines dashboard table, where cells are are frequently made up of interactable elements and/or other Prime components.
I can see that ag-grid
has an API for defining cell components, which we could use to live-render Svelte components, but managing that sort of compatibility layer makes me uneasy.
I think doing this work in the prime repository might be too much of a bottom-up approach for this kind of UI component. Would it be possible to take this work and drop it into This decision happened while my review was in progressapp
instead, so we can iterate on a PoC with the actual use case of the all machines table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the row data API, I think we should look at defining custom components to be used in the columnDefs
. The components would need to accept the expected data object and understand how to render (like the status badge) based on that.
There is a few different ways they manage creating cell renderers. I think the only layer we would need is something to make that accept Svelte components, which I saw a svelte 3 example of here. I think a similar wrapper that allows us to pass svelte components as a part of the object should work, that is next on my plan to experiment with.
onMount(() => { | ||
grid = createGrid( | ||
eGui, | ||
{ ...options, columnDefs, rowData, rowClassRules }, | ||
params | ||
); | ||
return () => grid.destroy(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned about taking a table approach that is entirely client-side rendered. We have "tables" that are currently capable of being rendered at build time, but switching to this would lock us out of that possibility - e.g. /registry
I have no experience with the library, but I wonder if a headless solution like tanstack table (20.3 kB (gzip)
), where we define our own markup directly, would have an acceptable feature set / performance for our needs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't dig too deep, but server-side rendering for rows is an enterprise feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All for considering tanstack table if it's a better solution since we haven't started investing in ag-grid yet
"@ag-grid-community/client-side-row-model": "^32.1.0", | ||
"@ag-grid-community/core": "^32.1.0", | ||
"@ag-grid-community/styles": "^32.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick check on bundle.js
, and it looks like these packages will add 221 kB (gzip)
to our page bundles where they're used. If we go this route, I think we'll need try to make it easy to code split
Closing this, @mcous is opening another PR on the |
This is a PoC to show a relatively quick-and-dirty implementation of ag-grid in Svelte. This gives us column sorting and drag-and-drop right out of the box, and one of the existing themes is already pretty close to what we probably want. I tried to make this a pretty straightforward passthrough of the ag-grid API, but the current props are large, deeply nesting objects, so there may be some performance concerns.
The following steps will be to add styles to overwrite the theme and match ours.
The large diff is due to updates in the
pnpm
lockfile.Note to reviewers: I added you because the topic of using an ag-grid for tables has been raised a few times now, and I wanted to start the conversation about what it would look like. Feel free to remove yourself from the PR if this isn't relevant to you.