-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
init: add skip-to-main-content shortcut #7390
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Yaten Dhingra <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think currently on pressing Edit: Sorry, will not ping 👍 |
WOW stop pinging everyone ! we (website team) receive notification when there are changes on repo. |
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
apps/site/components/withNavBar.tsx
Outdated
|
||
const toggleCurrentTheme = () => | ||
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark'); | ||
|
||
return ( | ||
<div> | ||
<a className={classNameOnTabPress} href="#main"> |
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.
Anchor href is not working, main element is missing the id attribute.
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 href won't work as of now, because I just set it randomly to #main
, I wanted to clarify that to what section the user must be directed to on clicking this 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.
I believe It should redirect to main
indeed
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.
For this, is there a main
class present in the pages? Ig not?
There is this <main/>
tag present in the about page, just for 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.
Sorry, I don't understand what you saying
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 was trying to say that on any page, since we're redirecting to #main
, there is no such class as #main
on any page, so where should the user be redirected?
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.
User should be "redirected" to main
, layouts lives on apps/site/layouts
.
Signed-off-by: Yaten Dhingra <[email protected]>
I've pushed a minor change(typo). Just wanted to ask, that could anyone please guide regarding these points, I was having a few doubts: |
Signed-off-by: Yaten Dhingra <[email protected]>
Signed-off-by: Yaten Dhingra <[email protected]>
Hi, I've pushed a commit, and I think that this addresses all the changes mentioned and required! Could anyone please have a look at it and LMK if any change has to be made in this? |
Hey, can anyone please have a look and LMK if any more changes are required? |
apps/site/components/withNavBar.tsx
Outdated
|
||
const toggleCurrentTheme = () => | ||
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark'); | ||
|
||
return ( | ||
<div> | ||
<a className={skipToContent} href="#main"> |
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.
<a className={skipToContent} href="#main"> | |
<Button className={skipToContent} href="#main"> |
use the component button @/components/common/Button
it's already exist and use our design system
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.
Yes, the Button component already exists, but there's a problem with this - #7390 (comment)
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.
our <button>
is a <a>
under the hood
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.
so just add classname
props to add more tailwind css classes need to positioned the 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.
Pushed a commit for the same. I've changed something in the index.module.css file (Button.tsx), will it be valid?
Signed-off-by: Yaten Dhingra <[email protected]>
I've tried to pull that PR on top of |
2025-01-23.11-09-38.mp4I've shared a screen recording for the same, is this behavior not being shown on your side? I just checked that in the deployment also it's showing this. |
No even running from the DevTools My steps are: git fetch https://github.com/nodejs/nodejs.org.git HEAD
git reset FETCH_HEAD --hard
curl -L https://github.com/nodejs/nodejs.org/pull/7390.patch | git am
npm ci
npm run dev |
@@ -19,6 +21,7 @@ const layouts = { | |||
'blog-category': BlogLayout, | |||
download: DownloadLayout, | |||
article: ArticlePageLayout, | |||
skipToContent: WithNavBar, |
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 don't think skipToContent
is a page layout, IMO it is a feature in layouts
const skipToContent = classNames( | ||
'absolute left-0 top-0 m-3 -translate-y-16 bg-blue-500 p-3 transition-transform focus:translate-y-0 focus:outline-none' | ||
); | ||
|
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.
const skipToContent = classNames( | |
'absolute left-0 top-0 m-3 -translate-y-16 bg-blue-500 p-3 transition-transform focus:translate-y-0 focus:outline-none' | |
); |
Since there is no conditional class added, there is no need to use classNames
, you can write styles directly
|
||
const toggleCurrentTheme = () => | ||
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark'); | ||
|
||
return ( | ||
<div> | ||
<Button className={skipToContent} href="#main"> |
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.
<Button className={skipToContent} href="#main"> | |
<Button className="absolute left-3 top-3 -translate-y-16 focus:translate-y-0" href="#main"> |
Margin, padding, and background color don't seem to be needed 👀 Also when the button is focused, the outline must be visible, otherwise, it is not obvious that it is focused.
@@ -6,4 +6,5 @@ export type Layouts = | |||
| 'blog-category' | |||
| 'blog-post' | |||
| 'download' | |||
| 'article'; | |||
| 'article' | |||
| 'skipToContent'; |
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.
Similarly, IMO there should be no skip to content layout
Description
This PR adds a
skip to main content
button (initially hidden), when the user pressesTab
(for windows), the button is visible and the user can then move directly to the main content of the page.Related Issues
Fixes #7220
Check List
npm run format
to ensure the code follows the style guide.npm run test
to check if all tests are passing.npx turbo build
to check if the website builds without errors.