diff --git a/src/components/Select/_select.scss b/src/components/Select/_select.scss new file mode 100644 index 0000000..07739f5 --- /dev/null +++ b/src/components/Select/_select.scss @@ -0,0 +1,71 @@ +@use '../../styles/tokens/typography' as *; + +.select { + position: relative; + display: inline-flex; + flex-direction: column; + width: 100%; + + &__trigger { + display: flex; + align-items: center; + justify-content: space-between; + padding: var(--nds-spacing-xs) var(--nds-spacing-md); + background-color: var(--nds-neutral); + color: var(--nds-text); + border: none; + border-radius: var(--nds-radius-sm); + cursor: pointer; + width: 100%; + gap: var(--nds-spacing-xs); + + &:hover { + background-color: color-mix(in srgb, var(--nds-neutral) 85%, var(--nds-text)); + } + } + + &__label { + flex: 1; + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + &__arrow { + flex-shrink: 0; + display: flex; + align-items: center; + + &--hidden { + display: none; + } + } + + &__dropdown { + position: absolute; + top: calc(100% + var(--nds-spacing-2xs)); + left: 0; + right: 0; + background-color: var(--nds-neutral); + border-radius: var(--nds-radius-sm); + list-style: none; + margin: 0; + padding: 0; + z-index: 100; + overflow: hidden; + + &[hidden] { + display: none; + } + } + + &--disabled { + opacity: 0.5; + + .select__trigger { + background-color: var(--nds-disabled); + cursor: not-allowed; + } +} +} \ No newline at end of file diff --git a/src/components/Select/_selectOption.scss b/src/components/Select/_selectOption.scss new file mode 100644 index 0000000..234498e --- /dev/null +++ b/src/components/Select/_selectOption.scss @@ -0,0 +1,32 @@ +@use '../../styles/tokens/typography' as *; + +.select-option { + padding: var(--nds-spacing-xs) var(--nds-spacing-md); + cursor: pointer; + color: var(--nds-text); + background-color: var(--nds-neutral); + transition: background-color 0.15s ease; + + &:hover:not(.select-option__disabled) { + background-color: var(--nds-secondary); + } + + &:active { + background-color: var(--nds-accent); + } + + &__selected { + background-color: var(--nds-primary); + color: var(--nds-text); + + &:hover { + background-color: color-mix(in srgb, var(--nds-primary) 85%, var(--nds-background)); + } + } + + &__disabled { + background-color: var(--nds-disabled); + color: color-mix(in srgb, var(--nds-text) 40%, transparent); + cursor: not-allowed; + } +} \ No newline at end of file diff --git a/src/components/Select/select.astro b/src/components/Select/select.astro new file mode 100644 index 0000000..6f6934d --- /dev/null +++ b/src/components/Select/select.astro @@ -0,0 +1,136 @@ +--- +import Arrow2 from '../Icons/Arrow2/Arrow2.astro'; + +export interface Props { + default?: string; + disabled?: boolean; + value?: string; +} +const { default: defaultValue, disabled = false, value } = Astro.props; +--- + + + + + + + + + + \ No newline at end of file diff --git a/src/components/Select/selectOption.astro b/src/components/Select/selectOption.astro new file mode 100644 index 0000000..b642fb9 --- /dev/null +++ b/src/components/Select/selectOption.astro @@ -0,0 +1,32 @@ +--- +export interface Props { + value: string; + disabled?: boolean; +} +const { value, disabled = false } = Astro.props; +--- + +
  • + +
  • + + + + \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index 32b6eaa..7a132e7 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -13,4 +13,6 @@ export { default as ListItemTitle } from './ListItem/listItemTitle.astro'; export { default as ListItemSubtitle } from './ListItem/listItemSubtitle.astro'; export { default as LoadingBar } from './LoadingBar/loadingBar.astro'; export { default as NumericStepper } from './numericStepper/numericStepper.astro'; -export { default as Avatar } from './Avatar/avatar.astro'; \ No newline at end of file +export { default as Avatar } from './Avatar/avatar.astro'; +export { default as Select } from './Select/select.astro'; +export { default as SelectOption } from './Select/selectOption.astro'; \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index c186703..f94cb00 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -20,6 +20,8 @@ import { SearchIcon, SettingsIcon, ShareIcon, ShieldIcon, SortIcon, StatsIcon, UploadIcon, } from '../components/Icons/index.ts'; +import Select from '../components/Select/select.astro'; +import SelectOption from '../components/Select/selectOption.astro'; const initialChecked = true; --- @@ -27,6 +29,25 @@ const initialChecked = true;

    Nova Design System

    +
    +

    Select

    +
    + + +
    +

    Avatar