add select

This commit is contained in:
Jesse Winton
2025-04-07 13:01:32 -04:00
parent e272fffcdf
commit cb09712daf
2 changed files with 52 additions and 15 deletions

View File

@@ -215,8 +215,43 @@
max-width: 75rem;
}
@layer components {
.mask {
@utility border-gradient {
--border-gradient-before: linear-gradient(
180deg,
rgba(255, 255, 255, 0.16) 0%,
rgba(255, 255, 255, 0) 100%
);
--border-gradient-after: linear-gradient(
180deg,
rgba(255, 255, 255, 0.12) 0%,
rgba(255, 255, 255, 0) 125.11%
);
--border-radius: 0.5rem;
&::before,
&::after {
content: '';
position: absolute;
inset: 0;
border-radius: var(--border-radius);
border: 1px solid transparent;
mask:
linear-gradient(#fff 0 0) padding-box,
linear-gradient(#fff 0 0);
mask-composite: exclude;
pointer-events: none;
}
&::before {
background: var(--border-gradient-before) border-box;
}
&::after {
background: var(--border-gradient-after) border-box;
}
}
@utility mask {
mask-image: linear-gradient(
to var(--mask-direction, top),
transparent,
@@ -224,7 +259,6 @@
black calc(100% - var(--mask-height, 32px)),
black
);
}
}
:root,

View File

@@ -1,7 +1,5 @@
<script lang="ts">
import { classNames } from '$lib/utils/classnames';
import { Select, type SelectProps } from 'melt/builders';
import type { HTMLButtonAttributes, SvelteHTMLElements } from 'svelte/elements';
type Props = {
options: Array<{
@@ -16,25 +14,30 @@
const {
options,
value = $bindable(),
onValueChange,
defaultValue = 'Select a value',
...rest
}: Props = $props();
type Option = (typeof options)[number];
const select = new Select<Option['value']>({
const select = new Select<Props['options'][number]['value']>({
value,
sameWidth: true,
forceVisible: false,
...rest
});
</script>
<button
class="web-select is-colored text-primary relative flex h-8 min-w-[145px] cursor-pointer items-center text-sm leading-[1] select-none [all:unset]"
class="border-gradient text-primary relative flex h-8 min-w-[145px] cursor-pointer items-center text-sm leading-[1] select-none"
{...select.trigger}
>
{select.value ?? defaultValue}
</button>
<div {...select.content}>
<div
class="text-primary relative box-border flex max-w-xs flex-col gap-2 overflow-y-auto rounded-xl p-1 text-sm leading-[1.2] select-none"
{...select.content}
>
{#each options as option}
<div {...select.getOption(option.value)}>
{option.label}