mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-07 12:57:49 +00:00
add select
This commit is contained in:
52
src/app.css
52
src/app.css
@@ -215,16 +215,50 @@
|
|||||||
max-width: 75rem;
|
max-width: 75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer components {
|
@utility border-gradient {
|
||||||
.mask {
|
--border-gradient-before: linear-gradient(
|
||||||
mask-image: linear-gradient(
|
180deg,
|
||||||
to var(--mask-direction, top),
|
rgba(255, 255, 255, 0.16) 0%,
|
||||||
transparent,
|
rgba(255, 255, 255, 0) 100%
|
||||||
black var(--mask-height, 32px),
|
);
|
||||||
black calc(100% - var(--mask-height, 32px)),
|
--border-gradient-after: linear-gradient(
|
||||||
black
|
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,
|
||||||
|
black var(--mask-height, 32px),
|
||||||
|
black calc(100% - var(--mask-height, 32px)),
|
||||||
|
black
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
:root,
|
:root,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { classNames } from '$lib/utils/classnames';
|
|
||||||
import { Select, type SelectProps } from 'melt/builders';
|
import { Select, type SelectProps } from 'melt/builders';
|
||||||
import type { HTMLButtonAttributes, SvelteHTMLElements } from 'svelte/elements';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
options: Array<{
|
options: Array<{
|
||||||
@@ -16,25 +14,30 @@
|
|||||||
const {
|
const {
|
||||||
options,
|
options,
|
||||||
value = $bindable(),
|
value = $bindable(),
|
||||||
|
onValueChange,
|
||||||
defaultValue = 'Select a value',
|
defaultValue = 'Select a value',
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
type Option = (typeof options)[number];
|
|
||||||
|
|
||||||
const select = new Select<Option['value']>({
|
const select = new Select<Props['options'][number]['value']>({
|
||||||
value,
|
value,
|
||||||
|
sameWidth: true,
|
||||||
|
forceVisible: false,
|
||||||
...rest
|
...rest
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<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.trigger}
|
||||||
>
|
>
|
||||||
{select.value ?? defaultValue}
|
{select.value ?? defaultValue}
|
||||||
</button>
|
</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}
|
{#each options as option}
|
||||||
<div {...select.getOption(option.value)}>
|
<div {...select.getOption(option.value)}>
|
||||||
{option.label}
|
{option.label}
|
||||||
|
|||||||
Reference in New Issue
Block a user