Skip to content
41 changes: 38 additions & 3 deletions packages/@adobe/spectrum-css-temp/components/slider/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,43 @@ governing permissions and limitations under the License.

user-select: none;
touch-action: none;

width: var(--spectrum-global-dimension-size-2400);
min-inline-size: var(--spectrum-slider-min-width);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought textfield had the min width on the input parent not the field and input parent parent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah honestly I don't know which is right. I am going to bring it up with Spectrum because I don't think I was specific enough when I asked them originally.



&.spectrum-Slider--positionTop {
display: inline-flex;
flex-direction: column;
width: var(--spectrum-component-single-line-width);

.spectrum-Slider-controls {
/* If the user overrides the width of the field, propagate to the inner component */
width: calc(100% - calc(var(--spectrum-slider-controls-margin)) * 2);
}
}

/* The side label variant of Field is inline, and fills as much space as needed
* by default. If an explicit width is set, then the field flexes to fill available space. */
&.spectrum-Slider--positionSide {
display: inline-flex;
align-items: center;
width: auto;


.spectrum-Slider-controls {
flex: 1;
width: var(--spectrum-component-single-line-width);
}
.spectrum-Slider-labelContainer {
margin-inline-end: calc(var(--spectrum-slider-label-gap-x) / 2);
}

.spectrum-Slider-value {
text-align: start;
}

}
}

.spectrum-Slider-controls {
Expand All @@ -66,10 +103,9 @@ governing permissions and limitations under the License.
z-index: auto;

min-block-size: var(--spectrum-slider-height);
min-inline-size: var(--spectrum-slider-min-width);

/* These calculations prevent the track from spilling outside of the control */
inline-size: calc(100% - calc(var(--spectrum-slider-controls-margin) * 2));
inline-size: calc(100% - calc(var(--spectrum-slider-controls-margin)));
Copy link
Member

@LFDanLu LFDanLu Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the default width is being specified on the wrapping div now, I think you can revert this change here and remove the margin-inline-end that you added below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

danni/devon removed it

margin-inline-start: var(--spectrum-slider-controls-margin);
min-block-size: var(--spectrum-slider-height);

Expand Down Expand Up @@ -304,7 +340,6 @@ governing permissions and limitations under the License.

inline-size: auto;

padding-block-start: var(--spectrum-fieldlabel-padding-top);

font-size: var(--spectrum-text-size-text-label);
line-height: var(--spectrum-line-height-text-label);
Expand Down
2 changes: 0 additions & 2 deletions packages/@react-spectrum/slider/src/RangeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function RangeSlider(props: SpectrumRangeSliderProps, ref: FocusableRef<HTMLDivE
<SliderBase {...baseProps} classes={'spectrum-Slider--range'} ref={ref}>
{({trackRef, inputRef, state}: SliderBaseChildArguments) => {
let cssDirection = direction === 'rtl' ? 'right' : 'left';

return (
<>
<div
Expand Down Expand Up @@ -72,7 +71,6 @@ function RangeSlider(props: SpectrumRangeSliderProps, ref: FocusableRef<HTMLDivE
<div
className={classNames(styles, 'spectrum-Slider-track')}
style={{
[cssDirection]: `${state.getThumbPercent(1) * 100}%`,
width: `${(1 - state.getThumbPercent(1)) * 100}%`
}} />
</>
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/slider/src/SliderBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ function SliderBase(props: SliderBaseProps, ref: FocusableRef<HTMLDivElement>) {
className={classNames(styles,
'spectrum-Slider',
{
'spectrum-Slider--label-side': labelPosition === 'side',
'spectrum-Slider--positionTop': labelPosition === 'top',
'spectrum-Slider--positionSide': labelPosition === 'side',
'is-disabled': isDisabled
},
classes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ storiesOf('Slider/RangeSlider', module)
)
.add(
'label overflow',
() => render({label: 'This is a rather long label for this narrow slider element.', maxValue: 1000, width: '100px'})
() => render({label: 'This is a rather long label for this narrow slider element.', maxValue: 1000, width: '300px'})
)
.add(
'showValueLabel: false',
Expand Down
16 changes: 14 additions & 2 deletions packages/@react-spectrum/slider/stories/Slider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ storiesOf('Slider', module)
)
.add(
'custom width',
() => render({label: 'Label', width: '200px'})
() => render({label: 'Label', width: '300px'})
)
.add(
'custom width small',
() => render({label: 'Label', width: '30px'})
)
.add(
'label overflow',
() => render({label: 'This is a rather long label for this narrow slider element.', maxValue: 1000, width: '100px'})
() => render({label: 'This is a rather long label for this narrow slider element.', maxValue: 1000, width: '300px'})
)
.add(
'showValueLabel: false',
Expand All @@ -75,6 +79,14 @@ storiesOf('Slider', module)
'labelPosition: side',
() => render({label: 'Label', labelPosition: 'side'})
)
.add(
'labelPosition: side, customWidth',
() => render({label: 'Label', labelPosition: 'side', width: '400px'})
)
.add(
'labelPosition: side, customWidth small',
() => render({label: 'Label', labelPosition: 'side', width: '30px'})
)
.add(
'min/max',
() => render({label: 'Label', minValue: 30, maxValue: 70})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,17 @@ storiesOf('TextField', module)
.add('custom width',
() => render({icon: <Info />, validationState: 'invalid', width: '300px'})
)
.add('custom width small',
() => render({icon: <Info />, validationState: 'invalid', width: '30px'})
)
.add('custom width, quiet',
() => render({icon: <Info />, validationState: 'invalid', width: '300px', isQuiet: true})
)
.add('custom width, labelPosition: side',
() => render({icon: <Info />, validationState: 'invalid', width: '500px', labelPosition: 'side'})
)
.add('custom width small, labelPosition: side',
() => render({icon: <Info />, validationState: 'invalid', width: '30px', labelPosition: 'side'})
);

function render(props = {}) {
Expand Down