From 110a2de64fbfac0b513fb705a024620ba81c2eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=85=E5=87=A4?= Date: Sat, 21 Nov 2026 13:48:07 -0400 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E9=87=8D=E6=9E=84=20CalloutBanner?= =?UTF-8?q?=20=E8=A1=A8=E9=9D=A2=E4=B8=8E=E8=AF=AD=E4=B9=89=E6=A0=87?= =?UTF-8?q?=E5=B9=B6=E6=94=AF=E6=8C=81=20Toast=20action=20=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E5=B8=B8=E9=A9=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/callout-banner/index.vue | 83 +++++++++++++++---------- src/components/sonner/Toaster.vue | 4 +- src/components/sonner/toast.ts | 2 + 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/components/callout-banner/index.vue b/src/components/callout-banner/index.vue index b5473fd..aee5e9d 100644 --- a/src/components/callout-banner/index.vue +++ b/src/components/callout-banner/index.vue @@ -34,7 +34,7 @@ :data-clickable="clickable ? '' : undefined" class="flex text-left" :class="[ - size === 'sm' ? 'gap-2' : 'gap-3', + size === 'sm' ? 'gap-2' : 'gap-3 sm:gap-5', bare ? '' : [frameClass, toneClass], clickable ? [interactiveClass, 'flex-row items-center'] : 'flex-col sm:flex-row sm:items-center', ]" @@ -42,22 +42,18 @@ + - default: the page-level banner (Memoh 2.0 Direction A). Opaque bg-card + surface (hairline border in light mode, borderless in dark mode to + match PlanCard / SurfaceCard), optional inline `r=6` semantic tag next + to the title instead of a leading icon, 14px title, 13px body. Legacy + callers that have not supplied `tag` keep the leading icon fallback so + tone never disappears silently. -->
-
-

- {{ title }} -

+

+ {{ title }} +

+ + {{ tag }} + +

{{ description }}

@@ -136,12 +145,13 @@ // have one notice owner instead of two with different edges and icon math. import { ErrorIcon } from '@memohai/icon/ui' import { ChevronRight, Info, TriangleAlert, X } from 'lucide-vue-next' -import { computed } from 'vue' +import { computed, useSlots } from 'vue' import { Button } from '#/components/button' const props = withDefaults(defineProps<{ tone?: 'neutral' | 'warning' | 'destructive' title?: string + tag?: string description?: string size?: 'default' | 'sm' bare?: boolean @@ -150,6 +160,7 @@ const props = withDefaults(defineProps<{ }>(), { tone: 'warning', title: '', + tag: '', description: '', size: 'default', bare: false, @@ -157,6 +168,8 @@ const props = withDefaults(defineProps<{ dismissLabel: '', }) +const slots = useSlots() + const emit = defineEmits<{ (e: 'dismiss'): void }>() @@ -167,44 +180,50 @@ const toneIcon = computed(() => ({ destructive: ErrorIcon, })[props.tone]) +// Direction A removes the leading icon whenever the semantic tag carries the +// tone (unless a caller explicitly supplies a custom `#icon` slot). +const showLeadingIcon = computed(() => Boolean(slots.icon) || !props.tag) + // The first line is the title if present, otherwise the promoted description; // the icon box borrows the same rung so `h-lh` resolves to that line box. const firstLineRung = computed(() => props.size === 'sm' ? 'text-label' : 'text-control') const frameClass = computed(() => props.size === 'sm' ? 'rounded-menu-shell border px-3 py-2' - : 'rounded-xl px-4 py-3') + : 'rounded-menu-shell border border-border bg-card px-5 py-4 dark:border-0') // Full literal class strings per tone — Tailwind scans source text, so a runtime -// concat would never be generated. Clickable hover uses the *-soft-hover tokens -// (utilities layer) so the wash is visible and stays in the same tone family. -// sm: hairline border + faint wash. default: no border, one solid fill that -// must read without an edge. Destructive/neutral step one rung deeper -// (*-soft-hover / muted) because their soft rung is a near-invisible 5–40% -// mix; warning's soft rung is already an opaque-ish tint and its hover rung -// reads as a saturated block, so it stays on warning-soft. Clickable -// destructive/neutral deepen by brightness since there is no rung above. +// concat would never be generated. +// - sm: hairline tone border + faint wash. +// - default: neutral opaque card surface (`bg-card`, border in light, borderless +// in dark) so dot-matrix / page backdrops never bleed through a translucent wash. const toneClass = computed(() => { const sm = props.size === 'sm' + if (!sm) { + return props.clickable ? 'transition-colors hover:bg-muted' : '' + } if (props.tone === 'destructive') { - if (!sm) return props.clickable ? 'bg-destructive-soft-hover transition-[filter] hover:brightness-125' : 'bg-destructive-soft-hover' const rest = 'border-destructive-border bg-destructive-soft' return props.clickable ? `${rest} transition-colors hover:bg-destructive-soft-hover hover:border-destructive-border-hover` : rest } if (props.tone === 'neutral') { - if (!sm) return props.clickable ? 'bg-muted transition-[filter] hover:brightness-125' : 'bg-muted' const rest = 'border-border bg-muted-soft' return props.clickable ? `${rest} transition-colors hover:bg-muted` : rest } - if (!sm) return props.clickable ? 'bg-warning-soft transition-colors hover:bg-warning-soft-hover' : 'bg-warning-soft' const rest = 'border-warning-border bg-warning-soft' return props.clickable ? `${rest} transition-colors hover:bg-warning-soft-hover hover:border-warning-border-hover` : rest }) +const tagClass = computed(() => ({ + neutral: 'bg-secondary text-muted-foreground', + warning: 'bg-accent-yellow-soft-hover text-accent-yellow', + destructive: 'bg-accent-red-soft-hover text-accent-red', +})[props.tone]) + const iconClass = computed(() => ({ neutral: 'text-muted-foreground', warning: 'text-warning-foreground', diff --git a/src/components/sonner/Toaster.vue b/src/components/sonner/Toaster.vue index dfbab3d..172e401 100644 --- a/src/components/sonner/Toaster.vue +++ b/src/components/sonner/Toaster.vue @@ -147,7 +147,7 @@ onBeforeUnmount(() => { variant="outline" size="sm" class="memoh-toast__action" - @click="() => { t.action!.onClick(); dismiss(t.id) }" + @click="() => { t.action!.onClick(); if (t.action!.dismissOnClick !== false) dismiss(t.id) }" > {{ t.action.label }} @@ -205,7 +205,7 @@ onBeforeUnmount(() => { variant="outline" size="sm" class="memoh-toast__action" - @click="() => { t.action!.onClick(); dismiss(t.id) }" + @click="() => { t.action!.onClick(); if (t.action!.dismissOnClick !== false) dismiss(t.id) }" > {{ t.action.label }} diff --git a/src/components/sonner/toast.ts b/src/components/sonner/toast.ts index c5366ee..1458e6f 100644 --- a/src/components/sonner/toast.ts +++ b/src/components/sonner/toast.ts @@ -11,6 +11,8 @@ export type ToastVariant = 'message' | 'success' | 'error' | 'info' | 'warning' export interface ToastAction { label: string onClick: () => void + /** Whether clicking the action dismisses this toast. Defaults to `true`. */ + dismissOnClick?: boolean } export interface ToastTextAction {