From 35933055128028aca3b27f1b00695d975065f342 Mon Sep 17 00:00:00 2001 From: unkn0wn Date: Tue, 23 Jun 2026 11:08:24 +0200 Subject: [PATCH] feat: add Tooltip component and update styles in Button and index page --- src/components/Button/button.astro | 32 ++++++++++---------- src/components/Tooltip/_tooltip.scss | 45 ++++++++++++++++++++++++++++ src/components/Tooltip/tooltip.astro | 16 ++++++++++ src/pages/index.astro | 6 ++++ 4 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 src/components/Tooltip/_tooltip.scss create mode 100644 src/components/Tooltip/tooltip.astro diff --git a/src/components/Button/button.astro b/src/components/Button/button.astro index 8528cf7..1f5c984 100644 --- a/src/components/Button/button.astro +++ b/src/components/Button/button.astro @@ -1,38 +1,40 @@ --- export interface Props { - type?: 'primary' | 'secondary' | 'ghost' | 'danger'; - size?: 'sm' | 'md' | 'lg'; + type?: "primary" | "secondary" | "ghost" | "danger"; + size?: "sm" | "md" | "lg"; disabled?: boolean; - icon?: boolean; - href?: string; - htmlType?: 'button' | 'submit' | 'reset'; + icon?: boolean; + href?: string; + htmlType?: "button" | "submit" | "reset"; } const { - type = 'primary', - size = 'md', + type = "primary", + size = "md", disabled = false, icon = false, href, - htmlType = 'button', + htmlType = "button", ...rest } = Astro.props; const classes = [ - 'button', + "button", `button__${type}`, `button--${size}`, - icon ? 'button--icon' : '', - disabled ? 'button--disabled' : '', -].filter(Boolean).join(' '); + icon ? "button--icon" : "", + disabled ? "button--disabled" : "", +] + .filter(Boolean) + .join(" "); -const Tag = href ? 'a' : 'button'; +const Tag = href ? "a" : "button"; --- @@ -41,5 +43,5 @@ const Tag = href ? 'a' : 'button'; diff --git a/src/components/Tooltip/_tooltip.scss b/src/components/Tooltip/_tooltip.scss new file mode 100644 index 0000000..2f780e9 --- /dev/null +++ b/src/components/Tooltip/_tooltip.scss @@ -0,0 +1,45 @@ +@use "../../styles/tokens/typography" as *; + +.tooltip { + position: relative; + display: inline-flex; + &__bubble { + position: absolute; + white-space: nowrap; + padding: var(--nds-spacing-2xs) var(--nds-spacing-xs); + background-color: var(--nds-text); + color: var(--nds-background); + border-radius: var(--nds-radius-sm); + @include text-sm; + font-weight: 500; + box-shadow: var(--nds-shadow-md); + z-index: 100; + opacity: 0; + pointer-events: none; + transition: opacity 130ms ease; + } + &:hover &__bubble, + &:focus-within &__bubble { + opacity: 1; + } + &--top &__bubble { + bottom: 100%; + left: 50%; + transform: translate(-50%, -6px); + } + &--bottom &__bubble { + top: 100%; + left: 50%; + transform: translate(-50%, 6px); + } + &--left &__bubble { + right: 100%; + top: 50%; + transform: translate(-6px, -50%); + } + &--right &__bubble { + left: 100%; + top: 50%; + transform: translate(6px, -50%); + } +} diff --git a/src/components/Tooltip/tooltip.astro b/src/components/Tooltip/tooltip.astro new file mode 100644 index 0000000..776e838 --- /dev/null +++ b/src/components/Tooltip/tooltip.astro @@ -0,0 +1,16 @@ +--- +export interface Props { + label: string; + position?: "top" | "bottom" | "left" | "right"; +} +const { label, position = "top" } = Astro.props; +--- + + + + {label} + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index f80b721..d3a5ac2 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -384,10 +384,16 @@ const libraryIcons = [