fix: style difference between w/ and w/o text input in Slider

main
Tsu-ba-me 3 years ago
parent 131b601e55
commit ef562b8082
  1. 35
      striker-ui/components/Slider.tsx

@ -61,7 +61,7 @@ const createInputLabelDecorator = ({
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
position: 'absolute', position: 'absolute',
width: '24em', width: '100%',
'> :last-child': { '> :last-child': {
flexGrow: 1, flexGrow: 1,
@ -107,6 +107,7 @@ const createOutlinedInput = ({
onChange, onChange,
onFocus, onFocus,
sliderValue, sliderValue,
sx,
}: { }: {
isFocused?: boolean; isFocused?: boolean;
max?: number; max?: number;
@ -114,7 +115,8 @@ const createOutlinedInput = ({
onBlur?: SliderOnBlur; onBlur?: SliderOnBlur;
onChange?: TextInputOnChange; onChange?: TextInputOnChange;
onFocus?: SliderOnFocus; onFocus?: SliderOnFocus;
sliderValue: SliderValue; sliderValue?: SliderValue;
sx?: MUISliderProps['sx'];
}) => ( }) => (
<OutlinedInput <OutlinedInput
{...{ {...{
@ -123,6 +125,7 @@ const createOutlinedInput = ({
onBlur, onBlur,
onChange, onChange,
onFocus, onFocus,
sx,
type: 'number', type: 'number',
value: sliderValue, value: sliderValue,
}} }}
@ -206,8 +209,8 @@ const Slider = ({
onFocus: handleLocalSliderFocus, onFocus: handleLocalSliderFocus,
sx: { sx: {
color: GREY, color: GREY,
marginLeft: '13px', marginLeft: '1em',
marginRight: '26px', marginRight: '1em',
[`& .${muiSliderClasses.thumb}`]: { [`& .${muiSliderClasses.thumb}`]: {
borderRadius: BORDER_RADIUS, borderRadius: BORDER_RADIUS,
@ -220,16 +223,20 @@ const Slider = ({
valueLabelDisplay: sliderValueLabelDisplay, valueLabelDisplay: sliderValueLabelDisplay,
}} }}
/> />
{isAllowTextInput && {createOutlinedInput({
createOutlinedInput({ isFocused,
isFocused, max,
max, min,
min, onBlur: handleLocalSliderBlur,
onBlur: handleLocalSliderBlur, onChange: handleLocalTextInputChange,
onChange: handleLocalTextInputChange, onFocus: handleLocalSliderFocus,
onFocus: handleLocalSliderFocus, sliderValue,
sliderValue, sx: isAllowTextInput
})} ? undefined
: {
visibility: 'collapse',
},
})}
</Box> </Box>
</Box> </Box>
); );

Loading…
Cancel
Save