-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Slider as a web component (#27165)
* Initial commit of styles and markup for slider * Cleans up some styles and adds Stories for states * More Slider styles and stories * Adds stripes to slider for vertical/horizontal. Deletes SliderLabel as we don't need it * Fixes silly math * Cleans up CSS * Cleans up CSS and Stories for Slider * Initial commit of styles and markup for slider * More Slider styles and stories * Adds stripes to slider for vertical/horizontal. Deletes SliderLabel as we don't need it * Fixes silly math * Fixes some styles on checkmarks * Adds check to see if Step was set * Generates API report * Removes some duplicate CSS and cleans up spec * Adds slider to index.ts and package.json * Addresses initial round of feedback to PR * Renames sizeChanged to stepChanged. Duh. * Adds JSDOC comments * update slider step rate code * Adds export to SliderOrientation * Adds new focus style and fixes overflow visual bug * Fixes build errors * Adds export to SliderOrientation * Adds new focus style and fixes overflow visual bug * Fixes build errors * Runs API report --------- Co-authored-by: Chris Holt <[email protected]>
- Loading branch information
Showing
15 changed files
with
457 additions
and
79 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-web-components-a3ffbc3c-8b89-4d1c-ba56-3690c7fb06e1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Adds Slider as a web component", | ||
"packageName": "@fluentui/web-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
packages/web-components/src/slider-label/slider-label.spec.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { FluentDesignSystem } from '../fluent-design-system.js'; | ||
import { definition } from './slider.definition.js'; | ||
|
||
definition.define(FluentDesignSystem.registry); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './slider.js'; | ||
export * from './slider.options.js'; | ||
export { definition as SliderDefinition } from './slider.definition.js'; | ||
export { styles as SliderStyles } from './slider.styles.js'; | ||
export { template as SliderTemplate } from './slider.template.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FluentDesignSystem } from '../fluent-design-system.js'; | ||
import { Slider } from './slider.js'; | ||
import { styles } from './slider.styles.js'; | ||
import { template } from './slider.template.js'; | ||
|
||
/** | ||
* The Fluent Slider Element. | ||
* | ||
* | ||
* @public | ||
* @remarks | ||
* HTML Element: \<fluent-slider\> | ||
*/ | ||
export const definition = Slider.compose({ | ||
name: `${FluentDesignSystem.prefix}-slider`, | ||
template, | ||
styles, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ValuesOf } from '@microsoft/fast-foundation'; | ||
export { SliderOrientation } from '@microsoft/fast-foundation'; | ||
|
||
/** | ||
* SliderSize Constants | ||
* @public | ||
*/ | ||
export const SliderSize = { | ||
small: 'small', | ||
medium: 'medium', | ||
} as const; | ||
|
||
/** | ||
* Applies bar height to the slider rail and diameter to the slider thumbs | ||
* @public | ||
*/ | ||
export type SliderSize = ValuesOf<typeof SliderSize>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { html } from '@microsoft/fast-element'; | ||
import type { Args, Meta } from '@storybook/html'; | ||
import { renderComponent } from '../helpers.stories.js'; | ||
import { SliderSize as SliderSetSize } from './slider.options.js'; | ||
import type { Slider as FluentSlider } from './slider.js'; | ||
import './define.js'; | ||
|
||
type SliderStoryArgs = Args & FluentSlider; | ||
type SliderStoryMeta = Meta<SliderStoryArgs>; | ||
|
||
const storyTemplate = html<SliderStoryArgs>` | ||
<fluent-slider | ||
?disabled=${x => x.disabled} | ||
?readonly=${x => x.readOnly} | ||
step=${x => x.step} | ||
size=${x => x.size} | ||
min=${x => x.min} | ||
max=${x => x.max} | ||
orientation=${x => x.orientation} | ||
value=${x => x.value} | ||
></fluent-slider> | ||
`; | ||
|
||
export default { | ||
title: 'Components/Slider', | ||
args: { | ||
disabled: false, | ||
readOnly: false, | ||
min: 0, | ||
max: 100, | ||
size: SliderSetSize.medium, | ||
orientation: 'horizontal', | ||
}, | ||
argTypes: { | ||
disabled: { control: 'boolean' }, | ||
readOnly: { control: 'boolean' }, | ||
min: { | ||
control: 'number', | ||
defaultValue: 0, | ||
}, | ||
max: { | ||
control: 'number', | ||
defaultValue: 100, | ||
}, | ||
value: { control: 'number', defaultValue: 50 }, | ||
size: { | ||
control: { | ||
type: 'inline-radio', | ||
options: Object.values(SliderSetSize), | ||
}, | ||
}, | ||
orientation: { | ||
control: { | ||
type: 'inline-radio', | ||
options: ['horizontal', 'vertical'], | ||
}, | ||
}, | ||
}, | ||
} as SliderStoryMeta; | ||
|
||
export const Slider = renderComponent(storyTemplate).bind({}); | ||
|
||
export const SliderOrientation = renderComponent(html<SliderStoryArgs>` | ||
<fluent-slider orientation="vertical" step="20" value="60" min="0" max="100"></fluent-slider> | ||
<fluent-slider orientation="horizontal" step="20" value="60" min="0" max="100"></fluent-slider> | ||
`); | ||
|
||
export const SliderSize = renderComponent(html<SliderStoryArgs>` | ||
<fluent-slider size="small" value="10" min="0" max="10"></fluent-slider> | ||
<fluent-slider size="medium" value="10" min="0" max="10"></fluent-slider> | ||
`); | ||
|
||
export const SliderSteps = renderComponent(html<SliderStoryArgs>` | ||
<fluent-slider step="10" value="10" min="0" max="100"></fluent-slider> | ||
`); | ||
|
||
export const SliderDisabled = renderComponent(html<SliderStoryArgs>` | ||
<fluent-slider disabled value="10" min="0" max="100"></fluent-slider> | ||
<fluent-slider step="25" disabled value="50" min="0" max="100"></fluent-slider> | ||
`); |
Oops, something went wrong.