diff --git a/demo/partials/alerts.html b/demo/partials/alerts.html index 5ec78cd..5b49085 100644 --- a/demo/partials/alerts.html +++ b/demo/partials/alerts.html @@ -47,4 +47,21 @@ + +

Vue alerts

+
+ diff --git a/demo/partials/badges.html b/demo/partials/badges.html index 8aee007..7fa4f9a 100644 --- a/demo/partials/badges.html +++ b/demo/partials/badges.html @@ -37,4 +37,22 @@ Failed + +

Vue badges

+
+ diff --git a/demo/partials/buttons.html b/demo/partials/buttons.html index ba81256..1f87a82 100644 --- a/demo/partials/buttons.html +++ b/demo/partials/buttons.html @@ -92,4 +92,34 @@ + +

Vue buttons

+
+ diff --git a/demo/partials/cards.html b/demo/partials/cards.html index 7a6fb4f..a9e6895 100644 --- a/demo/partials/cards.html +++ b/demo/partials/cards.html @@ -65,4 +65,25 @@
Generous padding and larger radius.
+ +

Vue cards

+
+ diff --git a/demo/partials/inputs.html b/demo/partials/inputs.html index 08c269d..fb3ccd7 100644 --- a/demo/partials/inputs.html +++ b/demo/partials/inputs.html @@ -61,4 +61,29 @@ + +

Vue inputs

+
+ diff --git a/demo/partials/tables.html b/demo/partials/tables.html index 50f8044..fe92bcc 100644 --- a/demo/partials/tables.html +++ b/demo/partials/tables.html @@ -1,4 +1,4 @@ -
+

Tables

@@ -58,4 +58,44 @@
+ +

Vue table

+
+
diff --git a/src/scss/components/_alerts.scss b/src/scss/components/_alerts.scss index df06ce9..0915558 100644 --- a/src/scss/components/_alerts.scss +++ b/src/scss/components/_alerts.scss @@ -71,4 +71,31 @@ background-color: $danger-bg; color: $danger-text; } + + .alert-close { + flex-shrink: 0; + display: inline-flex; + align-items: center; + justify-content: center; + width: 24px; + height: 24px; + padding: 0; + margin: -$space-1 0; + border: 0; + border-radius: $radius-full; + background: transparent; + color: currentColor; + cursor: pointer; + opacity: 0.7; + transition: opacity $motion-base $motion-ease, background-color $motion-base $motion-ease; + + &:hover { + opacity: 1; + background-color: rgba($neutral-900, 0.08); + } + + &:focus-visible { + @include focus_ring; + } + } } diff --git a/src/vue/components/GnAlert.js b/src/vue/components/GnAlert.js index 24b155d..a0daafe 100644 --- a/src/vue/components/GnAlert.js +++ b/src/vue/components/GnAlert.js @@ -16,9 +16,11 @@ variant: { type: String, default: "primary" }, icon: { type: String, default: "" }, role: { type: String, default: "status" }, - title: { type: String, default: "" } + title: { type: String, default: "" }, + dismissible: { type: Boolean, default: false } }, - setup(props, { attrs, slots }) { + emits: ["dismiss"], + setup(props, { attrs, slots, emit }) { return () => { const variant = normalizeVariant(props.variant); const iconName = props.icon || STATE_ICONS[variant] || ""; @@ -32,7 +34,13 @@ h("div", { class: "alert-content" }, [ props.title && h("div", { class: "alert-title" }, props.title), slots.default?.() - ]) + ]), + props.dismissible && h("button", { + type: "button", + class: "alert-close", + "aria-label": "Dismiss", + onClick: () => emit("dismiss") + }, [iconNode("ph-x")]) ]); }; } diff --git a/tests/demo-screenshot.spec.js b/tests/demo-screenshot.spec.js index 46010c6..97aff12 100644 --- a/tests/demo-screenshot.spec.js +++ b/tests/demo-screenshot.spec.js @@ -8,7 +8,7 @@ const SECTIONS = [ { name: "palette", label: "Palette" }, { name: "buttons", label: "Buttons" }, - { name: "forms", label: "Forms" }, + { name: "inputs", label: "Inputs" }, { name: "alerts", label: "Alerts" }, { name: "badges", label: "Badges" }, { name: "cards", label: "Cards" },