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

Added vertical ranges #3163

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions src/components/styled/range.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,99 @@
var(--focus-shadow, 0 0),
calc(var(--filler-size) * -1 - var(--filler-offset)) 0 0 var(--filler-size);
}

&-vertical {
writing-mode: vertical-lr;
direction: rtl;
height: 100%;
width: 1.5rem;

&:focus-visible::-webkit-slider-thumb {
--focus-shadow: 0 0 0 6px theme(colors.base-100) inset, 0 0 0 2rem var(--range-shdw) inset;
}
&:focus-visible::-moz-range-thumb {
--focus-shadow: 0 0 0 6px theme(colors.base-100) inset, 0 0 0 2rem var(--range-shdw) inset;
}
&::-webkit-slider-runnable-track {
@apply w-2 h-full;
}
&::-moz-range-track {
@apply w-2 h-full;
}
&::-webkit-slider-thumb {
top: 0%;
left: 50%;
transform: translateX(-50%);
box-shadow:
0 0 0 3px var(--range-shdw) inset,
var(--focus-shadow, 0 0),
0 calc(var(--filler-size) * 1 + var(--filler-offset)) 0 var(--filler-size);
}
&::-moz-range-thumb {
top: 0%;
left: 50%;
box-shadow:
0 0 0 3px var(--range-shdw) inset,
var(--focus-shadow, 0 0),
0 calc(var(--filler-size) * 1 + var(--filler-offset)) 0 var(--filler-size);
}
&.range-invert {
direction: ltr;
&::-webkit-slider-thumb {
box-shadow:
0 0 0 3px var(--range-shdw) inset,
var(--focus-shadow, 0 0),
0 calc(var(--filler-size) * -1 - var(--filler-offset)) 0 var(--filler-size);
}
&::-moz-range-thumb {
box-shadow:
0 0 0 3px var(--range-shdw) inset,
var(--focus-shadow, 0 0),
0 calc(var(--filler-size) * -1 - var(--filler-offset)) 0 var(--filler-size);
}
}

&.range-xs {
width: 1rem;
height: 100%;
&::-webkit-slider-runnable-track {
width: 0.25rem
}
&::-moz-range-track {
width: 0.25rem
}
}
&.range-sm {
width: 1.25rem;
height: 100%;
&::-webkit-slider-runnable-track {
width: 0.25rem
}
&::-moz-range-track {
width: 0.25rem
}
}
&.range-md {
width: 1.5rem;
height: 100%;
&::-webkit-slider-runnable-track {
width: 0.5rem
}
&::-moz-range-track {
width: 0.5rem
}
}
&.range-lg {
width: 2rem;
height: 100%;
&::-webkit-slider-runnable-track {
width: 1rem
}
&::-moz-range-track {
width: 1rem
}
}
}
&-primary {
--range-shdw: theme(colors.primary);
}
Expand Down
27 changes: 27 additions & 0 deletions src/docs/src/routes/(docs)/components/range/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,30 @@ data="{[

{/snippet}
</Component>

<Component title="Vertical and inverted">
<div class="flex h-full items-center gap-4 max-h-40">
<input type="range" min="0" max="100" value="80" class="range range-vertical range-xs max-w-xs" />
<input type="range" min="0" max="100" value="70" class="range range-vertical range-sm max-w-xs" />
<input type="range" min="0" max="100" value="60" class="range range-vertical range-md max-w-xs" />
<input type="range" min="0" max="100" value="50" class="range range-vertical range-lg max-w-xs" />
<input type="range" min="0" max="100" value="60" class="range range-vertical range-invert range-lg max-w-xs" />
<input type="range" min="0" max="100" value="70" class="range range-vertical range-invert range-md max-w-xs" />
<input type="range" min="0" max="100" value="80" class="range range-vertical range-invert range-sm max-w-xs" />
<input type="range" min="0" max="100" value="90" class="range range-vertical range-invert range-xs max-w-xs" />
</div>
{#snippet html()}

```html
<input type="range" min="0" max="100" value="80" class="range range-vertical range-xs max-w-xs" />
<input type="range" min="0" max="100" value="70" class="range range-vertical range-sm max-w-xs" />
<input type="range" min="0" max="100" value="60" class="range range-vertical range-md max-w-xs" />
<input type="range" min="0" max="100" value="50" class="range range-vertical range-lg max-w-xs" />
<input type="range" min="0" max="100" value="60" class="range range-vertical range-invert range-lg max-w-xs" />
<input type="range" min="0" max="100" value="70" class="range range-vertical range-invert range-md max-w-xs" />
<input type="range" min="0" max="100" value="80" class="range range-vertical range-invert range-sm max-w-xs" />
<input type="range" min="0" max="100" value="90" class="range range-vertical range-invert range-xs max-w-xs" />
```

{/snippet}
</Component>