-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Added Range Slider Example #351
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
Open
MyLightIsOn
wants to merge
7
commits into
main
Choose a base branch
from
299-range-slider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4ddda13
Added range slider
MyLightIsOn 6803490
Connected text input to range slider
MyLightIsOn 41f18ff
Change text input to span
MyLightIsOn f439bce
Moved variables to top of function for clarity
MyLightIsOn d4c2672
Removed uneeded aria-label prop
MyLightIsOn 34ca65e
Fixed type errors
MyLightIsOn 026f1ac
Updated event type in getMarkdownFunctionMap
MyLightIsOn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { NavigateFunction } from 'react-router-dom'; | ||
|
|
||
| import React from 'react'; | ||
| /** | ||
| * A map of callable functions that can be referenced inside Markdown files rendered as HTML. | ||
| * | ||
|
|
@@ -21,7 +21,7 @@ import { NavigateFunction } from 'react-router-dom'; | |
| */ | ||
| export const getMarkdownFunctionMap = ( | ||
| navigate: NavigateFunction | ||
| ): Record<string, (event: React.MouseEvent<Element>) => void> => ({ | ||
| ): Record<string, (event: React.SyntheticEvent) => void> => ({ | ||
|
Collaborator
Author
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. I changed MouseEvent to SyntheticEvent to generalize the Markdown function handler type to accept any React synthetic event. This allows buttons/links/divs (mouse events) and inputs (form/change events) are all supported consistently. |
||
| showAlert: () => alert('This works with a keyboard and a mouse!'), | ||
| showAlertWhenDisabled: () => | ||
| alert('This disabled button is still actionable for mouse and screen readers users!'), | ||
|
|
@@ -156,16 +156,16 @@ export const getMarkdownFunctionMap = ( | |
| if (!stepperSelect || stepperSelect.tagName.toLowerCase() !== 'select') { | ||
| return; // Exit if the provided element is not a select element | ||
| } | ||
|
|
||
| let currentIndex = stepperSelect.selectedIndex; | ||
| let nextIndex = currentIndex + 1; | ||
|
|
||
| if (nextIndex < stepperSelect.options.length) { | ||
| stepperSelect.selectedIndex = nextIndex; | ||
|
|
||
| if (liveRegion) { | ||
| liveRegion.innerHTML = `Quantity updated, ${nextIndex+1}`; | ||
|
|
||
| setTimeout(() => { | ||
| liveRegion.innerHTML = ''; | ||
| }, 2000); | ||
|
|
@@ -180,18 +180,18 @@ export const getMarkdownFunctionMap = ( | |
| if (!stepperSelect || stepperSelect.tagName.toLowerCase() !== 'select') { | ||
| return; // Exit if the provided element is not a select element | ||
| } | ||
|
|
||
| let currentIndex = stepperSelect.selectedIndex; | ||
| let nextIndex = currentIndex - 1; | ||
|
|
||
| if (currentIndex===0) { | ||
| return; // do nothing if at 0 | ||
| } else if (nextIndex < stepperSelect.options.length) { | ||
| stepperSelect.selectedIndex = nextIndex; | ||
|
|
||
| if (liveRegion) { | ||
| liveRegion.innerHTML = `Quantity updated, ${currentIndex}`; | ||
|
|
||
| setTimeout(() => { | ||
| liveRegion.innerHTML = ''; | ||
| }, 2000); | ||
|
|
@@ -221,11 +221,11 @@ export const getMarkdownFunctionMap = ( | |
|
|
||
| // Get current state | ||
| const isExpanded = toggleButton.getAttribute('aria-expanded') === 'true'; | ||
| // Toggle the state - use only aria-expanded attribute | ||
|
|
||
| // Toggle the state - use only aria-expanded attribute | ||
| const newExpandedState = !isExpanded; | ||
| toggleButton.setAttribute('aria-expanded', String(newExpandedState)); | ||
|
|
||
| }, | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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's no styling here yet, but if the functionality checks out, I can spice it up.