-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
doc: toggle all flavor selectors sticky on click #49526
Changes from 6 commits
bcb1e61
61d6008
3e91b7c
7922161
6ac5fc2
95e6ae6
3e7d654
ad92cfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -136,6 +136,29 @@ | |||||||||
updateHashes(); | ||||||||||
} | ||||||||||
|
||||||||||
function setupFlavorSelectors() { | ||||||||||
const kFlavorPreference = 'customFlavor'; | ||||||||||
const flavorSetting = localStorage.getItem(kFlavorPreference) === 'true'; | ||||||||||
const flavorSelectors = document.querySelectorAll('.js-flavor-selector'); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
flavorSelectors.forEach((selector) => { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
selector.checked = flavorSetting; | ||||||||||
selector.addEventListener('change', (e) => { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
const checked = e.target.checked; | ||||||||||
|
||||||||||
if (checked) { | ||||||||||
localStorage.setItem(kFlavorPreference, true); | ||||||||||
} else { | ||||||||||
localStorage.removeItem(kFlavorPreference); | ||||||||||
} | ||||||||||
|
||||||||||
flavorSelectors.forEach((el) => { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
el.checked = checked; | ||||||||||
}); | ||||||||||
}); | ||||||||||
}); | ||||||||||
} | ||||||||||
|
||||||||||
function setupCopyButton() { | ||||||||||
const buttons = document.querySelectorAll('.copy-button'); | ||||||||||
buttons.forEach((button) => { | ||||||||||
|
@@ -182,6 +205,8 @@ | |||||||||
// Make link to other versions of the doc open to the same hash target (if it exists). | ||||||||||
setupAltDocsLink(); | ||||||||||
|
||||||||||
setupFlavorSelectors(); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
setupCopyButton(); | ||||||||||
} | ||||||||||
|
||||||||||
|
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.
This comment applies to all current suggestions:
If you want to change every mention of "select" to "toggle", then we also need to change all the CSS files and also all the existing functions in
api.js
and possibly more. There are also test cases that might be affected.I think this renaming thing should go in a separate issue so we can land this feature. No need to spend time risking introducing other issues on something that is not really a problem imho.
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 I've done all the preparation work in #49536, do you think I've missed something? We can't land this PR as is because it's now inconsistent with
main
, but I think all you need to do is to merge my suggestions and this can land as soon as we have a green CI.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.
Ok, so you've committed the renaming directly onto main already?
The "setupCopyButton" function in
doc/api_assets/api.js
also uses the name "selector" everywhere, is that included? Not sure what else.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 merge and rename.