-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from dev-rb/docs/slider
docs: add slider
- Loading branch information
Showing
4 changed files
with
1,085 additions
and
0 deletions.
There are no files selected for viewing
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,73 @@ | ||
.SliderRoot { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
user-select: none; | ||
touch-action: none; | ||
width: 200px; | ||
} | ||
|
||
.SliderRoot[data-orientation="vertical"] { | ||
height: 200px; | ||
} | ||
|
||
.SliderTrack { | ||
background-color: rgba(0, 0, 0, 0.5); | ||
position: relative; | ||
border-radius: 9999px; | ||
height: 8px; | ||
width: 100%; | ||
} | ||
|
||
.SliderTrack[data-orientation="vertical"] { | ||
width: 8px; | ||
height: 100%; | ||
} | ||
.SliderRange { | ||
position: absolute; | ||
background-color: white; | ||
border-radius: 9999px; | ||
height: 100%; | ||
} | ||
|
||
.SliderRange[data-orientation="vertical"] { | ||
width: 100%; | ||
height: unset; | ||
} | ||
.SliderThumb { | ||
display: block; | ||
width: 16px; | ||
height: 16px; | ||
background-color: #0090ff; | ||
border-radius: 9999px; | ||
top: -4px; | ||
} | ||
.SliderThumb[data-orientation="vertical"] { | ||
left: -4px; | ||
top: unset; | ||
} | ||
.SliderThumb:hover { | ||
box-shadow: 0 0 0 5px #2a91fe98; | ||
} | ||
.SliderThumb:focus { | ||
outline: none; | ||
box-shadow: 0 0 0 5px #2a91fe98; | ||
} | ||
.SliderLabel { | ||
width: 100%; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.SecondThumb { | ||
background-color: #30a46c; | ||
} | ||
|
||
.SecondThumb:hover { | ||
box-shadow: 0 0 0 5px #50fdac5e; | ||
} | ||
|
||
.SecondThumb:focus { | ||
box-shadow: 0 0 0 5px #50fdac5e; | ||
} |
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,164 @@ | ||
import { Slider } from "@kobalte/core"; | ||
import { createSignal } from "solid-js"; | ||
import style from "./slider.module.css"; | ||
|
||
export function BasicExample() { | ||
return ( | ||
<Slider.Root class={style["SliderRoot"]}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Label</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} | ||
|
||
export function MultipleThumbsExample() { | ||
return ( | ||
<Slider.Root class={style["SliderRoot"]} defaultValue={[0, 20]}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Label</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
<Slider.Thumb class={`${style["SliderThumb"]} ${style["SecondThumb"]}`}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} | ||
|
||
export function StepExample() { | ||
return ( | ||
<> | ||
<Slider.Root class={style["SliderRoot"]} step={8}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Step size 8</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
<Slider.Root class={style["SliderRoot"]} step={10}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Step size 10</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
<Slider.Root class={style["SliderRoot"]} step={20}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Step size 20</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
</> | ||
); | ||
} | ||
|
||
export function MinStepsBetweenExample() { | ||
return ( | ||
<Slider.Root class={style["SliderRoot"]} defaultValue={[10, 20]} minStepsBetweenThumbs={10}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Label</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
<Slider.Thumb class={`${style["SliderThumb"]} ${style["SecondThumb"]}`}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} | ||
|
||
export function VerticalSliderExample() { | ||
return ( | ||
<Slider.Root class={style["SliderRoot"]} orientation="vertical"> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Label</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} | ||
|
||
export function CustomValueLabelExample() { | ||
return ( | ||
<Slider.Root | ||
class={style["SliderRoot"]} | ||
minValue={10} | ||
maxValue={2000} | ||
defaultValue={[20, 500]} | ||
getValueLabel={params => `$${params.values[0]} - $${params.values[1]}`} | ||
> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Money</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
<Slider.Thumb class={`${style["SliderThumb"]} ${style["SecondThumb"]}`}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} | ||
|
||
export function ControlledExample() { | ||
const [values, setValues] = createSignal<number[]>([40]); | ||
return ( | ||
<Slider.Root class={style["SliderRoot"]} value={values()} onChange={setValues}> | ||
<div class={style["SliderLabel"]}> | ||
<Slider.Label>Label</Slider.Label> | ||
<Slider.ValueLabel /> | ||
</div> | ||
<Slider.Track class={style["SliderTrack"]}> | ||
<Slider.Fill class={style["SliderRange"]} /> | ||
<Slider.Thumb class={style["SliderThumb"]}> | ||
<Slider.Input /> | ||
</Slider.Thumb> | ||
</Slider.Track> | ||
</Slider.Root> | ||
); | ||
} |
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
Oops, something went wrong.