-
Notifications
You must be signed in to change notification settings - Fork 0
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(components): a simple HTML-based Tree component #112
Conversation
NB: this PR implements a simplified version of our current tree renderer from vonnegut, mostly as a learning exercise / to check that CI works as I expect. I don't know if we want to actually commit it, and if we do it probably needs some polish. The example trees are exported from primer
|
8f0f7ad
to
39f0314
Compare
I actually think these could be perfect for a screen reader implementation. I've previously mentioned wanting to keep around the Vonnegut tree rendering style for that reason, but this one would be much easier to maintain and just as good from an a11y perspective, I would imagine. |
You mentioned that for a11y purposes, probably the first, "outline"/"nested |
Yeah, I think that's my preference for now. Perhaps you should keep the current branch head around somewhere in case we want to return to the "pretty" HTML version of the tree, but personally, I think the outline-ish version in your original commit was more interesting for the long term. If nothing else, it means it will be easier to maintain with less styling. |
39f0314
to
e528896
Compare
I have moved the "fancy css tree" to https://github.com/hackworthltd/primer-app/tree/brprice/tree-html-fancy , and this PR is now just the "outline" tree. |
Good idea. I'll review this shortly. |
See my comment on the storybook https://www.chromatic.com/test?appId=61562fccd90e96003afe472a&id=6193a7f67b9bc0003a9d719c -- it seems things are getting cut off, but I'm not sure why this is. |
Ugh, I can't build this on my |
e528896
to
5c042eb
Compare
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.
Let's move the Tree
core type into @hackworthltd/primer-types
, but otherwise, this looks good. Thanks!
</ul> | ||
); | ||
|
||
function ChildTrees({ trees }: { trees: TreeI[] }): JSX.Element { |
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.
It's not specific to this PR, but it seems like a good time to bring it up, as it's still early days and now's a good time to have a policy.
Personally, I really dislike this distinction between function
and const
. Should we use function
consistently? It seems to be anti-vogue, but I confess I don't understand why, exactly.
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.
TBH, I don't really understand the difference (there seems to be some difference in "hoisting"/scoping: it seems that function
s are visible through the entire file, but const
s are only visible below where they are defined? Also you can apparently re-bind functions in JS, so const
is perhaps slightly safer?). Mostly I use whichever one makes the linter not complain, defaulting to const
for simple things as const Foo = () => <Component ... />
is easier than function Foo () { return <Component ... /> }
.
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.
The linter has a million options, so we could probably disable that specific complaint.
Anyway, I guess we should just go with the flow for now.
</ul> | ||
); | ||
} | ||
return <></>; |
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.
(Parenthetical: return <></>;
seems like something we'll need fairly often. I wonder if there's a way to define a JSX constant value for <></>
.)
@@ -9,4 +9,5 @@ export { default as SearchBar } from "@/SearchBar"; | |||
export { default as SessionList } from "@/SessionList"; | |||
export { default as SessionPreview } from "@/SessionPreview"; | |||
export { default as SessionsNavBar } from "@/SessionsNavBar"; | |||
export { default as Tree } from "@/Tree"; |
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.
FYI, I've been doing this for each new type, too, but I suspect we'll need to export each component's properties as well in the index.ts
file, in order to make it useful. Anyway, that's out of scope.
Oh, minor meta-nit: I believe that Conventional Commits requires a FYI, I think the way Bors works is that it uses the title of the PR and the contents of the first comment in its commit message, so there's not necessarily any need to force-push this change/typo fix to any of your git commits. Also, to clarify: we're not enforcing Conventional Commits yet, but I think I will want to do that soon-ish, as I think it works pretty well and really the whole point of it IMO is to get some nice automation & tooling out of it. |
One last point about this PR. I think this will be a great basis for a screen reader implementation of Primer's canvas. However, we'll probably want to at least decorate the tree with nicer names than (edit In fact, one potentially nice, modular approach might be to pass the |
5c042eb
to
6cc26e1
Compare
Yes. I consider this out-of-scope here though. |
bors try |
tryTimed out. |
Hmm, I'm not sure why that timed out. It appears it succeeded on the Hydra: https://hydra.hackworth-corp.com/eval/380650 |
bors merge |
112: feat(components): a simple HTML-based Tree component r=brprice a=brprice We add a tree render which emits plain html trees, as nested lists. Co-authored-by: Ben Price <[email protected]>
This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried. Additional information: {"message":"2 of 3 required status checks are expected.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
I don't know why bors failed (maybe it timed out before hydra finished?). Let's try again |
112: feat(components): a simple HTML-based Tree component r=brprice a=brprice We add a tree render which emits plain html trees, as nested lists. Co-authored-by: Ben Price <[email protected]>
This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried. Additional information: {"message":"2 of 3 required status checks are expected.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
We render it in a simple nested list format. This is intended to be simple to maintain and a good basis for an accessibility-focussed component.
This unfortunately involves a lot of renaming churn, since the openapi description calls it 'Tree', rather than 'TreeI'. However, this is a good thing to do anyway, since having the bare-bones outline component being called 'Tree' would be confusing when we have some other, fancier, tree component as well.
6cc26e1
to
708100f
Compare
I have rebased onto main. Let's see how bors is feeling |
Ahh, I think perhaps at least some of our mysterious Bors merge failures (on this repo, anyway) are due to the fact that Bors doesn't know about the Chromatic jobs. So if Bors creates a new rev in order to merge, even if Bors succeeds, GitHub rejects the merge because the Chromatic jobs haven't run. I don't think there's any way to teach Bors that if it does its own merge that it also needs to start Chromatic jobs, so probably |
bors merge |
Build succeeded: |
tryTimed out. |
We add a tree render which emits plain html trees, as nested lists.