From dbd11ca9101751e1a6e242d0e8be617df2ee0d04 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 9 Oct 2024 14:23:09 +0200 Subject: [PATCH 01/12] First combobox setup --- v2/pink-sb/src/lib/combobox/Combobox.svelte | 127 ++++++++++++++++++ v2/pink-sb/src/lib/combobox/_combobox.scss | 102 ++++++++++++++ v2/pink-sb/src/lib/combobox/index.ts | 8 ++ .../stories/combobox/Combobox.stories.svelte | 88 ++++++++++++ 4 files changed, 325 insertions(+) create mode 100644 v2/pink-sb/src/lib/combobox/Combobox.svelte create mode 100644 v2/pink-sb/src/lib/combobox/_combobox.scss create mode 100644 v2/pink-sb/src/lib/combobox/index.ts create mode 100644 v2/pink-sb/src/stories/combobox/Combobox.stories.svelte diff --git a/v2/pink-sb/src/lib/combobox/Combobox.svelte b/v2/pink-sb/src/lib/combobox/Combobox.svelte new file mode 100644 index 000000000..3fd76320e --- /dev/null +++ b/v2/pink-sb/src/lib/combobox/Combobox.svelte @@ -0,0 +1,127 @@ + + +
+ +
+
    + {#each filteredOptions as option, index} +
  • { + currentActiveIndex = index; + }} + > + +
  • + {/each} +
+
+
+ + diff --git a/v2/pink-sb/src/lib/combobox/_combobox.scss b/v2/pink-sb/src/lib/combobox/_combobox.scss new file mode 100644 index 000000000..8da5e8543 --- /dev/null +++ b/v2/pink-sb/src/lib/combobox/_combobox.scss @@ -0,0 +1,102 @@ +@mixin base { + label { + display: flex; + flex-direction: column; + gap: 6px; + } + + .combobox-container { + position: relative; + } + + .combobox-input { + display: flex; + padding: var(--space-3, 6px) var(--space-4, 8px) var(--space-3, 6px) var(--space-6, 12px); + align-items: center; + gap: var(--space-7, 16px); + align-self: stretch; + border-radius: 8px; + border: var(--border-width-S, 1px) solid var(--color-border-neutral, #e4e4e7); + background: var(--color-bgColor-neutral-default, #fafafb); + box-sizing: border-box; + + input { + flex-grow: 1; + &::placeholder { + color: var(--color-fgColor-neutral-tertiary, #97979b); + } + } + + &:hover { + border: var(--border-width-S, 1px) solid var(--color-border-focus, #818186); + } + + &:focus-within { + box-shadow: 0 0 0 1px var(--color-border-focus, #818186); + border-color: var(--color-border-focus, #818186); + + svg { + transform: rotate(180deg); + } + } + + &.disabled { + border: var(--border-width-S, 1px) solid var(--color-border-neutral-strong, #d8d8db); + background: var(--color-bgColor-neutral-tertiary, #ededf0); + } + + svg { + transform: rotate(0deg); + transition: transform 0.2s; + fill: var(--color-fgColor-neutral-secondary, #56565c); + } + } + + .combobox-menu { + display: flex; + position: absolute; + width: 100%; + padding: var(--gap-XXS, 4px); + flex-direction: column; + align-items: flex-start; + gap: var(--gap-XXXS, 2px); + border-radius: var(--border-radius-M, 12px); + border: var(--border-width-S, 1px) solid var(--color-border-neutral, #e4e4e7); + background: var(--color-bgColor-neutral-primary, #fff); + margin-top: 8px; + + /* box-shadow/neutral/S */ + box-shadow: + 0 1px 3px 0 rgba(0, 0, 0, 0.03), + 0 4px 4px 0 rgba(0, 0, 0, 0.04); + + ul, + button { + width: 100%; + } + + button { + cursor: pointer; + height: 100%; + padding-top: var(--space-3, 6px); + padding-bottom: var(--space-3, 6px); + } + + .option { + display: flex; + padding: 0 var(--space-4, 8px) 0 var(--space-5, 10px); + align-items: center; + gap: var(--gap-S, 8px); + align-self: stretch; + + &.active { + border-radius: var(--border-radius-S, 8px); + background: var(--color-overlay-neutral-hover, rgba(25, 25, 28, 0.03)); + } + } + } + + .hidden { + display: none; + } +} diff --git a/v2/pink-sb/src/lib/combobox/index.ts b/v2/pink-sb/src/lib/combobox/index.ts new file mode 100644 index 000000000..f57f35d35 --- /dev/null +++ b/v2/pink-sb/src/lib/combobox/index.ts @@ -0,0 +1,8 @@ +import type { HTMLInputAttributes } from 'svelte/elements'; + +export type ComboboxOption = { key: string; value: string }; +export type ComboboxProps = HTMLInputAttributes & { + options: Array; +}; + +export { default as Combobox } from './Combobox.svelte'; diff --git a/v2/pink-sb/src/stories/combobox/Combobox.stories.svelte b/v2/pink-sb/src/stories/combobox/Combobox.stories.svelte new file mode 100644 index 000000000..fb1ed6f66 --- /dev/null +++ b/v2/pink-sb/src/stories/combobox/Combobox.stories.svelte @@ -0,0 +1,88 @@ + + + + + + + From 2e954ce7b7c39e7515eda6bba7a07d9c502348b4 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 9 Oct 2024 14:24:18 +0200 Subject: [PATCH 02/12] Add label prop --- v2/pink-sb/src/lib/combobox/Combobox.svelte | 3 ++- v2/pink-sb/src/lib/combobox/index.ts | 1 + v2/pink-sb/src/stories/combobox/Combobox.stories.svelte | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/v2/pink-sb/src/lib/combobox/Combobox.svelte b/v2/pink-sb/src/lib/combobox/Combobox.svelte index 3fd76320e..e617954bc 100644 --- a/v2/pink-sb/src/lib/combobox/Combobox.svelte +++ b/v2/pink-sb/src/lib/combobox/Combobox.svelte @@ -4,6 +4,7 @@ export let placeholder: ComboboxProps['placeholder'] = ''; export let disabled: ComboboxProps['disabled'] = false; export let options: ComboboxProps['options'] = []; + export let label: ComboboxProps['label'] = ''; $: hasFocus = false; let currentActiveIndex: number | null = null; @@ -58,7 +59,7 @@ aria-controls="comboboxoptions" >