Skip to content
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

feat: adjust slider's sliding range #32350

Merged
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
marchbox marked this conversation as resolved.
Show resolved Hide resolved
"type": "prerelease",
"comment": "feat: adjust slider sliding range",
"packageName": "@fluentui/web-components",
"email": "machi@microsoft.com",
"dependentChangeType": "patch"
}
68 changes: 45 additions & 23 deletions packages/web-components/src/slider/slider.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export const styles = css`
--track-margin-inline: calc(var(--thumb-size) / 2);
--track-size: 4px;
--track-overhang: calc(var(--track-size) / -2);
--rail-color: ${colorCompoundBrandBackground};
--track-color: ${colorNeutralStrokeAccessible};
--slider-direction: 90deg;
--border-radius: ${borderRadiusMedium};
--step-marker-inset: var(--track-overhang) -1px;

position: relative;
align-items: center;
justify-content: center;
Expand All @@ -44,6 +47,18 @@ export const styles = css`
grid-template-columns: var(--track-margin-inline) 1fr var(--track-margin-inline);
}

:host(:hover) {
--rail-color: ${colorCompoundBrandBackgroundHover};
}

:host(:active) {
--rail-color: ${colorCompoundBrandBackgroundPressed};
}

:host(:disabled) {
--rail-color: ${colorNeutralForegroundDisabled};
}

:host(:not(:disabled)) {
cursor: pointer;
}
Expand Down Expand Up @@ -75,22 +90,44 @@ export const styles = css`
outline: 1px solid ${colorStrokeFocus1};
}

:host:after,
.track {
position: relative;
background-color: ${colorNeutralStrokeAccessible};
height: var(--track-size);
width: 100%;
}

:host:after {
background-image: linear-gradient(
var(--slider-direction),
var(--rail-color) 0%,
var(--rail-color) 50%,
var(--track-color) 50.1%,
var(--track-color) 100%
);
border-radius: var(--border-radius);
content: '';
grid-row: 1 / -1;
grid-column: 1 / -1;
}

.track {
position: relative;
background-color: var(--track-color);
grid-row: 2 / 2;
grid-column: 2 / 2;
width: 100%;
height: var(--track-size);
forced-color-adjust: none;
overflow: hidden;
}

:host(${verticalState})::after,
:host(${verticalState}) .track {
height: 100%;
width: var(--track-size);
}

:host(${verticalState}) .track {
top: var(--track-overhang);
bottom: var(--track-overhang);
width: var(--track-size);
height: 100%;
}

.track::before {
Expand Down Expand Up @@ -151,26 +188,11 @@ export const styles = css`

.thumb,
.track::before {
background-color: ${colorCompoundBrandBackground};
}

:host(:hover) .thumb,
:host(:hover) .track::before {
background-color: ${colorCompoundBrandBackgroundHover};
}

:host(:active) .thumb,
:host(:active) .track::before {
background-color: ${colorCompoundBrandBackgroundPressed};
background-color: var(--rail-color);
}

:host(:disabled) .track {
background-color: ${colorNeutralBackgroundDisabled};
}

:host(:disabled) .thumb,
:host(:disabled) .track::before {
background-color: ${colorNeutralForegroundDisabled};
background-color: var(--track-color);
}
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
Expand Down
Loading