Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions packages/@react-spectrum/s2/chromatic/Slider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ FormatOptions.args = {
formatOptions: {style: 'currency', currency: 'JPY'}
};

export const MinMaxValue = (args: any) => (
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'start', gap: 8}}>
<Slider {...args} />
</div>
);

MinMaxValue.args = {
label: 'Size',
minValue: 1,
maxValue: 5
};

export const ContextualHelpExample = (args: any) => (
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'start', gap: 8}}>
<Slider {...args} />
Expand Down
5 changes: 2 additions & 3 deletions packages/@react-spectrum/s2/src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ const output = style({
});

export let track = style({
...fieldInput(),
gridArea: 'track',
position: 'relative',
width: 'full',
Expand Down Expand Up @@ -379,7 +378,7 @@ export function SliderBase<T extends number | number[]>(props: SliderBaseProps<T
</FieldLabel>
{labelPosition === 'top' && outputValue}
</div>
<div className={style({gridArea: 'input', display: 'inline-flex', alignItems: 'center', gap: {default: 16, size: {L: 20, XL: 24}}})({size})}>
<div className={style({...fieldInput(), display: 'inline-flex', alignItems: 'center', gap: {default: 16, size: {L: 20, XL: 24}}})({size})}>
{props.children}
{labelPosition === 'side' && outputValue}
</div>
Expand Down Expand Up @@ -416,7 +415,7 @@ function Slider(props: SliderProps, ref: FocusableRef<HTMLDivElement>) {
className={track({size, labelPosition, isInForm: !!formContext})}>
{({state, isDisabled}) => {

fillOffset = fillOffset !== undefined ? clamp(fillOffset, state.getThumbMinValue(0), state.getThumbMaxValue(0)) : 0;
fillOffset = fillOffset !== undefined ? clamp(fillOffset, state.getThumbMinValue(0), state.getThumbMaxValue(0)) : state.getThumbMinValue(0);

let fillWidth = state.getThumbPercent(0) - state.getValuePercent(fillOffset);
let isRightOfOffset = fillWidth > 0;
Expand Down