Skip to content

Commit

Permalink
Merge pull request #280 from kobaltedev/develop
Browse files Browse the repository at this point in the history
changeset: v0.11.2
  • Loading branch information
fabien-ml authored Oct 21, 2023
2 parents 6aaa33f + 677f256 commit ba4fc60
Show file tree
Hide file tree
Showing 11 changed files with 1,094 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-timers-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kobalte/core": patch
---

added `Slider` component
2 changes: 1 addition & 1 deletion apps/docs/src/VERSIONS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const CORE_VERSIONS = [

export const LATEST_CORE_CHANGELOG_URL = `/docs/changelog/${CORE_VERSIONS[0].replaceAll(".", "-")}`;

export const LATEST_CORE_VERSION_NAME = "v0.11.1";
export const LATEST_CORE_VERSION_NAME = "v0.11.2";
71 changes: 71 additions & 0 deletions apps/docs/src/examples/slider.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.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: hsl(240 6% 90%);
position: relative;
border-radius: 9999px;
height: 8px;
width: 100%;
}

.SliderTrack[data-orientation="vertical"] {
width: 8px;
height: 100%;
}

.SliderRange {
position: absolute;
background-color: hsl(200 98% 39%);
border-radius: 9999px;
height: 100%;
}

.SliderRange[data-orientation="vertical"] {
width: 100%;
height: unset;
}

.SliderThumb {
display: block;
width: 16px;
height: 16px;
background-color: hsl(200 98% 39%);
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;
}

[data-kb-theme="dark"] .SliderTrack {
background-color: hsl(240 5% 26%);
}
164 changes: 164 additions & 0 deletions apps/docs/src/examples/slider.tsx
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["SliderThumb"]}`}>
<Slider.Input />
</Slider.Thumb>
</Slider.Track>
</Slider.Root>
);
}

export function StepExample() {
return (
<div class="flex flex-col space-y-4">
<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>
</div>
);
}

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["SliderThumb"]}`}>
<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["SliderThumb"]}`}>
<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>
);
}
10 changes: 10 additions & 0 deletions apps/docs/src/routes/docs/changelog/0-11-x.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# v0.11.x

## v0.11.2 (October 21, 2023)

**New features**

- Added `Slider` component.

**Bug fixes**

- [#278](https://github.com/kobaltedev/kobalte/pull/278)

## v0.11.1 (October 20, 2023)

**New features**
Expand Down
6 changes: 5 additions & 1 deletion apps/docs/src/routes/docs/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const CORE_NAV_SECTIONS: NavSection[] = [
{
title: "Combobox",
href: "/docs/core/components/combobox",
status: "updated",
},
{
title: "Context Menu",
Expand Down Expand Up @@ -122,6 +121,11 @@ const CORE_NAV_SECTIONS: NavSection[] = [
href: "/docs/core/components/skeleton",
status: "new",
},
{
title: "Slider",
href: "/docs/core/components/slider",
status: "new",
},
{
title: "Switch",
href: "/docs/core/components/switch",
Expand Down
Loading

0 comments on commit ba4fc60

Please sign in to comment.