From dea517fbe54d5f3294288e9874063519186d8af8 Mon Sep 17 00:00:00 2001 From: unkn0wn Date: Tue, 23 Jun 2026 10:12:04 +0200 Subject: [PATCH] feat: adding Badge, Breadcrumb, Checkbox et Radio components --- src/components/Badge/_badge.scss | 58 +++++++++++++++++++ src/components/Badge/badge.astro | 15 +++++ src/components/Breadcrumb/_breadcrumb.scss | 27 +++++++++ src/components/Breadcrumb/breadcrumb.astro | 11 ++++ .../Breadcrumb/breadcrumbItem.astro | 19 ++++++ src/components/Checkbox/_checkbox.scss | 51 ++++++++++++++++ src/components/Checkbox/checkbox.astro | 37 ++++++++++++ src/components/Radio/_radio.scss | 50 ++++++++++++++++ src/components/Radio/radio.astro | 28 +++++++++ 9 files changed, 296 insertions(+) create mode 100644 src/components/Badge/_badge.scss create mode 100644 src/components/Badge/badge.astro create mode 100644 src/components/Breadcrumb/_breadcrumb.scss create mode 100644 src/components/Breadcrumb/breadcrumb.astro create mode 100644 src/components/Breadcrumb/breadcrumbItem.astro create mode 100644 src/components/Checkbox/_checkbox.scss create mode 100644 src/components/Checkbox/checkbox.astro create mode 100644 src/components/Radio/_radio.scss create mode 100644 src/components/Radio/radio.astro diff --git a/src/components/Badge/_badge.scss b/src/components/Badge/_badge.scss new file mode 100644 index 0000000..53be9b2 --- /dev/null +++ b/src/components/Badge/_badge.scss @@ -0,0 +1,58 @@ +@use "../../styles/tokens/typography" as *; + +.badge { + display: inline-flex; + align-items: center; + gap: var(--nds-spacing-2xs); + padding: 3px var(--nds-spacing-xs); + border-radius: var(--nds-radius-full); + @include text-sm; + font-weight: 600; + line-height: 1.2; + width: fit-content; + white-space: nowrap; + &__primary { + --c: var(--nds-primary); + --on: var(--nds-on-primary); + --soft: var(--nds-primary-soft); + } + &__neutral { + --c: var(--nds-neutral); + --on: var(--nds-surface); + --soft: color-mix(in srgb, var(--nds-neutral) 16%, transparent); + } + &__success { + --c: var(--nds-success-medium); + --on: #fff; + --soft: var(--nds-success-low); + } + &__warning { + --c: var(--nds-warning-medium); + --on: #fff; + --soft: var(--nds-warning-low); + } + &__error { + --c: var(--nds-error-medium); + --on: #fff; + --soft: var(--nds-error-low); + } + &__info { + --c: var(--nds-info-medium); + --on: #fff; + --soft: var(--nds-info-low); + } + &--soft { + background-color: var(--soft); + color: var(--c); + } + &--solid { + background-color: var(--c); + color: var(--on); + } + &__dot { + width: 6px; + height: 6px; + border-radius: var(--nds-radius-full); + background-color: currentColor; + } +} diff --git a/src/components/Badge/badge.astro b/src/components/Badge/badge.astro new file mode 100644 index 0000000..44c2cb0 --- /dev/null +++ b/src/components/Badge/badge.astro @@ -0,0 +1,15 @@ +--- +export interface Props { + type?: "primary" | "neutral" | "success" | "warning" | "error" | "info"; + variant?: "soft" | "solid"; +} +const { type = "primary", variant = "soft" } = Astro.props; +--- + + + + + + diff --git a/src/components/Breadcrumb/_breadcrumb.scss b/src/components/Breadcrumb/_breadcrumb.scss new file mode 100644 index 0000000..3641f68 --- /dev/null +++ b/src/components/Breadcrumb/_breadcrumb.scss @@ -0,0 +1,27 @@ +@use "../../styles/tokens/typography" as *; + +.breadcrumb { + display: flex; + align-items: center; + gap: var(--nds-spacing-xs); + @include text-base; + + &__item { + text-decoration: none; + color: var(--nds-neutral); + transition: color 120ms ease; + &:hover { + color: var(--nds-text); + } + &:not(:first-child)::before { + content: "/"; + color: var(--nds-disabled); + margin-right: var(--nds-spacing-xs); + } + &--current { + color: var(--nds-text); + font-weight: 600; + pointer-events: none; + } + } +} diff --git a/src/components/Breadcrumb/breadcrumb.astro b/src/components/Breadcrumb/breadcrumb.astro new file mode 100644 index 0000000..a857a04 --- /dev/null +++ b/src/components/Breadcrumb/breadcrumb.astro @@ -0,0 +1,11 @@ +--- +export interface Props {} +--- + + + + diff --git a/src/components/Breadcrumb/breadcrumbItem.astro b/src/components/Breadcrumb/breadcrumbItem.astro new file mode 100644 index 0000000..6e64321 --- /dev/null +++ b/src/components/Breadcrumb/breadcrumbItem.astro @@ -0,0 +1,19 @@ +--- +export interface Props { + href?: string; + current?: boolean; +} +const { href = "#", current = false } = Astro.props; +--- + + + + + + diff --git a/src/components/Checkbox/_checkbox.scss b/src/components/Checkbox/_checkbox.scss new file mode 100644 index 0000000..be7a5ca --- /dev/null +++ b/src/components/Checkbox/_checkbox.scss @@ -0,0 +1,51 @@ +@use "../../styles/tokens/typography" as *; + +.checkbox { + display: inline-flex; + align-items: center; + gap: var(--nds-spacing-xs); + cursor: pointer; + @include text-base; + color: var(--nds-text); + &__input { + position: absolute; + opacity: 0; + width: 0; + height: 0; + } + &__box { + width: 18px; + height: 18px; + flex-shrink: 0; + display: inline-flex; + align-items: center; + justify-content: center; + border: var(--nds-border-width-medium) solid var(--nds-border-strong); + border-radius: var(--nds-radius-sm); + background-color: var(--nds-surface); + color: var(--nds-on-primary); + transition: all 130ms ease; + svg { + width: 12px; + height: 12px; + opacity: 0; + transform: scale(0.6); + transition: all 130ms ease; + } + } + &__input:checked + &__box { + background-color: var(--nds-primary); + border-color: var(--nds-primary); + svg { + opacity: 1; + transform: scale(1); + } + } + &__input:focus-visible + &__box { + box-shadow: 0 0 0 3px var(--nds-ring); + } + &--disabled { + cursor: not-allowed; + opacity: 0.5; + } +} diff --git a/src/components/Checkbox/checkbox.astro b/src/components/Checkbox/checkbox.astro new file mode 100644 index 0000000..4d65788 --- /dev/null +++ b/src/components/Checkbox/checkbox.astro @@ -0,0 +1,37 @@ +--- +export interface Props { + id: string; + name?: string; + checked?: boolean; + disabled?: boolean; +} +const { id, name, checked = false, disabled = false } = Astro.props; +--- + + + + diff --git a/src/components/Radio/_radio.scss b/src/components/Radio/_radio.scss new file mode 100644 index 0000000..92429b3 --- /dev/null +++ b/src/components/Radio/_radio.scss @@ -0,0 +1,50 @@ +@use "../../styles/tokens/typography" as *; + +.radio { + display: inline-flex; + align-items: center; + gap: var(--nds-spacing-xs); + cursor: pointer; + @include text-base; + color: var(--nds-text); + &__input { + position: absolute; + opacity: 0; + width: 0; + height: 0; + } + &__dot { + width: 18px; + height: 18px; + flex-shrink: 0; + display: inline-flex; + align-items: center; + justify-content: center; + border: var(--nds-border-width-medium) solid var(--nds-border-strong); + border-radius: var(--nds-radius-full); + background-color: var(--nds-surface); + transition: border-color 130ms ease; + &::after { + content: ""; + width: 8px; + height: 8px; + border-radius: var(--nds-radius-full); + background-color: var(--nds-primary); + transform: scale(0); + transition: transform 130ms cubic-bezier(0.34, 1.4, 0.6, 1); + } + } + &__input:checked + &__dot { + border-color: var(--nds-primary); + &::after { + transform: scale(1); + } + } + &__input:focus-visible + &__dot { + box-shadow: 0 0 0 3px var(--nds-ring); + } + &--disabled { + cursor: not-allowed; + opacity: 0.5; + } +} diff --git a/src/components/Radio/radio.astro b/src/components/Radio/radio.astro new file mode 100644 index 0000000..c07cb65 --- /dev/null +++ b/src/components/Radio/radio.astro @@ -0,0 +1,28 @@ +--- +export interface Props { + id: string; + name: string; + value?: string; + checked?: boolean; + disabled?: boolean; +} +const { id, name, value, checked = false, disabled = false } = Astro.props; +--- + + + +