Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/lib/holocene/select/select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'data-testid'?: string;
menuButtonClass?: ClassNameValue;
menuClass?: ClassNameValue;
variant?: ButtonStyles['variant'];
variant?: Extract<ButtonStyles['variant'], 'primary' | 'secondary'>;
required?: boolean;
valid?: boolean;
error?: string;
Expand Down Expand Up @@ -125,6 +125,8 @@

const errorId = $derived(`${id}-error`);
const showError = $derived(!!error && !valid);
const isPrimary = $derived(variant === 'primary');
const showPlaceholder = $derived(!value && placeholder !== '');
</script>

<MenuContainer class="w-full" {open}>
Expand All @@ -133,7 +135,9 @@
{#key $labelCtx}
<MenuButton
class={merge(
'w-full border-secondary bg-background-primary text-primary focus-visible:border-secondary focus-visible:bg-background-primary focus-visible:ring-interactive-primary enabled:hover:border-tertiary enabled:hover:bg-interactive-tertiary-hover disabled:bg-surface-tertiary disabled:opacity-disabled',
'w-full',
!isPrimary &&
'border-secondary bg-background-primary text-primary focus-visible:bg-background-primary enabled:hover:border-tertiary enabled:hover:bg-interactive-tertiary-hover disabled:bg-surface-tertiary',
!valid &&
'border-danger focus-visible:border-danger focus-visible:ring-danger',
menuButtonClass,
Expand All @@ -158,11 +162,12 @@
{/snippet}
<input
{id}
value={!value && placeholder !== '' ? placeholder : $labelCtx}
value={showPlaceholder ? placeholder : $labelCtx}
tabindex="-1"
disabled
class={merge(
!value && placeholder !== '' ? 'text-secondary' : 'text-primary',
isPrimary ? 'text-white' : 'text-primary',
showPlaceholder && (isPrimary ? 'opacity-90' : 'text-secondary'),
)}
class:disabled
{required}
Expand Down
Loading