From 88384fa72d5905c323c0b23d452b83b65ead6869 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Wed, 7 Oct 2026 20:29:33 +0400 Subject: [PATCH] feat(island): post card access and share, action menu, tab links, segmented choice Island pieces for the channel, post page, composer and dashboard. - New molecules: ActionMenu (links or actions in a popover), TabLinks (route tabs), SegmentedChoice. - PostCard: owner footer, share menu on desktop, access note for an open premium post, frozen CTA reason on a locked one. - LockedTeaser keeps the gate's place while the viewer is unknown; Modal gains sizes; Lightbox and skeleton presets for feeds and headers. - Button: `pressableWhenFrozen`, a frozen look whose press still calls onClick (explain or check instead of a tooltip). - TextInput counts UTF-16 units, as the native maxLength does, so the counter reaches the limit with it. Co-Authored-By: Claude Opus 5.5 --- packages/island/src/atoms/avatar/Avatar.tsx | 3 +- packages/island/src/atoms/avatar/types.ts | 2 + packages/island/src/atoms/avatar/variants.ts | 7 +- packages/island/src/atoms/button/Button.tsx | 6 +- .../atoms/button/components/FrozenButton.tsx | 3 +- packages/island/src/atoms/button/types.ts | 15 ++- packages/island/src/atoms/button/variants.ts | 13 +- packages/island/src/index.ts | 17 ++- .../src/molecules/action-menu/ActionMenu.tsx | 97 +++++++++++++ .../action-menu/components/ActionMenuItem.tsx | 70 ++++++++++ .../island/src/molecules/action-menu/index.ts | 2 + .../island/src/molecules/action-menu/types.ts | 31 +++++ .../src/molecules/action-menu/variants.ts | 15 +++ .../molecules/locked-teaser/LockedTeaser.tsx | 46 ++++++- .../src/molecules/locked-teaser/constants.ts | 3 + .../src/molecules/locked-teaser/index.ts | 2 +- .../src/molecules/locked-teaser/types.ts | 18 +++ packages/island/src/molecules/modal/Modal.tsx | 102 +++++++++----- packages/island/src/molecules/modal/index.ts | 2 +- packages/island/src/molecules/modal/types.ts | 27 +++- .../island/src/molecules/modal/variants.ts | 16 +++ .../segmented-choice/SegmentedChoice.tsx | 74 ++++++++++ .../src/molecules/segmented-choice/index.ts | 11 ++ .../src/molecules/segmented-choice/types.ts | 46 +++++++ .../molecules/segmented-choice/variants.ts | 38 ++++++ .../src/molecules/tab-links/TabLinks.tsx | 48 +++++++ .../island/src/molecules/tab-links/index.ts | 2 + .../island/src/molecules/tab-links/types.ts | 25 ++++ .../src/molecules/tab-links/variants.ts | 31 +++++ .../src/molecules/text-input/TextInput.tsx | 3 +- .../src/organisms/lightbox/Lightbox.tsx | 127 +++++++++++++++--- .../src/organisms/lightbox/constants.ts | 8 +- .../island/src/organisms/lightbox/types.ts | 15 ++- .../island/src/organisms/lightbox/utils.ts | 24 ++++ .../island/src/organisms/lightbox/variants.ts | 23 +++- .../src/organisms/post-card/PostCard.tsx | 25 +++- .../post-card/components/PostAccess.tsx | 39 ++++++ .../post-card/components/PostAccessNote.tsx | 22 +++ .../post-card/components/PostActions.tsx | 31 +++-- .../post-card/components/PostHead.tsx | 6 + .../post-card/components/PostLocked.tsx | 5 + .../post-card/components/PostShareMenu.tsx | 42 ++++++ .../island/src/organisms/post-card/types.ts | 68 +++++++++- .../skeleton-preset/SkeletonPreset.tsx | 8 +- .../components/HeaderSkeleton.tsx | 12 +- .../components/ListSkeleton.tsx | 39 +++++- .../src/organisms/skeleton-preset/types.ts | 25 +++- 47 files changed, 1182 insertions(+), 112 deletions(-) create mode 100644 packages/island/src/molecules/action-menu/ActionMenu.tsx create mode 100644 packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx create mode 100644 packages/island/src/molecules/action-menu/index.ts create mode 100644 packages/island/src/molecules/action-menu/types.ts create mode 100644 packages/island/src/molecules/action-menu/variants.ts create mode 100644 packages/island/src/molecules/modal/variants.ts create mode 100644 packages/island/src/molecules/segmented-choice/SegmentedChoice.tsx create mode 100644 packages/island/src/molecules/segmented-choice/index.ts create mode 100644 packages/island/src/molecules/segmented-choice/types.ts create mode 100644 packages/island/src/molecules/segmented-choice/variants.ts create mode 100644 packages/island/src/molecules/tab-links/TabLinks.tsx create mode 100644 packages/island/src/molecules/tab-links/index.ts create mode 100644 packages/island/src/molecules/tab-links/types.ts create mode 100644 packages/island/src/molecules/tab-links/variants.ts create mode 100644 packages/island/src/organisms/lightbox/utils.ts create mode 100644 packages/island/src/organisms/post-card/components/PostAccess.tsx create mode 100644 packages/island/src/organisms/post-card/components/PostAccessNote.tsx create mode 100644 packages/island/src/organisms/post-card/components/PostShareMenu.tsx diff --git a/packages/island/src/atoms/avatar/Avatar.tsx b/packages/island/src/atoms/avatar/Avatar.tsx index 01f1b85..92082c2 100644 --- a/packages/island/src/atoms/avatar/Avatar.tsx +++ b/packages/island/src/atoms/avatar/Avatar.tsx @@ -16,6 +16,7 @@ export function Avatar({ src, size = 'md', verified = false, + muted = false, verifiedLabel, label, className, @@ -36,7 +37,7 @@ export function Avatar({ aria-hidden={label ? undefined : true} justifyItems="justify-items-center" alignItems="items-center" - className={avatarVariants({ size })} + className={avatarVariants({ size, muted })} > , 'children'> & { size?: AvatarSize; /** The creator's verification mark at the bottom inline end. */ verified?: boolean; + /** Greyed: an account that can't be used now (a suspended creator's own channel). */ + muted?: boolean; /** The mark's accessible name, such as «تأیید‌شده». */ verifiedLabel?: string; /** diff --git a/packages/island/src/atoms/avatar/variants.ts b/packages/island/src/atoms/avatar/variants.ts index df74a67..b962df8 100644 --- a/packages/island/src/atoms/avatar/variants.ts +++ b/packages/island/src/atoms/avatar/variants.ts @@ -17,7 +17,12 @@ export const avatarVariants = cva( /** The profile photo field. */ '2xl': 'size-24', }, + /** An account that can't be used, such as a suspended creator's own avatar: no brand colour. */ + muted: { + true: 'bg-surface-sunken text-text-secondary grayscale', + false: '', + }, }, - defaultVariants: { size: 'md' }, + defaultVariants: { size: 'md', muted: false }, }, ); diff --git a/packages/island/src/atoms/button/Button.tsx b/packages/island/src/atoms/button/Button.tsx index c57bc5b..f70c674 100644 --- a/packages/island/src/atoms/button/Button.tsx +++ b/packages/island/src/atoms/button/Button.tsx @@ -22,6 +22,8 @@ export function Button({ label, frozen = false, frozenReason, + frozenAlign, + pressableWhenFrozen = false, isLoading = false, className, children, @@ -68,6 +70,7 @@ export function Button({ {...buttonProps} reason={frozenReason} block={block} + align={frozenAlign} className={classes} aria-label={ariaLabel} > @@ -80,10 +83,11 @@ export function Button({ // blocked, swallows the click: preventDefault also stops a submit button's form, including Enter // in a field. A server render can't carry a handler, so a blocked button without onClick renders // `type="button"` instead, which can't submit its form at all. + const swallowsClick = isLoading || (frozen && !pressableWhenFrozen); const handleClick = onClick && ((event: MouseEvent) => { - if (isBlocked) { + if (swallowsClick) { event.preventDefault(); return; } diff --git a/packages/island/src/atoms/button/components/FrozenButton.tsx b/packages/island/src/atoms/button/components/FrozenButton.tsx index 00978d3..7dd9da2 100644 --- a/packages/island/src/atoms/button/components/FrozenButton.tsx +++ b/packages/island/src/atoms/button/components/FrozenButton.tsx @@ -15,6 +15,7 @@ import { frozenTipVariants } from '../variants'; export function FrozenButton({ reason, block, + align, children, ...props }: FrozenButtonProps) { @@ -45,7 +46,7 @@ export function FrozenButton({ role="tooltip" variant="caption" color="inverse" - className={frozenTipVariants({ open: isOpen })} + className={frozenTipVariants({ open: isOpen, align })} > {reason} diff --git a/packages/island/src/atoms/button/types.ts b/packages/island/src/atoms/button/types.ts index dd3141a..0dbe867 100644 --- a/packages/island/src/atoms/button/types.ts +++ b/packages/island/src/atoms/button/types.ts @@ -3,7 +3,9 @@ import type NextLink from 'next/link'; import type { ComponentPropsWithRef, ReactNode } from 'react'; import type { IconName } from '../icon'; -import type { buttonVariants } from './variants'; +import type { buttonVariants, frozenTipVariants } from './variants'; + +type FrozenTipAlign = VariantProps['align']; type ButtonOwnProps = Pick< VariantProps, @@ -18,6 +20,16 @@ type ButtonOwnProps = Pick< frozen?: boolean; /** Why the button is frozen, shown on tap, hover and focus. */ frozenReason?: ReactNode; + /** + * Frozen without a reason, yet a press still calls `onClick`, which explains or checks instead: + * a publish menu that opens why it can't publish, an empty post's check. + */ + pressableWhenFrozen?: boolean; + /** + * Where the reason sits above the button: centred (default), or `end`, its end on the button's, + * for a button at the screen's end edge, so a long reason stays on screen. + */ + frozenAlign?: FrozenTipAlign; /** An action is in flight: keeps the label, shows a spinner, and blocks repeat taps. */ isLoading?: boolean; children?: ReactNode; @@ -57,5 +69,6 @@ export type FrozenButtonProps = Omit< > & { reason: ReactNode; block?: boolean | null; + align?: FrozenTipAlign; children: ReactNode; }; diff --git a/packages/island/src/atoms/button/variants.ts b/packages/island/src/atoms/button/variants.ts index 1731980..171c759 100644 --- a/packages/island/src/atoms/button/variants.ts +++ b/packages/island/src/atoms/button/variants.ts @@ -48,14 +48,19 @@ export const buttonVariants = cva( }, ); -/** The tooltip that explains a frozen button, above it and centred on it. */ +/** The tooltip that explains a frozen button, above it. */ export const frozenTipVariants = cva( - // Physical left: centring is the same in RTL and LTR. - 'pointer-events-none absolute bottom-[calc(100%+0.5rem)] left-1/2 z-menu hidden w-max max-w-[16.25rem] -translate-x-1/2 rounded-sm bg-surface-inverse px-3 py-1.5 text-center whitespace-normal shadow-2 group-focus-within:block group-hover:block', + 'pointer-events-none absolute bottom-[calc(100%+0.5rem)] z-menu hidden w-max max-w-[16.25rem] rounded-sm bg-surface-inverse px-3 py-1.5 text-center whitespace-normal shadow-2 group-focus-within:block group-hover:block', { variants: { open: { true: 'block', false: '' }, + align: { + // Physical left: centring is the same in RTL and LTR. + center: 'left-1/2 -translate-x-1/2', + // Its end on the button's end, so it grows toward the screen from a button at the edge. + end: 'end-0', + }, }, - defaultVariants: { open: false }, + defaultVariants: { open: false, align: 'center' }, }, ); diff --git a/packages/island/src/index.ts b/packages/island/src/index.ts index 11f458d..0e460f3 100644 --- a/packages/island/src/index.ts +++ b/packages/island/src/index.ts @@ -107,6 +107,8 @@ export { Banner, bannerVariants } from './molecules/banner'; export type { BannerProps, BannerTone } from './molecules/banner'; export { Card, cardVariants } from './molecules/card'; export type { CardOwnProps, CardProps } from './molecules/card'; +export { ActionMenu } from './molecules/action-menu'; +export type { ActionMenuItem, ActionMenuProps } from './molecules/action-menu'; export { ChipGroup } from './molecules/chip-group'; export type { ChipGroupOption, ChipGroupProps } from './molecules/chip-group'; export { ChoiceCard, choiceCardVariants } from './molecules/choice-card'; @@ -122,7 +124,7 @@ export type { LockedTeaserProps } from './molecules/locked-teaser'; export { MediaCarousel } from './molecules/media-carousel'; export type { MediaCarouselProps, MediaItem } from './molecules/media-carousel'; export { Modal } from './molecules/modal'; -export type { ModalProps } from './molecules/modal'; +export type { ModalProps, ModalSize } from './molecules/modal'; export { NetworkStatus, networkStatusVariants, @@ -139,6 +141,17 @@ export type { ResendCodeProps, ResendStatus, } from './molecules/resend-code'; +export { + SegmentedChoice, + segmentedChoiceOptionVariants, + segmentedChoiceVariants, +} from './molecules/segmented-choice'; +export type { + SegmentedChoiceOption, + SegmentedChoiceProps, + SegmentedChoiceSize, + SegmentedChoiceTrack, +} from './molecules/segmented-choice'; export { Sheet } from './molecules/sheet'; export type { SheetPlacement, SheetProps } from './molecules/sheet'; export { StateMessage, stateMessageVariants } from './molecules/state-message'; @@ -148,6 +161,8 @@ export type { } from './molecules/state-message'; export { StepProgress } from './molecules/step-progress'; export type { StepProgressProps } from './molecules/step-progress'; +export { TabLinks } from './molecules/tab-links'; +export type { TabLinkItem, TabLinksProps } from './molecules/tab-links'; export { TextInput, textInputBoxVariants, diff --git a/packages/island/src/molecules/action-menu/ActionMenu.tsx b/packages/island/src/molecules/action-menu/ActionMenu.tsx new file mode 100644 index 0000000..5a9e032 --- /dev/null +++ b/packages/island/src/molecules/action-menu/ActionMenu.tsx @@ -0,0 +1,97 @@ +'use client'; + +import { useEffect, useEffectEvent, useRef } from 'react'; +import type { KeyboardEvent } from 'react'; + +import { Element } from '../../primitives/element'; +import { cn } from '../../tools/cn'; +import { ActionMenuItem } from './components/ActionMenuItem'; +import type { ActionMenuProps } from './types'; +import { actionMenuVariants } from './variants'; + +/** + * A short list of destinations or actions anchored to its trigger, such as «انتشار» → «پست جدید» + * / «پیش‌بینی جدید», or a post's share → «کپی لینک». Put it in a positioned container that holds + * only the trigger and the menu, and give the trigger `aria-haspopup="menu"`. It takes focus when + * it opens; ↑ ↓ move, and the trigger keeps its own press. Escape or a choice closes it and puts + * focus back on that container's `[aria-haspopup]` trigger; a press outside, or Tab out of the + * menu and its trigger, closes it and leaves focus where the press or Tab put it. + */ +export function ActionMenu({ + open, + onClose, + items, + label, + placement = 'below', + className, +}: ActionMenuProps) { + const ref = useRef(null); + const close = useEffectEvent(onClose); + + useEffect(() => { + if (!open) return undefined; + // The trigger's container: the menu and its trigger, nothing else. + const area = ref.current?.parentElement ?? ref.current; + if (!area) return undefined; + ref.current?.querySelector('[role="menuitem"]')?.focus(); + const handlePointerDown = (event: PointerEvent) => { + if (!area.contains(event.target as Node)) close(); + }; + // Tab out of it closes it; focus has already moved on, so it stays there. A null target + // (another window, a press on nothing focusable) keeps it open. + const handleFocusOut = (event: FocusEvent) => { + const next = event.relatedTarget; + if (next instanceof Node && !area.contains(next)) close(); + }; + document.addEventListener('pointerdown', handlePointerDown); + area.addEventListener('focusout', handleFocusOut); + return () => { + document.removeEventListener('pointerdown', handlePointerDown); + area.removeEventListener('focusout', handleFocusOut); + }; + }, [open]); + + if (!open) return null; + + // Read on the event, before the menu unmounts; focusing the trigger keeps the keyboard in place. + const closeToTrigger = () => { + const trigger = + ref.current?.parentElement?.querySelector('[aria-haspopup]'); + onClose(); + trigger?.focus(); + }; + + const onKeyDown = (event: KeyboardEvent) => { + const options = Array.from( + ref.current?.querySelectorAll('[role="menuitem"]') ?? [], + ); + const at = options.indexOf(document.activeElement as HTMLElement); + if (event.key === 'Escape') { + event.preventDefault(); + closeToTrigger(); + } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { + event.preventDefault(); + const step = event.key === 'ArrowDown' ? 1 : -1; + options[(at + step + options.length) % options.length]?.focus(); + } + }; + + return ( + + {items.map((item) => ( + + ))} + + ); +} diff --git a/packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx b/packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx new file mode 100644 index 0000000..cbac0c8 --- /dev/null +++ b/packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx @@ -0,0 +1,70 @@ +import NextLink from 'next/link'; + +import { FlexBox } from '../../../atoms/flex-box'; +import { Icon } from '../../../atoms/icon'; +import { Typography } from '../../../atoms/typography'; +import { Element } from '../../../primitives/element'; +import { cn } from '../../../tools/cn'; +import type { ActionMenuItemProps } from '../types'; + +/** A link row and a button row look the same. */ +const ROW_CLASS = + 'min-h-touch-target rounded-md px-3 text-text-primary no-underline outline-none hover:bg-surface-sunken focus-visible:bg-surface-sunken focus-visible:focus-ring'; + +/** + * One destination or action: its icon in the brand colour and its name, a 44px row. A link + * navigates; a button closes the menu, then runs its `onSelect`. + */ +export function ActionMenuItem({ + href, + label, + icon, + onSelect, + onClose, +}: ActionMenuItemProps) { + const content = ( + <> + + + {label} + + + ); + + return ( + + {href != null ? ( + + {content} + + ) : ( + { + onClose(); + onSelect?.(); + }} + alignItems="items-center" + gap="gap-3" + className={cn(ROW_CLASS, 'w-full cursor-pointer text-start')} + > + {content} + + )} + + ); +} diff --git a/packages/island/src/molecules/action-menu/index.ts b/packages/island/src/molecules/action-menu/index.ts new file mode 100644 index 0000000..3c8c951 --- /dev/null +++ b/packages/island/src/molecules/action-menu/index.ts @@ -0,0 +1,2 @@ +export { ActionMenu } from './ActionMenu'; +export type { ActionMenuItem, ActionMenuProps } from './types'; diff --git a/packages/island/src/molecules/action-menu/types.ts b/packages/island/src/molecules/action-menu/types.ts new file mode 100644 index 0000000..741c5a4 --- /dev/null +++ b/packages/island/src/molecules/action-menu/types.ts @@ -0,0 +1,31 @@ +import type { IconName } from '../../atoms/icon'; + +/** A destination (`href`, a link) or an action (`onSelect`, a button), never both. */ +export type ActionMenuItem = { + label: string; + icon: IconName; +} & ( + | { href: string; onSelect?: never } + | { + /** Runs after the menu has closed, such as «کپی لینک». */ + onSelect: () => void; + href?: never; + } +); + +export type ActionMenuProps = { + open: boolean; + /** Escape, a press or Tab outside the menu and its trigger, or a choice close it. */ + onClose: () => void; + items: readonly ActionMenuItem[]; + /** The menu's accessible name, such as «انتشار». */ + label: string; + /** above: over a bottom-nav button. below: under a header button. */ + placement?: 'above' | 'below'; + className?: string; +}; + +export type ActionMenuItemProps = ActionMenuItem & { + /** The menu's close, which also returns focus to the trigger. */ + onClose: () => void; +}; diff --git a/packages/island/src/molecules/action-menu/variants.ts b/packages/island/src/molecules/action-menu/variants.ts new file mode 100644 index 0000000..8eee572 --- /dev/null +++ b/packages/island/src/molecules/action-menu/variants.ts @@ -0,0 +1,15 @@ +import { cva } from 'class-variance-authority'; + +/** A card that hangs off its trigger: centred over it, or under it at the inline end. */ +export const actionMenuVariants = cva( + 'absolute z-menu m-0 min-w-55 rounded-lg border border-border-subtle bg-surface-raised p-1 shadow-2', + { + variants: { + placement: { + above: 'bottom-full left-1/2 mb-3 -translate-x-1/2', + below: 'end-0 top-full mt-2', + }, + }, + defaultVariants: { placement: 'below' }, + }, +); diff --git a/packages/island/src/molecules/locked-teaser/LockedTeaser.tsx b/packages/island/src/molecules/locked-teaser/LockedTeaser.tsx index 7c84a03..d9296b2 100644 --- a/packages/island/src/molecules/locked-teaser/LockedTeaser.tsx +++ b/packages/island/src/molecules/locked-teaser/LockedTeaser.tsx @@ -4,17 +4,19 @@ import { Button } from '../../atoms/button'; import { FlexBox } from '../../atoms/flex-box'; import { GridBox } from '../../atoms/grid-box'; import { Icon } from '../../atoms/icon'; +import { Skeleton } from '../../atoms/skeleton'; import { Tag } from '../../atoms/tag'; import { Typography } from '../../atoms/typography'; import { Element } from '../../primitives/element'; -import { ACTION_CLASS } from './constants'; +import { ACTION_CLASS, PENDING_ACTION_CLASS } from './constants'; import type { LockedTeaserProps } from './types'; /** * The one locked premium body, on the channel, the post page and the feed alike: two lines of * preview fading into a saffron lock, a lock placeholder for the images, a prediction's frame, * then one message and one CTA on `premium-subtle`. Images are never shown or blurred, not even - * from a blurHash: a blurred chart still leaks the direction. + * from a blurHash: a blurred chart still leaks the direction. While the viewer is unknown + * (`pending`), the gate keeps the message's place and draws the CTA as a skeleton. */ export function LockedTeaser({ preview, @@ -26,6 +28,9 @@ export function LockedTeaser({ actionLabel, actionHref, onAction, + actionFrozenReason, + actionIndicator, + pending = false, className, }: LockedTeaserProps) { return ( @@ -76,8 +81,41 @@ export function LockedTeaser({ gap="gap-3" className="rounded-md bg-premium-subtle p-4 text-center" > - {message} - {actionHref ? ( + {pending ? ( + <> + {/* The message's own height, so the gate doesn't move when the viewer is known. */} + + {message} + + + + + + + ) : actionIndicator ? ( + + ) : actionFrozenReason ? ( + + ) : actionHref ? ( diff --git a/packages/island/src/molecules/locked-teaser/constants.ts b/packages/island/src/molecules/locked-teaser/constants.ts index c1f59d1..fa71f4a 100644 --- a/packages/island/src/molecules/locked-teaser/constants.ts +++ b/packages/island/src/molecules/locked-teaser/constants.ts @@ -1,2 +1,5 @@ /** Puts the CTA above a card's stretched link (PostCard's), so it keeps its own tap. */ export const ACTION_CLASS = 'relative z-1'; + +/** The CTA's skeleton: a Button md's height and about its width. */ +export const PENDING_ACTION_CLASS = 'h-control-md w-34'; diff --git a/packages/island/src/molecules/locked-teaser/index.ts b/packages/island/src/molecules/locked-teaser/index.ts index 5a98d4d..c9b7b8b 100644 --- a/packages/island/src/molecules/locked-teaser/index.ts +++ b/packages/island/src/molecules/locked-teaser/index.ts @@ -1,2 +1,2 @@ export { LockedTeaser } from './LockedTeaser'; -export type { LockedTeaserProps } from './types'; +export type { LockedTeaserIndicator, LockedTeaserProps } from './types'; diff --git a/packages/island/src/molecules/locked-teaser/types.ts b/packages/island/src/molecules/locked-teaser/types.ts index 1d451e7..109f5bd 100644 --- a/packages/island/src/molecules/locked-teaser/types.ts +++ b/packages/island/src/molecules/locked-teaser/types.ts @@ -1,5 +1,14 @@ import type { ReactNode } from 'react'; +import type { IconName } from '../../atoms/icon'; + +/** A frozen status in the CTA's place, such as «پرداخت در حال بررسی», and why it can't be pressed. */ +export type LockedTeaserIndicator = { + label: ReactNode; + reason: ReactNode; + icon?: IconName; +}; + export type LockedTeaserProps = { /** `captionPreview` from the API. Clamped to 2 lines, a hard limit so no analysis leaks. */ preview?: ReactNode; @@ -22,5 +31,14 @@ export type LockedTeaserProps = { actionHref?: string; /** Instead of `actionHref`, such as opening the auth sheet. Client callers only. */ onAction?: () => void; + /** The CTA shows but does nothing, and says why: the creator previewing their own post. */ + actionFrozenReason?: ReactNode; + /** Replaces the CTA with a frozen status, such as a payment waiting for the bank. */ + actionIndicator?: LockedTeaserIndicator; + /** + * The viewer isn't known yet (the server render and the first browser render): the message keeps + * its place unseen and the CTA is a skeleton, so a guest never sees a member's CTA or the reverse. + */ + pending?: boolean; className?: string; }; diff --git a/packages/island/src/molecules/modal/Modal.tsx b/packages/island/src/molecules/modal/Modal.tsx index 2aa3d39..db6c83b 100644 --- a/packages/island/src/molecules/modal/Modal.tsx +++ b/packages/island/src/molecules/modal/Modal.tsx @@ -7,11 +7,15 @@ import { Dialog } from '../../atoms/dialog'; import { Element } from '../../primitives/element'; import { cn } from '../../tools/cn'; import type { ModalProps } from './types'; +import { modalPanelVariants } from './variants'; /** * A centred dialog for short, blocking decisions on desktop, at most 420px wide. On mobile the * same content is always a bottom Sheet, never a Modal. The panel takes focus when it opens, and * focus returns to the trigger when it closes. + * + * `size="wide"` is the desktop form dialog (C4 ۷.۳, «پست جدید»): 640px, a header row with the + * title and `headerAction`, then the caller's body and footer bar, edge to edge. */ export function Modal({ open, @@ -19,6 +23,8 @@ export function Modal({ children, actions, icon, + size = 'default', + headerAction, onClose, onExited, closeLabel, @@ -38,44 +44,68 @@ export function Modal({ labelledBy={titleId} className="items-center justify-center p-4" > - - {closeLabel && dismissible && ( -