-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
87 additions
and
99 deletions.
There are no files selected for viewing
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
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,32 @@ | ||
export default class WebUIRangeInput extends HTMLElement { | ||
private rangeInput: HTMLInputElement | null; | ||
private rangeOutput: HTMLOutputElement | null; | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.rangeInput = this.querySelector('[type="range"]'); | ||
this.rangeOutput = this.querySelector('output'); | ||
|
||
if (!this.rangeInput || !this.rangeOutput) return; | ||
|
||
this.rangeOutput.innerHTML = this.rangeInput.value; | ||
this.rangeInput.addEventListener('input', this); | ||
} | ||
|
||
private handleValidRanges( | ||
range: HTMLInputElement, | ||
bubble: HTMLOutputElement, | ||
): void { | ||
range.setAttribute('value', range.value); | ||
range.setAttribute('aria-valuenow', range.value); | ||
bubble.innerHTML = range.value; | ||
} | ||
|
||
// Handle constructor() event listeners. | ||
handleEvent() { | ||
this.rangeInput && | ||
this.rangeOutput && | ||
this.handleValidRanges(this.rangeInput, this.rangeOutput); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,5 @@ | |
@use 'input'; | ||
@use 'label'; | ||
@use 'radio'; | ||
@use 'range'; | ||
@use 'select'; | ||
@use 'textarea'; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
ui/stories/4. Forms/RangeInputSlider/RangeInputSlider.stories.js
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
ui/stories/6. Web Components Or Custom Elements/WebUI Range Input/WebUIRangeInput.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,21 @@ | ||
export const WebUIRangeInputHtml = () => ` | ||
<webui-range-input> | ||
<div class="form__field"> | ||
<label for="range-input" class="label"> | ||
Range slider | ||
</label> | ||
<input | ||
class="input" | ||
type="range" | ||
id="range-input" | ||
value="1" | ||
min="1" | ||
max="10" | ||
aria-valuenow="1" | ||
aria-valuemin="1" | ||
aria-valuemax="10" | ||
/> | ||
<output></output> | ||
</div> | ||
</webui-range-input> | ||
`; |
12 changes: 12 additions & 0 deletions
12
...ries/6. Web Components Or Custom Elements/WebUI Range Input/WebUIRangeInput.mdx
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,12 @@ | ||
import { Meta, Canvas } from '@storybook/blocks'; | ||
import * as WebUIRangeInput from './WebUIRangeInput.stories'; | ||
|
||
<Meta of={WebUIRangeInput} /> | ||
|
||
# `<webui-range-input>` | ||
- JavaScript is required to display the numeric range value inside the `<output>` element. | ||
|
||
## Accessibility considerations | ||
- See the [ARIA APG slider pattern](https://www.w3.org/WAI/ARIA/apg/patterns/slider/). | ||
|
||
<Canvas of={WebUIRangeInput.WebUIRangeInput} /> |
15 changes: 15 additions & 0 deletions
15
ui/stories/6. Web Components Or Custom Elements/WebUI Range Input/WebUIRangeInput.stories.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,15 @@ | ||
import { WebUIRangeInputHtml } from './WebUIRangeInput'; | ||
|
||
export default { | ||
title: 'Web Components Or Custom Elements/<webui-range-input>', | ||
parameters: { | ||
status: { | ||
type: 'stable', | ||
}, | ||
}, | ||
}; | ||
|
||
export const WebUIRangeInput = { | ||
render: (args) => WebUIRangeInputHtml(args), | ||
}; | ||
WebUIRangeInput.storyName = '<webui-range-input>'; |