From c6c1aa33b299e3eee8e9df97d5fc0b42f5b5430e Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Fri, 9 Oct 2026 17:38:43 +0400 Subject: [PATCH] =?UTF-8?q?feat(island):=20v6=20compositions=20=E2=80=94?= =?UTF-8?q?=20list=20rows,=20page=20header,=20section=20title,=20pinned=20?= =?UTF-8?q?footer,=20result=20panel,=20stat=20tile,=20meter,=20search=20fi?= =?UTF-8?q?eld,=20avatar=20stack,=20timeline,=20code=20input,=20key-value,?= =?UTF-8?q?=20analyst=20card;=20new=20chips,=20segmented,=20avatar=20sizes?= =?UTF-8?q?,=20toast=20placement,=20account=20menu=20items,=20post=20and?= =?UTF-8?q?=20prediction=20card=20names=20and=20close=20reason?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- packages/island/src/atoms/avatar/constants.ts | 11 +- packages/island/src/atoms/avatar/variants.ts | 12 +- packages/island/src/atoms/chip/Chip.tsx | 2 +- packages/island/src/atoms/chip/index.ts | 2 +- packages/island/src/atoms/chip/variants.ts | 25 ++- packages/island/src/atoms/icon/icon-names.ts | 7 + packages/island/src/atoms/select/Select.tsx | 20 +- packages/island/src/atoms/select/types.ts | 4 + packages/island/src/atoms/switch/Switch.tsx | 46 ++++- packages/island/src/atoms/switch/types.ts | 5 + packages/island/src/constants.ts | 2 +- packages/island/src/icons/chevron-up.svg | 3 + packages/island/src/icons/expand.svg | 3 + packages/island/src/icons/file.svg | 4 + packages/island/src/icons/phone.svg | 4 + packages/island/src/icons/plus-square.svg | 4 + packages/island/src/icons/settings.svg | 4 + packages/island/src/icons/share-ios.svg | 4 + packages/island/src/index.ts | 119 ++++++++++- .../src/molecules/action-menu/ActionMenu.tsx | 47 +++-- .../action-menu/components/ActionMenuItem.tsx | 80 ++++---- .../island/src/molecules/action-menu/types.ts | 11 + .../src/molecules/action-menu/variants.ts | 27 ++- .../molecules/avatar-stack/AvatarStack.tsx | 113 ++++++++++ .../src/molecules/avatar-stack/index.ts | 3 + .../src/molecules/avatar-stack/types.ts | 23 +++ .../src/molecules/avatar-stack/variants.ts | 27 +++ .../src/molecules/chip-group/ChipGroup.tsx | 12 +- .../island/src/molecules/chip-group/types.ts | 2 + .../src/molecules/code-input/CodeInput.tsx | 163 +++++++++++++++ .../src/molecules/code-input/constants.ts | 11 + .../island/src/molecules/code-input/index.ts | 8 + .../island/src/molecules/code-input/types.ts | 66 ++++++ .../src/molecules/code-input/variants.ts | 4 + .../src/molecules/detail-row/DetailRow.tsx | 63 ++++-- .../island/src/molecules/detail-row/index.ts | 4 +- .../island/src/molecules/detail-row/types.ts | 25 ++- .../src/molecules/detail-row/variants.ts | 27 ++- .../src/molecules/file-field/FileField.tsx | 183 ++++++++++------- .../island/src/molecules/file-field/types.ts | 2 + .../src/molecules/file-field/variants.ts | 16 +- .../molecules/filter-chips/FilterChips.tsx | 15 +- .../src/molecules/filter-chips/types.ts | 2 + .../src/molecules/key-value/KeyValue.tsx | 29 +++ .../island/src/molecules/key-value/index.ts | 3 + .../island/src/molecules/key-value/types.ts | 17 ++ .../src/molecules/key-value/variants.ts | 20 ++ .../island/src/molecules/list-row/List.tsx | 46 +++++ .../island/src/molecules/list-row/ListRow.tsx | 174 ++++++++++++++++ .../island/src/molecules/list-row/index.ts | 17 ++ .../island/src/molecules/list-row/types.ts | 66 ++++++ .../island/src/molecules/list-row/variants.ts | 79 +++++++ packages/island/src/molecules/meter/Meter.tsx | 68 ++++++ packages/island/src/molecules/meter/index.ts | 3 + packages/island/src/molecules/meter/types.ts | 26 +++ .../island/src/molecules/meter/variants.ts | 26 +++ packages/island/src/molecules/modal/Modal.tsx | 5 +- packages/island/src/molecules/modal/types.ts | 10 +- .../island/src/molecules/modal/variants.ts | 2 + .../src/molecules/page-header/PageHeader.tsx | 62 ++++++ .../island/src/molecules/page-header/index.ts | 3 + .../island/src/molecules/page-header/types.ts | 28 +++ .../src/molecules/page-header/variants.ts | 15 ++ .../molecules/pinned-footer/PinnedFooter.tsx | 59 ++++++ .../src/molecules/pinned-footer/constants.ts | 6 + .../src/molecules/pinned-footer/index.ts | 4 + .../src/molecules/pinned-footer/types.ts | 19 ++ .../src/molecules/pinned-footer/variants.ts | 9 + .../molecules/result-panel/ResultPanel.tsx | 74 +++++++ .../src/molecules/result-panel/constants.ts | 11 + .../src/molecules/result-panel/index.ts | 4 + .../src/molecules/result-panel/types.ts | 31 +++ .../src/molecules/result-panel/variants.ts | 15 ++ .../molecules/search-field/SearchField.tsx | 77 +++++++ .../src/molecules/search-field/index.ts | 3 + .../src/molecules/search-field/types.ts | 20 ++ .../src/molecules/search-field/variants.ts | 11 + .../molecules/section-title/SectionTitle.tsx | 59 ++++++ .../src/molecules/section-title/index.ts | 3 + .../src/molecules/section-title/types.ts | 15 ++ .../src/molecules/section-title/variants.ts | 6 + .../segmented-choice/SegmentedChoice.tsx | 16 +- .../src/molecules/segmented-choice/index.ts | 1 + .../src/molecules/segmented-choice/types.ts | 13 +- .../molecules/segmented-choice/variants.ts | 48 ++++- .../src/molecules/stat-tile/StatTile.tsx | 57 +++++ .../island/src/molecules/stat-tile/index.ts | 3 + .../island/src/molecules/stat-tile/types.ts | 29 +++ .../src/molecules/stat-tile/variants.ts | 25 +++ .../src/molecules/text-input/variants.ts | 3 + .../src/molecules/timeline/Timeline.tsx | 13 ++ .../src/molecules/timeline/TimelineItem.tsx | 62 ++++++ .../island/src/molecules/timeline/index.ts | 8 + .../island/src/molecules/timeline/types.ts | 31 +++ .../island/src/molecules/timeline/variants.ts | 29 +++ .../molecules/toast/ToastPlacementMarker.tsx | 13 ++ .../island/src/molecules/toast/Toaster.tsx | 52 ++++- .../island/src/molecules/toast/constants.ts | 14 +- .../toast/hooks/use-toast-placement.ts | 22 ++ packages/island/src/molecules/toast/index.ts | 6 + .../src/molecules/toast/placement-store.ts | 42 ++++ packages/island/src/molecules/toast/types.ts | 21 +- .../organisms/analyst-card/AnalystCard.tsx | 194 ++++++++++++++++++ .../analyst-card/components/AnalystStats.tsx | 61 ++++++ .../src/organisms/analyst-card/constants.ts | 13 ++ .../src/organisms/analyst-card/index.ts | 7 + .../src/organisms/analyst-card/types.ts | 82 ++++++++ .../src/organisms/analyst-card/utils.ts | 16 ++ .../island/src/organisms/lightbox/variants.ts | 5 +- .../post-card/components/PostHead.tsx | 50 ++++- .../island/src/organisms/post-card/types.ts | 5 + .../prediction-card/PredictionCard.tsx | 6 +- .../components/CloseReasonRow.tsx | 53 +++++ .../prediction-card/components/ClosedHero.tsx | 16 +- .../components/PredictionSeal.tsx | 32 ++- .../organisms/prediction-card/constants.ts | 10 + .../src/organisms/prediction-card/index.ts | 1 + .../src/organisms/prediction-card/types.ts | 61 +++++- .../components/HeaderSkeleton.tsx | 5 +- .../src/organisms/skeleton-preset/types.ts | 2 +- packages/island/src/styles/theme.css | 5 + packages/island/src/tools/cn/constants.ts | 2 + 122 files changed, 3227 insertions(+), 247 deletions(-) create mode 100644 packages/island/src/icons/chevron-up.svg create mode 100644 packages/island/src/icons/expand.svg create mode 100644 packages/island/src/icons/file.svg create mode 100644 packages/island/src/icons/phone.svg create mode 100644 packages/island/src/icons/plus-square.svg create mode 100644 packages/island/src/icons/settings.svg create mode 100644 packages/island/src/icons/share-ios.svg create mode 100644 packages/island/src/molecules/avatar-stack/AvatarStack.tsx create mode 100644 packages/island/src/molecules/avatar-stack/index.ts create mode 100644 packages/island/src/molecules/avatar-stack/types.ts create mode 100644 packages/island/src/molecules/avatar-stack/variants.ts create mode 100644 packages/island/src/molecules/code-input/CodeInput.tsx create mode 100644 packages/island/src/molecules/code-input/constants.ts create mode 100644 packages/island/src/molecules/code-input/index.ts create mode 100644 packages/island/src/molecules/code-input/types.ts create mode 100644 packages/island/src/molecules/code-input/variants.ts create mode 100644 packages/island/src/molecules/key-value/KeyValue.tsx create mode 100644 packages/island/src/molecules/key-value/index.ts create mode 100644 packages/island/src/molecules/key-value/types.ts create mode 100644 packages/island/src/molecules/key-value/variants.ts create mode 100644 packages/island/src/molecules/list-row/List.tsx create mode 100644 packages/island/src/molecules/list-row/ListRow.tsx create mode 100644 packages/island/src/molecules/list-row/index.ts create mode 100644 packages/island/src/molecules/list-row/types.ts create mode 100644 packages/island/src/molecules/list-row/variants.ts create mode 100644 packages/island/src/molecules/meter/Meter.tsx create mode 100644 packages/island/src/molecules/meter/index.ts create mode 100644 packages/island/src/molecules/meter/types.ts create mode 100644 packages/island/src/molecules/meter/variants.ts create mode 100644 packages/island/src/molecules/page-header/PageHeader.tsx create mode 100644 packages/island/src/molecules/page-header/index.ts create mode 100644 packages/island/src/molecules/page-header/types.ts create mode 100644 packages/island/src/molecules/page-header/variants.ts create mode 100644 packages/island/src/molecules/pinned-footer/PinnedFooter.tsx create mode 100644 packages/island/src/molecules/pinned-footer/constants.ts create mode 100644 packages/island/src/molecules/pinned-footer/index.ts create mode 100644 packages/island/src/molecules/pinned-footer/types.ts create mode 100644 packages/island/src/molecules/pinned-footer/variants.ts create mode 100644 packages/island/src/molecules/result-panel/ResultPanel.tsx create mode 100644 packages/island/src/molecules/result-panel/constants.ts create mode 100644 packages/island/src/molecules/result-panel/index.ts create mode 100644 packages/island/src/molecules/result-panel/types.ts create mode 100644 packages/island/src/molecules/result-panel/variants.ts create mode 100644 packages/island/src/molecules/search-field/SearchField.tsx create mode 100644 packages/island/src/molecules/search-field/index.ts create mode 100644 packages/island/src/molecules/search-field/types.ts create mode 100644 packages/island/src/molecules/search-field/variants.ts create mode 100644 packages/island/src/molecules/section-title/SectionTitle.tsx create mode 100644 packages/island/src/molecules/section-title/index.ts create mode 100644 packages/island/src/molecules/section-title/types.ts create mode 100644 packages/island/src/molecules/section-title/variants.ts create mode 100644 packages/island/src/molecules/stat-tile/StatTile.tsx create mode 100644 packages/island/src/molecules/stat-tile/index.ts create mode 100644 packages/island/src/molecules/stat-tile/types.ts create mode 100644 packages/island/src/molecules/stat-tile/variants.ts create mode 100644 packages/island/src/molecules/timeline/Timeline.tsx create mode 100644 packages/island/src/molecules/timeline/TimelineItem.tsx create mode 100644 packages/island/src/molecules/timeline/index.ts create mode 100644 packages/island/src/molecules/timeline/types.ts create mode 100644 packages/island/src/molecules/timeline/variants.ts create mode 100644 packages/island/src/molecules/toast/ToastPlacementMarker.tsx create mode 100644 packages/island/src/molecules/toast/hooks/use-toast-placement.ts create mode 100644 packages/island/src/molecules/toast/placement-store.ts create mode 100644 packages/island/src/organisms/analyst-card/AnalystCard.tsx create mode 100644 packages/island/src/organisms/analyst-card/components/AnalystStats.tsx create mode 100644 packages/island/src/organisms/analyst-card/constants.ts create mode 100644 packages/island/src/organisms/analyst-card/index.ts create mode 100644 packages/island/src/organisms/analyst-card/types.ts create mode 100644 packages/island/src/organisms/analyst-card/utils.ts create mode 100644 packages/island/src/organisms/prediction-card/components/CloseReasonRow.tsx diff --git a/packages/island/src/atoms/avatar/constants.ts b/packages/island/src/atoms/avatar/constants.ts index 80823f8..516a6fe 100644 --- a/packages/island/src/atoms/avatar/constants.ts +++ b/packages/island/src/atoms/avatar/constants.ts @@ -5,23 +5,26 @@ import type { AvatarSize } from './types'; export const AVATAR_PX: Record = { sm: 32, md: 40, - lg: 56, - xl: 80, + lg: 52, + xl: 72, '2xl': 96, + xxl: 96, }; export const AVATAR_INITIAL_VARIANT: Record = { sm: 'label', md: 'body-md', - lg: 'heading-sm', + lg: 'heading-md', xl: 'heading-lg', '2xl': 'display', + xxl: 'display', }; export const AVATAR_MARK_PX: Record = { sm: 12, md: 14, lg: 18, - xl: 22, + xl: 20, '2xl': 24, + xxl: 24, }; diff --git a/packages/island/src/atoms/avatar/variants.ts b/packages/island/src/atoms/avatar/variants.ts index b962df8..ed8085b 100644 --- a/packages/island/src/atoms/avatar/variants.ts +++ b/packages/island/src/atoms/avatar/variants.ts @@ -10,12 +10,14 @@ export const avatarVariants = cva( sm: 'size-8', /** Post headers, subscription cards, list rows. */ md: 'size-10', - /** Sheet and checkout headers. */ - lg: 'size-14', - /** The channel profile header. */ - xl: 'size-20', - /** The profile photo field. */ + /** Analyst cards, sheet and checkout headers (DS lg, 52px). */ + lg: 'size-13', + /** The channel header (DS xl, 72px). */ + xl: 'size-18', + /** The profile photo field (96px). */ '2xl': 'size-24', + /** The DS name for `2xl` (96px). */ + xxl: 'size-24', }, /** An account that can't be used, such as a suspended creator's own avatar: no brand colour. */ muted: { diff --git a/packages/island/src/atoms/chip/Chip.tsx b/packages/island/src/atoms/chip/Chip.tsx index 24ac463..dd55f87 100644 --- a/packages/island/src/atoms/chip/Chip.tsx +++ b/packages/island/src/atoms/chip/Chip.tsx @@ -27,7 +27,7 @@ export function Chip({ {...props} > {selected && } - + {children} diff --git a/packages/island/src/atoms/chip/index.ts b/packages/island/src/atoms/chip/index.ts index 5aec666..76b74b1 100644 --- a/packages/island/src/atoms/chip/index.ts +++ b/packages/island/src/atoms/chip/index.ts @@ -1,3 +1,3 @@ export { Chip } from './Chip'; export type { ChipProps, ChipSize } from './types'; -export { chipVariants } from './variants'; +export { chipRowVariants, chipVariants } from './variants'; diff --git a/packages/island/src/atoms/chip/variants.ts b/packages/island/src/atoms/chip/variants.ts index d08c536..d066406 100644 --- a/packages/island/src/atoms/chip/variants.ts +++ b/packages/island/src/atoms/chip/variants.ts @@ -1,20 +1,35 @@ import { cva } from 'class-variance-authority'; -/** A pill you press to pick one of many, such as a market; a set sits in a wrapping row. */ +/** + * A pill you press to pick one of many, such as a market; a set sits in a wrapping row (DS Chips). + * Off, it is white with a `border-default` outline; on, filled brand. 15/600, 14 at `sm`. + */ export const chipVariants = cva( - 'rounded-full border px-4 whitespace-nowrap transition-colors duration-120 ease-standard focus-visible:focus-ring actionable:cursor-pointer disabled:frozen', + 'rounded-full border px-4 font-semibold whitespace-nowrap transition-colors duration-120 ease-standard focus-visible:focus-ring actionable:cursor-pointer disabled:frozen', { variants: { selected: { true: 'border-action-primary bg-action-primary text-text-on-action actionable:hover:bg-action-primary-hover', false: - 'border-transparent bg-action-primary-muted text-action-primary-text actionable:hover:border-action-primary', + 'border-border-default bg-surface text-text-primary actionable:hover:border-text-secondary actionable:hover:bg-surface-hover', }, size: { - sm: 'min-h-control-sm px-3.5', - md: 'min-h-control-md', + sm: 'min-h-control-sm px-3.5 text-body-sm leading-6', + md: 'min-h-control-md text-[0.9375rem] leading-6', }, }, defaultVariants: { selected: false, size: 'md' }, }, ); + +/** A set of chips: wrapping rows, or one row that scrolls sideways (DS `scroll`). */ +export const chipRowVariants = cva('', { + variants: { + scroll: { + // The 4px padding keeps each chip's focus ring inside the scroller's clip. + true: '-m-1 overflow-x-auto p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden', + false: '', + }, + }, + defaultVariants: { scroll: false }, +}); diff --git a/packages/island/src/atoms/icon/icon-names.ts b/packages/island/src/atoms/icon/icon-names.ts index 3320355..7c55d2d 100644 --- a/packages/island/src/atoms/icon/icon-names.ts +++ b/packages/island/src/atoms/icon/icon-names.ts @@ -18,14 +18,17 @@ export const ICON_NAMES = [ 'chevron-down', 'chevron-left', 'chevron-right', + 'chevron-up', 'clock', 'close', 'copy', 'dashboard', 'download', 'edit', + 'expand', 'external', 'eye', + 'file', 'filter', 'flag', 'grip', @@ -43,12 +46,16 @@ export const ICON_NAMES = [ 'minus', 'more', 'pause', + 'phone', + 'plus-square', 'plus', 'receipt', 'refresh', 'search-x', 'search', 'server', + 'settings', + 'share-ios', 'share', 'shield-check', 'sort', diff --git a/packages/island/src/atoms/select/Select.tsx b/packages/island/src/atoms/select/Select.tsx index 638b64e..01b3146 100644 --- a/packages/island/src/atoms/select/Select.tsx +++ b/packages/island/src/atoms/select/Select.tsx @@ -8,12 +8,14 @@ import { Typography } from '../typography'; import type { SelectProps } from './types'; /** - * A labelled native select, 44px high. On phones the system draws its own wheel or list, so a - * date or time picker built from these needs no script of its own. + * A labelled native select with the DS SelectField look: 48px, 16px padding, an optional leading + * icon and the chevron at the end. On phones the system draws its own wheel or list, so a date or + * time picker built from these needs no script of its own (0035). */ export function Select({ label, options, + icon, className, id, ...props @@ -36,10 +38,19 @@ export function Select({ {label} + {icon && ( + + )} {options.map((option) => ( @@ -50,8 +61,7 @@ export function Select({ diff --git a/packages/island/src/atoms/select/types.ts b/packages/island/src/atoms/select/types.ts index 94e0cac..f4b0647 100644 --- a/packages/island/src/atoms/select/types.ts +++ b/packages/island/src/atoms/select/types.ts @@ -1,9 +1,13 @@ import type { ComponentPropsWithRef, ReactNode } from 'react'; +import type { IconName } from '../icon'; + export type SelectOption = { value: string; label: ReactNode }; export type SelectProps = Omit, 'children'> & { /** The visible label above the control, such as «روز». */ label: ReactNode; options: readonly SelectOption[]; + /** A 20px icon at the start of the control, such as `clock` (DS SelectField). */ + icon?: IconName; }; diff --git a/packages/island/src/atoms/switch/Switch.tsx b/packages/island/src/atoms/switch/Switch.tsx index 2ab8f39..2ae83bd 100644 --- a/packages/island/src/atoms/switch/Switch.tsx +++ b/packages/island/src/atoms/switch/Switch.tsx @@ -1,7 +1,10 @@ 'use client'; +import { useId } from 'react'; + import { Element } from '../../primitives/element'; import { cn } from '../../tools/cn'; +import { FlexBox } from '../flex-box'; import { Typography } from '../typography'; import type { SwitchProps } from './types'; import { switchKnobVariants, switchTrackVariants } from './variants'; @@ -16,10 +19,15 @@ export function Switch({ onCheckedChange, locked = false, children, + description, className, onClick, ...props }: SwitchProps) { + const labelId = useId(); + const descriptionId = useId(); + const hasText = children != null || description != null; + return ( { onClick?.(event); if (!locked && !event.defaultPrevented) onCheckedChange?.(!checked); @@ -36,15 +49,38 @@ export function Switch({ locked ? 'cursor-not-allowed opacity-(--opacity-dimmed)' : 'cursor-pointer', - children && 'justify-between text-start', + hasText && 'justify-between text-start', className, )} {...props} > - {children && ( - - {children} - + {hasText && ( + + {children != null && ( + + {children} + + )} + {description != null && ( + + {description} + + )} + )} + + diff --git a/packages/island/src/icons/expand.svg b/packages/island/src/icons/expand.svg new file mode 100644 index 0000000..9eef56f --- /dev/null +++ b/packages/island/src/icons/expand.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/island/src/icons/file.svg b/packages/island/src/icons/file.svg new file mode 100644 index 0000000..9d3de01 --- /dev/null +++ b/packages/island/src/icons/file.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/island/src/icons/phone.svg b/packages/island/src/icons/phone.svg new file mode 100644 index 0000000..451e3f5 --- /dev/null +++ b/packages/island/src/icons/phone.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/island/src/icons/plus-square.svg b/packages/island/src/icons/plus-square.svg new file mode 100644 index 0000000..849ebf0 --- /dev/null +++ b/packages/island/src/icons/plus-square.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/island/src/icons/settings.svg b/packages/island/src/icons/settings.svg new file mode 100644 index 0000000..c84060d --- /dev/null +++ b/packages/island/src/icons/settings.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/island/src/icons/share-ios.svg b/packages/island/src/icons/share-ios.svg new file mode 100644 index 0000000..2603c4e --- /dev/null +++ b/packages/island/src/icons/share-ios.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/island/src/index.ts b/packages/island/src/index.ts index 02535a7..fc6cb2b 100644 --- a/packages/island/src/index.ts +++ b/packages/island/src/index.ts @@ -11,7 +11,7 @@ export type { } from './atoms/button'; export { Checkbox, checkboxVariants } from './atoms/checkbox'; export type { CheckboxProps } from './atoms/checkbox'; -export { Chip, chipVariants } from './atoms/chip'; +export { Chip, chipRowVariants, chipVariants } from './atoms/chip'; export type { ChipProps, ChipSize } from './atoms/chip'; export { CountBadge } from './atoms/count-badge'; export type { CountBadgeProps } from './atoms/count-badge'; @@ -109,6 +109,15 @@ export type { TypographyProps, TypographyVariant, } from './atoms/typography'; +export { + AvatarStack, + avatarStackFaceVariants, + avatarStackVariants, +} from './molecules/avatar-stack'; +export type { + AvatarStackItem, + AvatarStackProps, +} from './molecules/avatar-stack'; export { AvatarField } from './molecules/avatar-field'; export type { AvatarFieldLabels, @@ -125,8 +134,19 @@ export { ChipGroup } from './molecules/chip-group'; export type { ChipGroupOption, ChipGroupProps } from './molecules/chip-group'; export { ChoiceCard, choiceCardVariants } from './molecules/choice-card'; export type { ChoiceCardProps } from './molecules/choice-card'; -export { DetailRow, detailRowVariants } from './molecules/detail-row'; -export type { DetailRowProps } from './molecules/detail-row'; +export { + DetailRow, + detailRowVariants, + detailValueVariants, +} from './molecules/detail-row'; +export type { DetailRowProps, DetailRowTone } from './molecules/detail-row'; +export { CodeInput, codeInputButtonVariants } from './molecules/code-input'; +export type { + CodeInputLabels, + CodeInputProps, + CodeInputSource, + CodeInputStatus, +} from './molecules/code-input'; export { EmptyState } from './molecules/empty-state'; export type { EmptyStateProps, EmptyStateTone } from './molecules/empty-state'; export { ERROR_KIND_STYLES, ErrorState } from './molecules/error-state'; @@ -142,10 +162,31 @@ export { FormSection } from './molecules/form-section'; export type { FormSectionProps } from './molecules/form-section'; export { InfoTip, infoTipVariants } from './molecules/info-tip'; export type { InfoTipProps } from './molecules/info-tip'; +export { KeyValue, keyValueVariants } from './molecules/key-value'; +export type { KeyValueProps, KeyValueTone } from './molecules/key-value'; +export { + List, + ListRow, + listHeaderVariants, + listItemsVariants, + listRowIconVariants, + listRowVariants, + listVariants, +} from './molecules/list-row'; +export type { + ListProps, + ListRowAsButtonProps, + ListRowAsLinkProps, + ListRowIconTone, + ListRowProps, + ListTone, +} from './molecules/list-row'; export { LockedTeaser } from './molecules/locked-teaser'; export type { LockedTeaserProps } from './molecules/locked-teaser'; export { MediaCarousel } from './molecules/media-carousel'; export type { MediaCarouselProps, MediaItem } from './molecules/media-carousel'; +export { Meter, meterBarVariants } from './molecules/meter'; +export type { MeterProps, MeterTone } from './molecules/meter'; export { Modal } from './molecules/modal'; export type { ModalProps, ModalSize } from './molecules/modal'; export { @@ -157,6 +198,17 @@ export type { NetworkStatusProps, } from './molecules/network-status'; export { OtpInput } from './molecules/otp-input'; +export { PageHeader, pageHeaderTitleVariants } from './molecules/page-header'; +export type { PageHeaderProps, PageHeaderSize } from './molecules/page-header'; +export { + PINNED_FOOTER_TOAST_OFFSET, + PinnedFooter, + pinnedFooterVariants, +} from './molecules/pinned-footer'; +export type { + PinnedFooterLayout, + PinnedFooterProps, +} from './molecules/pinned-footer'; export type { OtpInputProps, OtpStatus } from './molecules/otp-input'; export { ResendCode } from './molecules/resend-code'; export type { @@ -164,13 +216,30 @@ export type { ResendCodeProps, ResendStatus, } from './molecules/resend-code'; +export { + RESULT_PANEL_ICONS, + ResultPanel, + resultPanelIconVariants, +} from './molecules/result-panel'; +export type { + ResultPanelProps, + ResultPanelTone, +} from './molecules/result-panel'; export { SampleFrame, sampleTagVariants } from './molecules/sample-frame'; +export { + SearchField, + searchFieldInputVariants, + searchFieldVariants, +} from './molecules/search-field'; +export type { SearchFieldProps } from './molecules/search-field'; export type { SampleFrameProps } from './molecules/sample-frame'; export { SectionHeading, sectionHeadingVariants, } from './molecules/section-heading'; export type { SectionHeadingProps } from './molecules/section-heading'; +export { SectionTitle, sectionTitleVariants } from './molecules/section-title'; +export type { SectionTitleProps } from './molecules/section-title'; export { SegmentedChoice, segmentedChoiceOptionVariants, @@ -180,6 +249,7 @@ export type { SegmentedChoiceOption, SegmentedChoiceProps, SegmentedChoiceSize, + SegmentedChoiceTone, SegmentedChoiceTrack, } from './molecules/segmented-choice'; export { Sheet } from './molecules/sheet'; @@ -189,9 +259,31 @@ export type { StateMessageProps, StateMessageSize, } from './molecules/state-message'; +export { + StatTile, + statTileValueVariants, + statTileVariants, +} from './molecules/stat-tile'; +export type { + StatTileProps, + StatTileTone, + StatTileValueTone, +} from './molecules/stat-tile'; export { StepProgress } from './molecules/step-progress'; export type { StepProgressProps } from './molecules/step-progress'; export { TabLinks } from './molecules/tab-links'; +export { + Timeline, + TimelineItem, + timelineDotVariants, + timelineItemVariants, + timelineVariants, +} from './molecules/timeline'; +export type { + TimelineItemProps, + TimelineProps, + TimelineTone, +} from './molecules/timeline'; export type { TabLinkItem, TabLinksProps } from './molecules/tab-links'; export { TextInput, @@ -199,14 +291,32 @@ export { textInputControlVariants, } from './molecules/text-input'; export type { TextInputProps } from './molecules/text-input'; -export { dismissToast, showToast, Toast, Toaster } from './molecules/toast'; +export { + dismissToast, + showToast, + Toast, + TOAST_OFFSETS, + Toaster, + ToastPlacementMarker, + useToastPlacement, +} from './molecules/toast'; export type { + DeclaredToastPlacement, ShowToastOptions, ToastAction, ToasterProps, + ToastPlacement, + ToastPlacementMarkerProps, ToastProps, ToastTone, } from './molecules/toast'; +export { AnalystCard } from './organisms/analyst-card'; +export type { + AnalystCardAnalyst, + AnalystCardLabels, + AnalystCardProps, + AnalystCardStats, +} from './organisms/analyst-card'; export { CreatorStats } from './organisms/creator-stats'; export type { CreatorStatsData, @@ -233,6 +343,7 @@ export { PredictionCard } from './organisms/prediction-card'; export type { PredictionCardLabels, PredictionCardProps, + PredictionCloseReason, PredictionData, PredictionDirection, PredictionOutcome, diff --git a/packages/island/src/molecules/action-menu/ActionMenu.tsx b/packages/island/src/molecules/action-menu/ActionMenu.tsx index 5a9e032..4a6dea0 100644 --- a/packages/island/src/molecules/action-menu/ActionMenu.tsx +++ b/packages/island/src/molecules/action-menu/ActionMenu.tsx @@ -3,6 +3,7 @@ import { useEffect, useEffectEvent, useRef } from 'react'; import type { KeyboardEvent } from 'react'; +import { FlexBox } from '../../atoms/flex-box'; import { Element } from '../../primitives/element'; import { cn } from '../../tools/cn'; import { ActionMenuItem } from './components/ActionMenuItem'; @@ -11,8 +12,9 @@ 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 + * / «پیش‌بینی جدید», a post's share → «کپی لینک», or the desktop account menu with its identity + * `header`, links and a danger «خروج از حساب» after a separator. 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. @@ -22,10 +24,11 @@ export function ActionMenu({ onClose, items, label, + header, placement = 'below', className, }: ActionMenuProps) { - const ref = useRef(null); + const ref = useRef(null); const close = useEffectEvent(onClose); useEffect(() => { @@ -61,7 +64,7 @@ export function ActionMenu({ trigger?.focus(); }; - const onKeyDown = (event: KeyboardEvent) => { + const onKeyDown = (event: KeyboardEvent) => { const options = Array.from( ref.current?.querySelectorAll('[role="menuitem"]') ?? [], ); @@ -79,19 +82,33 @@ export function ActionMenu({ return ( - {items.map((item) => ( - - ))} + {header != null && ( + + {header} + + )} + + {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 index cbac0c8..cd68a84 100644 --- a/packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx +++ b/packages/island/src/molecules/action-menu/components/ActionMenuItem.tsx @@ -6,19 +6,19 @@ 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'; +import { actionMenuIconVariants, actionMenuItemVariants } from '../variants'; /** - * 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`. + * One destination or action: its icon in the brand colour (red on a danger item) and its name, a + * 48px row. A link navigates; a button closes the menu, then runs its `onSelect`. A separator + * before it starts a new group. */ export function ActionMenuItem({ href, label, icon, + tone = 'default', + separatorBefore = false, onSelect, onClose, }: ActionMenuItemProps) { @@ -27,44 +27,52 @@ export function ActionMenuItem({ {label} ); + const rowClass = actionMenuItemVariants({ tone }); return ( - - {href != null ? ( - - {content} - - ) : ( - { - onClose(); - onSelect?.(); - }} - alignItems="items-center" - gap="gap-3" - className={cn(ROW_CLASS, 'w-full cursor-pointer text-start')} - > - {content} - + <> + {separatorBefore && ( + + + )} - + + {href != null ? ( + + {content} + + ) : ( + { + onClose(); + onSelect?.(); + }} + alignItems="items-center" + gap="gap-3" + className={cn(rowClass, 'cursor-pointer')} + > + {content} + + )} + + ); } diff --git a/packages/island/src/molecules/action-menu/types.ts b/packages/island/src/molecules/action-menu/types.ts index 741c5a4..30eb9fd 100644 --- a/packages/island/src/molecules/action-menu/types.ts +++ b/packages/island/src/molecules/action-menu/types.ts @@ -1,9 +1,15 @@ +import type { ReactNode } from 'react'; + 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; + /** danger: a destructive choice in red, such as «خروج از حساب». */ + tone?: 'default' | 'danger'; + /** A hairline above the item, which starts a new group, such as sign-out under the links. */ + separatorBefore?: boolean; } & ( | { href: string; onSelect?: never } | { @@ -20,6 +26,11 @@ export type ActionMenuProps = { items: readonly ActionMenuItem[]; /** The menu's accessible name, such as «انتشار». */ label: string; + /** + * Shown above the items over a hairline, never focused: who the menu belongs to, such as the + * account's avatar, name and @username. + */ + header?: ReactNode; /** above: over a bottom-nav button. below: under a header button. */ placement?: 'above' | 'below'; className?: string; diff --git a/packages/island/src/molecules/action-menu/variants.ts b/packages/island/src/molecules/action-menu/variants.ts index 8eee572..df0e4eb 100644 --- a/packages/island/src/molecules/action-menu/variants.ts +++ b/packages/island/src/molecules/action-menu/variants.ts @@ -2,7 +2,7 @@ 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', + 'absolute z-menu min-w-55 rounded-lg border border-border-subtle bg-surface-raised p-1.5 shadow-2', { variants: { placement: { @@ -13,3 +13,28 @@ export const actionMenuVariants = cva( defaultVariants: { placement: 'below' }, }, ); + +/** A 48px row, 16/600; a link row and a button row look the same. */ +export const actionMenuItemVariants = cva( + 'min-h-12 w-full rounded-md px-3 text-start no-underline outline-none hover:bg-surface-sunken focus-visible:bg-surface-sunken focus-visible:focus-ring', + { + variants: { + tone: { + default: 'text-text-primary', + danger: 'text-danger-text', + }, + }, + defaultVariants: { tone: 'default' }, + }, +); + +/** The item's icon: the brand colour, or red on a danger item. */ +export const actionMenuIconVariants = cva('flex-none', { + variants: { + tone: { + default: 'text-action-primary-text', + danger: 'text-danger-text', + }, + }, + defaultVariants: { tone: 'default' }, +}); diff --git a/packages/island/src/molecules/avatar-stack/AvatarStack.tsx b/packages/island/src/molecules/avatar-stack/AvatarStack.tsx new file mode 100644 index 0000000..aba14af --- /dev/null +++ b/packages/island/src/molecules/avatar-stack/AvatarStack.tsx @@ -0,0 +1,113 @@ +import { number } from '@lumina/tools/format'; +import NextLink from 'next/link'; + +import { Avatar } from '../../atoms/avatar'; +import { FlexBox } from '../../atoms/flex-box'; +import { GridBox } from '../../atoms/grid-box'; +import { Icon } from '../../atoms/icon'; +import { Typography } from '../../atoms/typography'; +import { cn } from '../../tools/cn'; +import type { AvatarStackProps } from './types'; +import { avatarStackFaceVariants, avatarStackVariants } from './variants'; + +/** + * Overlapping 32px avatars with «+N» for the rest (DS AvatarStack). With a `title` it is the strip + * on خانه, «تحلیلگران منتخب», and with `href` the whole strip is a link. + */ +export function AvatarStack({ + avatars, + max = 4, + title, + subtitle, + href, + label, + className, +}: AvatarStackProps) { + const shown = avatars.slice(0, max); + const rest = avatars.length - shown.length; + const strip = title != null; + + const faces = ( + + {shown.map((avatar, index) => ( + 0 })} + /> + ))} + {rest > 0 && ( + 0 }), + 'size-8 bg-surface-sunken text-text-secondary', + )} + > + + {`+${number(rest)}`} + + + )} + + ); + + if (!strip) return faces; + + const content = ( + <> + {faces} + + + {title} + + {subtitle != null && ( + + {subtitle} + + )} + + {href && ( + + )} + + ); + const classes = cn( + avatarStackVariants({ strip: true, link: href != null }), + className, + ); + + return href ? ( + + {content} + + ) : ( + + {content} + + ); +} diff --git a/packages/island/src/molecules/avatar-stack/index.ts b/packages/island/src/molecules/avatar-stack/index.ts new file mode 100644 index 0000000..b46448e --- /dev/null +++ b/packages/island/src/molecules/avatar-stack/index.ts @@ -0,0 +1,3 @@ +export { AvatarStack } from './AvatarStack'; +export type { AvatarStackItem, AvatarStackProps } from './types'; +export { avatarStackFaceVariants, avatarStackVariants } from './variants'; diff --git a/packages/island/src/molecules/avatar-stack/types.ts b/packages/island/src/molecules/avatar-stack/types.ts new file mode 100644 index 0000000..3891644 --- /dev/null +++ b/packages/island/src/molecules/avatar-stack/types.ts @@ -0,0 +1,23 @@ +import type { ReactNode } from 'react'; + +export type AvatarStackItem = { + /** The username: unique in the stack, and the placeholder's letter. */ + name: string; + src?: string | null; +}; + +export type AvatarStackProps = { + /** In order; the first `max` show, the rest count as «+N». */ + avatars: readonly AvatarStackItem[]; + /** 4 by default. */ + max?: number; + /** Makes it the DS strip, such as «تحلیلگران منتخب». */ + title?: ReactNode; + /** Under the title, such as «۱۲ تحلیلگر فعال». */ + subtitle?: ReactNode; + /** The strip opens this page, with a chevron. */ + href?: string; + /** The faces' accessible name when there is no title, such as «۵ مشترک». */ + label?: string; + className?: string; +}; diff --git a/packages/island/src/molecules/avatar-stack/variants.ts b/packages/island/src/molecules/avatar-stack/variants.ts new file mode 100644 index 0000000..e68fe6c --- /dev/null +++ b/packages/island/src/molecules/avatar-stack/variants.ts @@ -0,0 +1,27 @@ +import { cva } from 'class-variance-authority'; + +/** + * With a title, the DS AvatarStack strip: a bordered radius-lg row, at least 56px, that opens a + * list as a link. Without one, only the faces. + */ +export const avatarStackVariants = cva('min-w-0', { + variants: { + strip: { + true: 'min-h-14 rounded-lg border border-border-subtle bg-surface px-4 py-2 text-text-primary no-underline', + false: '', + }, + link: { + true: 'transition-[border-color,box-shadow] duration-120 ease-standard focus-visible:focus-ring hover:border-border-strong hover:shadow-1', + false: '', + }, + }, + defaultVariants: { strip: false, link: false }, +}); + +/** One 32px face, ringed in the surface so overlapping faces stay apart; each after the first tucks 10px under. */ +export const avatarStackFaceVariants = cva('rounded-full ring-2 ring-surface', { + variants: { + overlap: { true: '-ms-2.5', false: '' }, + }, + defaultVariants: { overlap: false }, +}); diff --git a/packages/island/src/molecules/chip-group/ChipGroup.tsx b/packages/island/src/molecules/chip-group/ChipGroup.tsx index 7bc3e9b..49f0e70 100644 --- a/packages/island/src/molecules/chip-group/ChipGroup.tsx +++ b/packages/island/src/molecules/chip-group/ChipGroup.tsx @@ -1,8 +1,9 @@ import { useId } from 'react'; -import { Chip } from '../../atoms/chip'; +import { Chip, chipRowVariants } from '../../atoms/chip'; import { FieldError } from '../../atoms/field-error'; import { FlexBox } from '../../atoms/flex-box'; +import { cn } from '../../tools/cn'; import type { ChipGroupProps } from './types'; /** @@ -16,6 +17,7 @@ export function ChipGroup({ label, error, size = 'md', + scroll = false, disabled = false, ref, className, @@ -31,15 +33,19 @@ export function ChipGroup({ tabIndex={-1} aria-label={label} aria-describedby={hasError ? errorId : undefined} - wrap="flex-wrap" + wrap={scroll ? 'flex-nowrap' : 'flex-wrap'} gap="gap-2" - className="rounded-md outline-none" + className={cn( + 'min-w-0 rounded-md outline-none', + chipRowVariants({ scroll }), + )} > {options.map((option) => ( onToggle(option.value)} > diff --git a/packages/island/src/molecules/chip-group/types.ts b/packages/island/src/molecules/chip-group/types.ts index 02a69ea..bee7927 100644 --- a/packages/island/src/molecules/chip-group/types.ts +++ b/packages/island/src/molecules/chip-group/types.ts @@ -15,6 +15,8 @@ export type ChipGroupProps = { /** Under the chips, such as «انتخاب حداقل یک تخصص الزامی است.». */ error?: ReactNode; size?: ChipSize; + /** One row that scrolls sideways instead of wrapping. */ + scroll?: boolean; disabled?: boolean; /** Reaches the fieldset, which takes focus (and scrolls into view) for a form error. */ ref?: Ref; diff --git a/packages/island/src/molecules/code-input/CodeInput.tsx b/packages/island/src/molecules/code-input/CodeInput.tsx new file mode 100644 index 0000000..fa67b90 --- /dev/null +++ b/packages/island/src/molecules/code-input/CodeInput.tsx @@ -0,0 +1,163 @@ +'use client'; + +import { useId, useState } from 'react'; + +import { Button } from '../../atoms/button'; +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 { textInputBoxVariants, textInputControlVariants } from '../text-input'; +import { CODE_INPUT_BOX_STATE } from './constants'; +import type { CodeInputProps } from './types'; +import { codeInputButtonVariants } from './variants'; + +/** + * An invite code with its own «ثبت» (DS CodeInput): left to right, the button checks the code and + * so does Enter, which never submits the outer form. Checking locks the field with a spinner; + * a valid code turns green and read-only, and the button becomes «تغییر». The status and every + * text come from the caller. + */ +export function CodeInput({ + label, + labels, + status = 'idle', + source = 'typed', + value, + defaultValue = '', + onValueChange, + onCheck, + onEdit, + onBlur, + hint, + message, + placeholder, + frozen = false, + ref, + id: idProp, + name, + className, +}: CodeInputProps) { + const autoId = useId(); + const id = idProp ?? autoId; + const messageId = `${id}-message`; + const [ownValue, setOwnValue] = useState(defaultValue); + const code = (value ?? ownValue).trim(); + const isValid = status === 'valid'; + const isChecking = status === 'checking'; + const isLocked = status === 'locked'; + const isError = status === 'invalid' || status === 'error'; + const isFixed = isValid || isChecking || isLocked; + + const shown = + message ?? + (isValid && source === 'link' + ? (labels.validFromLink ?? labels.valid) + : status === 'idle' + ? hint + : labels[status]); + + const check = () => { + if (!isFixed && !frozen && code !== '') onCheck(code); + }; + + return ( + + + {label} + + + + { + if (value === undefined) setOwnValue(event.target.value); + onValueChange?.(event.target.value); + }} + onBlur={() => onBlur?.(code)} + onKeyDown={(event) => { + if (event.key !== 'Enter') return; + event.preventDefault(); + check(); + }} + className={textInputControlVariants({ + ltr: true, + locked: isChecking || isLocked, + })} + /> + {isValid ? ( + + ) : isError ? ( + + ) : isLocked ? ( + + ) : null} + + {isValid ? ( + + ) : ( + !isLocked && ( + + ) + )} + + {shown != null && ( + + {shown} + + )} + + ); +} diff --git a/packages/island/src/molecules/code-input/constants.ts b/packages/island/src/molecules/code-input/constants.ts new file mode 100644 index 0000000..cdd8538 --- /dev/null +++ b/packages/island/src/molecules/code-input/constants.ts @@ -0,0 +1,11 @@ +import type { CodeInputStatus } from './types'; + +/** The box's frame for each status (TextInput's box states). */ +export const CODE_INPUT_BOX_STATE = { + idle: 'default', + checking: 'locked', + valid: 'valid', + invalid: 'invalid', + error: 'invalid', + locked: 'locked', +} as const satisfies Record; diff --git a/packages/island/src/molecules/code-input/index.ts b/packages/island/src/molecules/code-input/index.ts new file mode 100644 index 0000000..ee442db --- /dev/null +++ b/packages/island/src/molecules/code-input/index.ts @@ -0,0 +1,8 @@ +export { CodeInput } from './CodeInput'; +export type { + CodeInputLabels, + CodeInputProps, + CodeInputSource, + CodeInputStatus, +} from './types'; +export { codeInputButtonVariants } from './variants'; diff --git a/packages/island/src/molecules/code-input/types.ts b/packages/island/src/molecules/code-input/types.ts new file mode 100644 index 0000000..8e5cbe0 --- /dev/null +++ b/packages/island/src/molecules/code-input/types.ts @@ -0,0 +1,66 @@ +import type { ReactNode, Ref } from 'react'; + +/** + * idle: typed, not checked. checking: «ثبت» was pressed. valid: accepted, read-only until «تغییر». + * invalid: the code doesn't exist. error: the check failed. locked: fixed for this flow. + */ +export type CodeInputStatus = + | 'idle' + | 'checking' + | 'valid' + | 'invalid' + | 'error' + | 'locked'; + +/** Where the code came from: typed here, or applied from an invite link. */ +export type CodeInputSource = 'typed' | 'link'; + +/** Every text the field shows, from the translations. A state without its text shows none. */ +export type CodeInputLabels = { + /** The button that checks the code: «ثبت». */ + check: ReactNode; + /** The button on a valid code that unlocks the field: «تغییر». */ + change: ReactNode; + /** «در حال بررسی کد…». */ + checking?: ReactNode; + /** «کد دعوت معتبر است.». */ + valid?: ReactNode; + /** A valid code from an invite link: «کد دعوت از لینک دعوت اعمال شد.». */ + validFromLink?: ReactNode; + /** «کد دعوت وارد‌شده معتبر نیست.». */ + invalid?: ReactNode; + /** «بررسی کد انجام نشد. دوباره «ثبت» را بزنید.». */ + error?: ReactNode; + /** Why a locked code can't change. */ + locked?: ReactNode; +}; + +export type CodeInputProps = { + /** «کد دعوت». */ + label: ReactNode; + labels: CodeInputLabels; + status?: CodeInputStatus; + source?: CodeInputSource; + /** Controlled: the code now. Leave it out to let the field keep its own. */ + value?: string; + defaultValue?: string; + onValueChange?: (value: string) => void; + /** «ثبت» or Enter, with the trimmed code; never while checking, valid, locked or empty. */ + onCheck: (code: string) => void; + /** «تغییر» on a valid code: the caller sets the status back to idle. */ + onEdit?: () => void; + /** Leaving the field, with the trimmed code, such as for a quiet check. */ + onBlur?: (code: string) => void; + /** Under the field while idle. */ + hint?: ReactNode; + /** Replaces the status's text. */ + message?: ReactNode; + placeholder?: string; + /** Visible but unusable now, at 40%. */ + frozen?: boolean; + /** Reaches the input, such as react-hook-form's field ref. */ + ref?: Ref; + id?: string; + name?: string; + className?: string; +}; diff --git a/packages/island/src/molecules/code-input/variants.ts b/packages/island/src/molecules/code-input/variants.ts new file mode 100644 index 0000000..19337b6 --- /dev/null +++ b/packages/island/src/molecules/code-input/variants.ts @@ -0,0 +1,4 @@ +import { cva } from 'class-variance-authority'; + +/** «ثبت» and «تغییر» as tall as the field beside them (48px). */ +export const codeInputButtonVariants = cva('min-h-input-height flex-none'); diff --git a/packages/island/src/molecules/detail-row/DetailRow.tsx b/packages/island/src/molecules/detail-row/DetailRow.tsx index 5cae7b7..4dc042d 100644 --- a/packages/island/src/molecules/detail-row/DetailRow.tsx +++ b/packages/island/src/molecules/detail-row/DetailRow.tsx @@ -1,29 +1,66 @@ +import { Button } from '../../atoms/button'; import { FlexBox } from '../../atoms/flex-box'; import { Typography } from '../../atoms/typography'; import { Element } from '../../primitives/element'; +import { cn } from '../../tools/cn'; import type { DetailRowProps } from './types'; -import { detailRowVariants } from './variants'; +import { detailRowVariants, detailValueVariants } from './variants'; /** - * One line of a `
`, such as a receipt or a payment's detail: the label at the start, its - * value at the end, on one baseline. + * One line of a `
` (DS KV), such as a receipt or a payment's detail: the key at the start in + * 13px secondary, its value at the end on one baseline. Put rows in a KeyValue for the DS group with + * hairlines, or in any `dl`. */ -export function DetailRow({ label, children, size }: DetailRowProps) { +export function DetailRow({ + label, + children, + size, + strong = false, + tone, + ltr = false, + copyLabel, + onCopy, + className, +}: DetailRowProps) { return ( - - - {label} - - - - {children} - + + {label} + + + {ltr ? ( + + {children} + + ) : ( + children + )} + {copyLabel && onCopy && ( + + )} + {!isUploading && ( +