Skip to content

Commit

Permalink
feat: introduce new select field based on shadcn implementation with …
Browse files Browse the repository at this point in the history
…custom interfaces (#134)

* wip: add select field story from shadcn

* refactor: extract select field story values to separate file to hide in UI

* feat: implement custom select component based on shadcn implementation
  • Loading branch information
sjschlapbach authored Oct 5, 2024
1 parent effdd6c commit 808b052
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 291 deletions.
2 changes: 1 addition & 1 deletion packages/design-system/.ladle/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.3rem;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
Expand Down
79 changes: 2 additions & 77 deletions packages/design-system/src/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,6 @@
import { useState } from 'react'
import Select from './Select'

export const fruitsValues = [
{ value: 'apple', label: 'Apple' },
{ value: 'banana', label: 'Banana' },
{ value: 'pear', label: 'Pear' },
{ value: 'watermelon', label: 'Watermelon' },
{ value: 'peach', label: 'Peach' },
{ value: 'mango', label: 'Mango' },
]
export const vegetablesValues = [
{ value: 'carrot', label: 'Carrot' },
{ value: 'cucumber', label: 'Cucumber' },
{ value: 'onion', label: 'Onion' },
{ value: 'potato', label: 'Potato' },
{ value: 'tomato', label: 'Tomato' },
{ value: 'broccoli', label: 'Broccoli' },
]
export const transportValues = [
{ value: 'car', label: 'Car' },
{ value: 'bike', label: 'Bike' },
{ value: 'train', label: 'Train' },
{ value: 'plane', label: 'Plane' },
{ value: 'boat', label: 'Boat' },
{ value: 'bus', label: 'Bus' },
]
export const programmingValues = [
{ value: 'javascript', label: 'JavaScript' },
{ value: 'typescript', label: 'TypeScript' },
{ value: 'python', label: 'Python' },
{ value: 'ruby', label: 'Ruby' },
{ value: 'java', label: 'Java' },
{ value: 'csharp', label: 'C#' },
]

export const programmingValuesDisabled = [
{ value: 'javascript', label: 'JavaScript (disabled)', disabled: true },
{ value: 'typescript', label: 'TypeScript' },
{ value: 'python', label: 'Python (disabled)', disabled: true },
{ value: 'ruby', label: 'Ruby' },
{ value: 'java', label: 'Java (disabled)' },
{ value: 'csharp', label: 'C#' },
]

export const groupValues = [
{ items: fruitsValues },
{ items: vegetablesValues, showSeparator: true },
{ items: transportValues, showSeparator: true, label: 'Transport' },
{
items: programmingValues,
showSeparator: true,
label: 'Programming Languages',
},
]

export const groupValuesDisabled = [
{ items: fruitsValues },
{ items: vegetablesValues, showSeparator: true },
{ items: transportValues, showSeparator: true, label: 'Transport' },
{
items: programmingValuesDisabled,
showSeparator: true,
label: 'Programming Languages',
},
]
import { fruitsValues, groupValues } from './values'

export const Default = () => {
return (
Expand Down Expand Up @@ -212,9 +149,8 @@ export const Styled = () => {
className={{
root: 'h-full rounded-none border-none',
content: 'bg-green-200',
trigger: 'rounded-none border-none bg-uzh-blue-20',
trigger: 'rounded-none border-none bg-uzh-blue-20 text-lg',
item: 'text-red-700',
scrollButton: 'bg-blue-400',
groupLabel: 'text-red-700',
separator: 'bg-green-700',
}}
Expand All @@ -223,17 +159,6 @@ export const Styled = () => {
)
}

export const Small = () => {
return (
<Select
placeholder="Select an item"
groups={groupValues}
onChange={(newValue) => console.log(newValue)}
size="sm"
/>
)
}

export const CustomTriggerLabel = () => {
const items = [
{ value: 'apple', label: 'Apple long label', shortLabel: 'Apple' },
Expand Down
Loading

0 comments on commit 808b052

Please sign in to comment.