-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Create SliderUnstyled docs #31850
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
54f7c6d
Move existing SliderUnstyled docs
michaldudak 8f56327
Add more demos
michaldudak ebe6c3b
Apply suggestions from code review
michaldudak ad89606
Update demos' styles
michaldudak 2eb5eb2
Merge remote-tracking branch 'upstream/master' into docs/slider
michaldudak 3dde137
Fix generated links
michaldudak 8ef06ac
Correct mark labels' styles
michaldudak ba4dded
Merge remote-tracking branch 'upstream/master' into docs/slider
michaldudak c85afc6
Merge remote-tracking branch 'upstream/master' into docs/slider
michaldudak 47eaff0
docs:api
michaldudak 9469b66
Merge remote-tracking branch 'upstream/master' into docs/slider
michaldudak 4c7f510
Fix broken demos
michaldudak 47aac7f
Merge remote-tracking branch 'upstream/master' into docs/slider
michaldudak 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 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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import * as React from 'react'; | ||
import { styled, alpha, Box } from '@mui/system'; | ||
import SliderUnstyled from '@mui/base/SliderUnstyled'; | ||
|
||
const StyledSlider = styled(SliderUnstyled)( | ||
({ theme }) => ` | ||
color: ${theme.palette.mode === 'light' ? '#1976d2' : '#90caf9'}; | ||
height: 4px; | ||
width: 100%; | ||
padding: 13px 0; | ||
display: inline-block; | ||
position: relative; | ||
cursor: pointer; | ||
touch-action: none; | ||
-webkit-tap-highlight-color: transparent; | ||
opacity: 0.75; | ||
|
||
&:hover { | ||
opacity: 1; | ||
} | ||
|
||
& .MuiSlider-rail { | ||
display: block; | ||
position: absolute; | ||
width: 100%; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
opacity: 0.38; | ||
} | ||
|
||
& .MuiSlider-track { | ||
display: block; | ||
position: absolute; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
} | ||
|
||
& .MuiSlider-thumb { | ||
position: absolute; | ||
width: 14px; | ||
height: 14px; | ||
margin-left: -6px; | ||
margin-top: -5px; | ||
box-sizing: border-box; | ||
border-radius: 50%; | ||
outline: 0; | ||
border: 2px solid currentColor; | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-mark { | ||
position: absolute; | ||
width: 4px; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
top: 50%; | ||
opacity: 0.7; | ||
transform: translateX(-50%); | ||
} | ||
|
||
& .MuiSlider-markActive { | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-valueLabel { | ||
font-family: IBM Plex Sans; | ||
font-size: 14px; | ||
display: block; | ||
position: relative; | ||
top: -1.6em; | ||
text-align: center; | ||
transform: translateX(-50%); | ||
|
||
} | ||
|
||
:hover, | ||
&.Mui-focusVisible { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.15, | ||
)}; | ||
} | ||
|
||
&.Mui-active { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.3, | ||
)}; | ||
} | ||
`, | ||
); | ||
|
||
function valuetext(value) { | ||
return `${value}°C`; | ||
} | ||
|
||
export default function DiscreteSlider() { | ||
return ( | ||
<Box sx={{ width: 300 }}> | ||
<StyledSlider | ||
aria-label="Temperature" | ||
defaultValue={30} | ||
getAriaValueText={valuetext} | ||
valueLabelDisplay="auto" | ||
step={10} | ||
marks | ||
min={10} | ||
max={110} | ||
/> | ||
</Box> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import * as React from 'react'; | ||
import { styled, alpha, Box } from '@mui/system'; | ||
import SliderUnstyled from '@mui/base/SliderUnstyled'; | ||
|
||
const StyledSlider = styled(SliderUnstyled)( | ||
({ theme }) => ` | ||
color: ${theme.palette.mode === 'light' ? '#1976d2' : '#90caf9'}; | ||
height: 4px; | ||
width: 100%; | ||
padding: 13px 0; | ||
display: inline-block; | ||
position: relative; | ||
cursor: pointer; | ||
touch-action: none; | ||
-webkit-tap-highlight-color: transparent; | ||
opacity: 0.75; | ||
|
||
&:hover { | ||
opacity: 1; | ||
} | ||
|
||
& .MuiSlider-rail { | ||
display: block; | ||
position: absolute; | ||
width: 100%; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
opacity: 0.38; | ||
} | ||
|
||
& .MuiSlider-track { | ||
display: block; | ||
position: absolute; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
} | ||
|
||
& .MuiSlider-thumb { | ||
position: absolute; | ||
width: 14px; | ||
height: 14px; | ||
margin-left: -6px; | ||
margin-top: -5px; | ||
box-sizing: border-box; | ||
border-radius: 50%; | ||
outline: 0; | ||
border: 2px solid currentColor; | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-mark { | ||
position: absolute; | ||
width: 4px; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
top: 50%; | ||
opacity: 0.7; | ||
transform: translateX(-50%); | ||
} | ||
|
||
& .MuiSlider-markActive { | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-valueLabel { | ||
font-family: IBM Plex Sans; | ||
font-size: 14px; | ||
display: block; | ||
position: relative; | ||
top: -1.6em; | ||
text-align: center; | ||
transform: translateX(-50%); | ||
|
||
} | ||
|
||
:hover, | ||
&.Mui-focusVisible { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.15, | ||
)}; | ||
} | ||
|
||
&.Mui-active { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.3, | ||
)}; | ||
} | ||
`, | ||
); | ||
|
||
function valuetext(value: number) { | ||
return `${value}°C`; | ||
} | ||
|
||
export default function DiscreteSlider() { | ||
return ( | ||
<Box sx={{ width: 300 }}> | ||
<StyledSlider | ||
aria-label="Temperature" | ||
defaultValue={30} | ||
getAriaValueText={valuetext} | ||
valueLabelDisplay="auto" | ||
step={10} | ||
marks | ||
min={10} | ||
max={110} | ||
/> | ||
</Box> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/data/base/components/slider/DiscreteSlider.tsx.preview
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<StyledSlider | ||
aria-label="Temperature" | ||
defaultValue={30} | ||
getAriaValueText={valuetext} | ||
valueLabelDisplay="auto" | ||
step={10} | ||
marks | ||
min={10} | ||
max={110} | ||
/> |
131 changes: 131 additions & 0 deletions
131
docs/data/base/components/slider/DiscreteSliderMarks.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import * as React from 'react'; | ||
import { styled, alpha, Box } from '@mui/system'; | ||
import SliderUnstyled from '@mui/base/SliderUnstyled'; | ||
|
||
const StyledSlider = styled(SliderUnstyled)( | ||
({ theme }) => ` | ||
color: ${theme.palette.mode === 'light' ? '#1976d2' : '#90caf9'}; | ||
height: 4px; | ||
width: 100%; | ||
padding: 13px 0; | ||
display: inline-block; | ||
position: relative; | ||
cursor: pointer; | ||
touch-action: none; | ||
-webkit-tap-highlight-color: transparent; | ||
opacity: 0.75; | ||
|
||
&:hover { | ||
opacity: 1; | ||
} | ||
|
||
& .MuiSlider-rail { | ||
display: block; | ||
position: absolute; | ||
width: 100%; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
opacity: 0.38; | ||
} | ||
|
||
& .MuiSlider-track { | ||
display: block; | ||
position: absolute; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
} | ||
|
||
& .MuiSlider-thumb { | ||
position: absolute; | ||
width: 14px; | ||
height: 14px; | ||
margin-left: -6px; | ||
margin-top: -5px; | ||
box-sizing: border-box; | ||
border-radius: 50%; | ||
outline: 0; | ||
border: 2px solid currentColor; | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-mark { | ||
position: absolute; | ||
width: 4px; | ||
height: 4px; | ||
border-radius: 2px; | ||
background-color: currentColor; | ||
top: 50%; | ||
opacity: 0.7; | ||
transform: translateX(-50%); | ||
} | ||
|
||
& .MuiSlider-markActive { | ||
background-color: #fff; | ||
} | ||
|
||
& .MuiSlider-markLabel { | ||
font-family: IBM Plex Sans; | ||
font-size: 14px; | ||
position: absolute; | ||
white-space: nowrap; | ||
top: 30px; | ||
-webkit-transform: translateX(-50%); | ||
-moz-transform: translateX(-50%); | ||
-ms-transform: translateX(-50%); | ||
transform: translateX(-50%); | ||
} | ||
|
||
:hover, | ||
&.Mui-focusVisible { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.15, | ||
)}; | ||
} | ||
|
||
&.Mui-active { | ||
box-shadow: 0 0 0 0.25rem ${alpha( | ||
theme.palette.mode === 'light' ? '#1976d2' : '#90caf9', | ||
0.3, | ||
)}; | ||
} | ||
`, | ||
); | ||
|
||
const marks = [ | ||
{ | ||
value: 0, | ||
label: '0°C', | ||
}, | ||
{ | ||
value: 20, | ||
label: '20°C', | ||
}, | ||
{ | ||
value: 37, | ||
label: '37°C', | ||
}, | ||
{ | ||
value: 100, | ||
label: '100°C', | ||
}, | ||
]; | ||
|
||
function valuetext(value) { | ||
return `${value}°C`; | ||
} | ||
|
||
export default function DiscreteSliderMarks() { | ||
return ( | ||
<Box sx={{ width: 300 }}> | ||
<StyledSlider | ||
aria-label="Temperature" | ||
defaultValue={37} | ||
getAriaValueText={valuetext} | ||
marks={marks} | ||
/> | ||
</Box> | ||
); | ||
} |
Oops, something went wrong.
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.
We should improve the hover styles:
Also, we need a focus visible styles on the thumb, there is not indication that it is focused.