-
Notifications
You must be signed in to change notification settings - Fork 41
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
add SkipToContent button to SubdomainNavBar #503
Conversation
🦋 Changeset detectedLatest commit: 3e86b7d The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🟢 No design token changes found |
|
width: 1px; | ||
height: 1px; | ||
padding: 0; | ||
overflow: hidden; | ||
clip: rect(1px, 1px, 1px, 1px); | ||
border: 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.
This is just visually hiding it, right? If so, could this be done programmatically by adding the global visually-hidden
class?
<Button | ||
as="a" | ||
href="#start-of-content" | ||
variant="primary" | ||
className={clsx(styles['SubdomainNavBar-skip-to-content'])} | ||
> | ||
Skip to content | ||
</Button> |
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.
@auareyou Checking that you've seen the proposed design here? I'm not sure the button styling works, and that we need something a bit more custom. The button feels too big IMO. What do you think? Happy to take your steer here.
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 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.
Discussed at maintainer sync. We'll move forward with this design as an interim-step, with @auareyou exploring more integrated presentation down the line.
@joseph-lozano I'd suggest use banner stretching under the header to avoid having the button awkwardly overlap the header UI like this: ![]() Since this would be a custom additions we could consider using our button component and stretch it full width (like Linear does). Since our CTA component is very chunky it would look like this - ideally we'd want to remove the border radius for it too look more like the banner above. ![]() Happy to see/review whatever is feasible here |
onFocus={() => setStartOfContentButtonFocused(true)} | ||
onBlur={() => setStartOfContentButtonFocused(false)} |
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.
Possible to extract these functions outside of the return statement please? Potentially wrapping in a useCallback
? Micro-perf optimisation to avoid creating a new function each time. I missed this last time, sorry.
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.
LGTM. Added some more minor feedback, otherwise good to go
Nice work @joseph-lozano ✨
After chatting at the Accessiblity Eng+ Office Hours, it sounds like we should first look for a Additionally, if we create the |
502d4b6
to
96d963d
Compare
useEffect(() => { | ||
const main = document.getElementsByTagName('main')[0] as HTMLElement | undefined | ||
if (!main) return | ||
if (!main.id && startOfContentID) main.id = startOfContentID | ||
setMainTag(main) | ||
}, [setMainTag, startOfContentID]) |
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.
@rezrah this seems... somehow wrong, but unsure how else I might satisfy the a11y team's recommendation. Do you have any thoughts?
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 wouldn't recommend storing the element in React state, if that's what you're asking?That's really heavy and refs
are better for this IMO.
This is just pseudocode so you'll need to try it, but can you do something like:
const mainElRef = useRef<HTMLElement | null>(null);
useEffect(() => {
const main = document.getElementsByTagName('main')[0] as HTMLElement | undefined
if(el and otherStuff) {
mainElRef.current = el;
}
}, []);
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.
@rezrah my man, I think this is GTG test:axe
doesn't work on Codespaces, so I'll have to try this on my local.
Do we even need them?
@rezrah thanks for helping me sort out running the But then this wasn't what I needed, what I needed was to get that cd apps/storybook
npm i # which I think doesn't do anything cause node_modules are in the root directory
npx storybook build This gave me the So I curated the ![]() These stories include ![]() I wonder if we can load the desired story independently of the story chooser. I think we should be able to do so. I'll try to update the code. Here is the suggested sketch: #546 But as the instant remedy I added these two stories in question to the ignore list. Since they are just for testing the ability to scroll to P.S. The reason I needed to curate the ![]() |
Summary
Adds a
SkipToContent
button to theSubdomainNavBar
List of notable changes:
SkipToContent
button to theSubdomainNavBar
What should reviewers focus on?
Does the button work?
Does it properly hide itself when not in focus?
Does it jump to the content of the page.
Steps to test:
You can test this component on any of the SubdomainNavBar stories, e.g. https://primer-6e6587907b-26139705.drafts.github.io/storybook/?path=/story/components-subdomainnavbar--playground
Supporting resources (related issues, external links, etc):
Solves #404
Contributor checklist:
Reviewer checklist:
Screenshots: