Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Pad in slider so the thumb does not render outside the bounds of the root element",
"packageName": "@fluentui/react-slider",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const useRootStyles = makeStyles({
root: {
position: 'relative',
display: 'inline-grid',
gridTemplateAreas: '"slider"',
gridTemplateAreas: '". . ." ". slider ." ". . ."',
touchAction: 'none',
alignItems: 'center',
justifyItems: 'center',
Expand All @@ -54,12 +54,15 @@ const useRootStyles = makeStyles({
horizontal: {
minWidth: '120px',
height: `var(${thumbSizeVar})`,
gridTemplateRows: `1fr var(${thumbSizeVar}) 1fr`,
gridTemplateColumns: `1fr calc(100% - var(${thumbSizeVar})) 1fr`,
},

vertical: {
width: `var(${thumbSizeVar})`,
minHeight: '120px',
gridTemplateColumns: `var(${thumbSizeVar})`,
gridTemplateRows: `1fr calc(100% - var(${thumbSizeVar})) 1fr`,
gridTemplateColumns: `1fr var(${thumbSizeVar}) 1fr`,
},

enabled: {
Expand Down Expand Up @@ -181,6 +184,10 @@ const useRailStyles = makeStyles({
const useThumbStyles = makeStyles({
thumb: {
position: 'absolute',
gridRowStart: 'slider',
gridRowEnd: 'slider',
gridColumnStart: 'slider',
gridColumnEnd: 'slider',
width: `var(${thumbSizeVar})`,
height: `var(${thumbSizeVar})`,
pointerEvents: 'none',
Expand All @@ -189,7 +196,6 @@ const useThumbStyles = makeStyles({
...shorthands.borderRadius(tokens.borderRadiusCircular),
boxShadow: `0 0 0 calc(var(${thumbSizeVar}) * .2) ${tokens.colorNeutralBackground1} inset`,
backgroundColor: `var(${thumbColorVar})`,
transform: 'translateX(-50%)',
'::before': {
position: 'absolute',
top: '0px',
Expand All @@ -208,10 +214,13 @@ const useThumbStyles = makeStyles({
},
},
horizontal: {
transform: 'translate(-50%, -50%)',
top: '50%',
left: `var(${sliderProgressVar})`,
},
vertical: {
transform: 'translateY(50%)',
transform: 'translate(-50%, 50%)',
left: '50%',
bottom: `var(${sliderProgressVar})`,
},
});
Expand All @@ -222,19 +231,19 @@ const useThumbStyles = makeStyles({
const useInputStyles = makeStyles({
input: {
opacity: 0,
gridRowStart: 'slider',
gridRowEnd: 'slider',
gridColumnStart: 'slider',
gridColumnEnd: 'slider',
gridRowStart: '1',
gridRowEnd: '-1',
gridColumnStart: '1',
gridColumnEnd: '-1',
...shorthands.padding(0),
...shorthands.margin(0),
},
horizontal: {
height: `var(${thumbSizeVar})`,
width: `calc(100% + var(${thumbSizeVar}))`,
width: '100%',
},
vertical: {
height: `calc(100% + var(${thumbSizeVar}))`,
height: '100%',
width: `var(${thumbSizeVar})`,
'-webkit-appearance': 'slider-vertical',
},
Expand Down