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

TreeTable React component #813

Merged
merged 34 commits into from
Mar 4, 2024
Merged

TreeTable React component #813

merged 34 commits into from
Mar 4, 2024

Conversation

bobular
Copy link
Member

@bobular bobular commented Jan 30, 2024

Latest story! Responds appropriately to rowHeight prop in the controls. (Though the table row height is a minimum height so things don't line up below a certain value (42 for me).)
image

Firstly I followed much of Dave's work here #559
But I wanted it to be a components component, not something only working in ortho-site.

So I started with a super-simple story, and I'm working backwards from there.

  1. cd packages/libs/components
  2. yarn add d3v5@npm:d3@5 - adds version 5 with the alias d3v5
  3. yarn add tidytree@github:d-callan/TidyTree
  4. yarn add --dev imports-loader@^1.1.1 exports-loader@^1.1.1 - Storybook uses webpack 4, this page suggests v1.1.1 is the last suitable for webpack 4
  5. make crude tidytree.d.ts for now
  6. add Dave's shimming to .storybook/main.js
  7. make story
  8. copy test data to story directory
  9. find that patristic isn't available to tidytree.js
  10. add an extra shim for patristic in .storybook/main.js - this wasn't needed in Dave's PR but that was using webpack 5.
  11. it seems to work!

Notes

I tried to get storybook-addon-deep-controls working for the nested args object in the story, but I couldn't get it to work. Have given up!

I installed react-query as a dev dependency and provided the Storybook wrappings for it, but stopped using it. We should probably leave it in though, right?

Question

How do we get the shimming to work when the component is used outside of Storybook?

@bobular
Copy link
Member Author

bobular commented Feb 6, 2024

tidytree margin specs are not [ top, right, bottom, left ] as indicated in the code, and it's difficult to work out what is going on. For now we will work with zero margins and live with the leaf nodes being chopped in half and the left-most edges not being very clear either.

@bobular
Copy link
Member Author

bobular commented Feb 7, 2024

tidytree margin specs are not [ top, right, bottom, left ] as indicated in the code, and it's difficult to work out what is going on. For now we will work with zero margins and live with the leaf nodes being chopped in half and the left-most edges not being very clear either.

Fixed these margin/spacing issues in our fork :-) https://github.com/d-callan/TidyTree/pulls

Now we have the vertical alignment bit pretty much sorted. Can start building a tree-table component next.

First I think I will nail down this TidyTree.tsx component to only do horizontal dendrograms - or wrap a horizontal dendrogram component around it. The rowHeight prop would make no sense in a vertical tree, for example. Not sure how general purpose TidyTree will need to be...

@d-callan d-callan marked this pull request as ready for review February 7, 2024 15:00
@bobular bobular marked this pull request as draft February 7, 2024 18:18
@@ -71,6 +73,7 @@
"@babel/core": "^7.17.9",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@emotion/css": "^11.11.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

Does this eventually need to be a regular runtime dependency because we're doing runtime dynamic styling with cx(css(...))?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, it probably does

@bobular bobular changed the title TidyTree as a React component TreeTable React component Feb 19, 2024
@bobular
Copy link
Member Author

bobular commented Feb 19, 2024

Would the props be better split into treeProps and tableProps rather than extending the tree props as done presently?

Copy link
Member

@d-callan d-callan left a comment

Choose a reason for hiding this comment

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

mostly i just played w storybook, but i think its looking good! 😸 I notice there isnt a dendrogram story w the branches colored as well, but just looking at the component api quickly suggests it should be possible. 👍

},
];

const tableColumns: MesaColumn<LeafRow>[] = [
Copy link
Member

Choose a reason for hiding this comment

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

idk enough to know... is it easy to add a column of check boxes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for having a look. There's a separate story in "HorizontalDendrogram" with some non-table checkboxes that colour the tree.

I should probably wire up the TreeTable to use table-based checkboxes. Would be a good thing for the story.

@bobular
Copy link
Member Author

bobular commented Feb 23, 2024

Would the props be better split into treeProps and tableProps rather than extending the tree props as done presently?

I did this while adding the checkbox selection, which seems to work fine.

image

@bobular
Copy link
Member Author

bobular commented Feb 23, 2024

I factored out the shimming here c62b622

Hopefully this will be visible to other packages as const { addD3Shimming } = require('@veupathdb/components/webpack-shimming'); but we will see! I might have to move it into somewhere that gets packaged up?

@bobular bobular marked this pull request as ready for review March 4, 2024 15:14
@bobular bobular merged commit d344d72 into main Mar 4, 2024
1 check passed
@bobular bobular deleted the tidytree-component branch March 4, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants