@noix-dev/brix-vue 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/package.json +117 -3
- package/src/components/address-field/AddressField.vue +337 -0
- package/src/components/address-field/index.ts +1 -0
- package/src/components/appearance-picker/AppearancePicker.vue +502 -0
- package/src/components/appearance-picker/AppearanceSegment.vue +175 -0
- package/src/components/appearance-picker/index.ts +44 -0
- package/src/components/autofill/AutoFillDialog.vue +264 -0
- package/src/components/autofill/index.ts +1 -0
- package/src/components/badge/Badge.vue +23 -0
- package/src/components/badge/index.ts +106 -0
- package/src/components/build-stamp/BuildStamp.vue +62 -0
- package/src/components/build-stamp/index.ts +1 -0
- package/src/components/button/Button.vue +31 -0
- package/src/components/button/index.ts +122 -0
- package/src/components/card/Card.vue +29 -0
- package/src/components/card/CardAction.vue +17 -0
- package/src/components/card/CardContent.vue +14 -0
- package/src/components/card/CardDescription.vue +14 -0
- package/src/components/card/CardFooter.vue +22 -0
- package/src/components/card/CardHeader.vue +22 -0
- package/src/components/card/CardTitle.vue +29 -0
- package/src/components/card/index.ts +47 -0
- package/src/components/chart/BarChart.vue +123 -0
- package/src/components/chart/StackedBarChart.vue +149 -0
- package/src/components/chart/appearanceRevision.ts +22 -0
- package/src/components/chart/chartColor.ts +59 -0
- package/src/components/chart/index.ts +6 -0
- package/src/components/checkbox/Checkbox.vue +61 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/code-editor/CodeEditor.vue +352 -0
- package/src/components/code-editor/index.ts +9 -0
- package/src/components/code-editor/syntaxTheme.ts +110 -0
- package/src/components/colour-picker/ColourPicker.vue +421 -0
- package/src/components/colour-picker/index.ts +1 -0
- package/src/components/combobox/Combobox.vue +337 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/comments/CommentComposer.vue +302 -0
- package/src/components/comments/CommentMessage.vue +259 -0
- package/src/components/comments/CommentThread.vue +250 -0
- package/src/components/comments/commentBody.ts +185 -0
- package/src/components/comments/commentLevels.ts +139 -0
- package/src/components/comments/commentNode.ts +35 -0
- package/src/components/comments/composer.ts +20 -0
- package/src/components/comments/index.ts +29 -0
- package/src/components/confirm-dialog/ConfirmDialog.vue +153 -0
- package/src/components/confirm-dialog/index.ts +1 -0
- package/src/components/containers/Box.vue +42 -0
- package/src/components/containers/Section.vue +88 -0
- package/src/components/containers/SectionAction.vue +17 -0
- package/src/components/containers/SectionContent.vue +14 -0
- package/src/components/containers/SectionDescription.vue +14 -0
- package/src/components/containers/SectionHeader.vue +22 -0
- package/src/components/containers/SectionTitle.vue +17 -0
- package/src/components/containers/index.ts +9 -0
- package/src/components/data-table/ColumnMenu.vue +241 -0
- package/src/components/data-table/DataTable.vue +447 -0
- package/src/components/data-table/ExpandCaret.vue +34 -0
- package/src/components/data-table/SortableHead.vue +184 -0
- package/src/components/data-table/TableLoadingRow.vue +13 -0
- package/src/components/data-table/TableProgressRow.vue +26 -0
- package/src/components/data-table/columns.ts +13 -0
- package/src/components/data-table/index.ts +3 -0
- package/src/components/data-table/pinned.ts +19 -0
- package/src/components/data-table/rowActivation.ts +14 -0
- package/src/components/data-table/sort.ts +13 -0
- package/src/components/data-table/types.ts +23 -0
- package/src/components/date-picker/CalendarPanel.vue +432 -0
- package/src/components/date-picker/DateField.vue +293 -0
- package/src/components/date-picker/DatePicker.vue +147 -0
- package/src/components/date-picker/UntilDatePicker.vue +96 -0
- package/src/components/date-picker/dateFieldGuard.ts +87 -0
- package/src/components/date-picker/index.ts +4 -0
- package/src/components/date-picker/useDateField.ts +37 -0
- package/src/components/date-range-picker/DateRangePicker.vue +247 -0
- package/src/components/date-range-picker/index.ts +1 -0
- package/src/components/date-time-picker/DateTimePicker.vue +291 -0
- package/src/components/date-time-picker/index.ts +1 -0
- package/src/components/dialog/Dialog.vue +250 -0
- package/src/components/dialog/DialogSurface.vue +214 -0
- package/src/components/dialog/dialogEdges.ts +65 -0
- package/src/components/dialog/dialogSizes.ts +35 -0
- package/src/components/dialog/index.ts +12 -0
- package/src/components/dialog/toastHost.ts +18 -0
- package/src/components/dropdown/Dropdown.vue +101 -0
- package/src/components/dropdown/DropdownItems.vue +154 -0
- package/src/components/dropdown/dropdown.ts +64 -0
- package/src/components/dropdown/index.ts +2 -0
- package/src/components/file-preview/FilePreview.vue +78 -0
- package/src/components/file-preview/index.ts +1 -0
- package/src/components/file-upload/FileUpload.vue +234 -0
- package/src/components/file-upload/index.ts +1 -0
- package/src/components/filter-check-menu/FilterCheckMenu.vue +562 -0
- package/src/components/filter-check-menu/filterCheckOption.ts +10 -0
- package/src/components/filter-check-menu/index.ts +2 -0
- package/src/components/form-field/FormField.vue +74 -0
- package/src/components/form-field/index.ts +2 -0
- package/src/components/form-field/types.ts +5 -0
- package/src/components/frames/FrameCentred.vue +137 -0
- package/src/components/frames/FrameSidebar.vue +113 -0
- package/src/components/frames/FrameSplit.vue +109 -0
- package/src/components/frames/index.ts +3 -0
- package/src/components/icon/BellIcon.vue +27 -0
- package/src/components/icon/BoldIcon.vue +31 -0
- package/src/components/icon/CalendarDaysIcon.vue +33 -0
- package/src/components/icon/CheckIcon.vue +31 -0
- package/src/components/icon/ChevronDownIcon.vue +30 -0
- package/src/components/icon/ChevronLeftIcon.vue +31 -0
- package/src/components/icon/ChevronRightIcon.vue +31 -0
- package/src/components/icon/ChevronUpIcon.vue +30 -0
- package/src/components/icon/CircleAlertIcon.vue +29 -0
- package/src/components/icon/ClockIcon.vue +31 -0
- package/src/components/icon/Columns3Icon.vue +32 -0
- package/src/components/icon/FlipHorizontalIcon.vue +29 -0
- package/src/components/icon/ItalicIcon.vue +28 -0
- package/src/components/icon/LinkIcon.vue +27 -0
- package/src/components/icon/ListIcon.vue +29 -0
- package/src/components/icon/ListOrderedIcon.vue +28 -0
- package/src/components/icon/PenLineIcon.vue +31 -0
- package/src/components/icon/PlusIcon.vue +28 -0
- package/src/components/icon/RotateCcwIcon.vue +28 -0
- package/src/components/icon/RotateCwIcon.vue +28 -0
- package/src/components/icon/SearchIcon.vue +31 -0
- package/src/components/icon/StarIcon.vue +29 -0
- package/src/components/icon/TriangleAlertIcon.vue +29 -0
- package/src/components/icon/UnderlineIcon.vue +27 -0
- package/src/components/icon/Undo2Icon.vue +28 -0
- package/src/components/icon/XIcon.vue +31 -0
- package/src/components/icon/ZoomInIcon.vue +30 -0
- package/src/components/icon/ZoomOutIcon.vue +29 -0
- package/src/components/icon/index.ts +37 -0
- package/src/components/icon-picker/IconPicker.vue +560 -0
- package/src/components/icon-picker/index.ts +1 -0
- package/src/components/image-crop-dialog/CropRatioRow.vue +132 -0
- package/src/components/image-crop-dialog/CropVariantStrip.vue +277 -0
- package/src/components/image-crop-dialog/ImageCropDialog.vue +1541 -0
- package/src/components/image-crop-dialog/index.ts +16 -0
- package/src/components/image-upload/ImageUpload.vue +345 -0
- package/src/components/image-upload/index.ts +2 -0
- package/src/components/input/Input.vue +48 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/keycap/Keycap.vue +49 -0
- package/src/components/keycap/index.ts +1 -0
- package/src/components/label/Label.vue +26 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/menu/MenuCheckboxItem.vue +63 -0
- package/src/components/menu/MenuContent.vue +45 -0
- package/src/components/menu/MenuGroup.vue +22 -0
- package/src/components/menu/MenuItem.vue +34 -0
- package/src/components/menu/MenuLabel.vue +22 -0
- package/src/components/menu/MenuRadioGroup.vue +22 -0
- package/src/components/menu/MenuRadioItem.vue +50 -0
- package/src/components/menu/MenuRoot.vue +25 -0
- package/src/components/menu/MenuSeparator.vue +27 -0
- package/src/components/menu/MenuSub.vue +29 -0
- package/src/components/menu/MenuSubContent.vue +48 -0
- package/src/components/menu/MenuSubTrigger.vue +49 -0
- package/src/components/menu/MenuTrigger.vue +22 -0
- package/src/components/menu/index.ts +20 -0
- package/src/components/menu/menuClasses.ts +74 -0
- package/src/components/morph-select/MorphSelect.vue +150 -0
- package/src/components/morph-select/index.ts +1 -0
- package/src/components/nav/NavFlyout.vue +343 -0
- package/src/components/nav/NavGroup.vue +306 -0
- package/src/components/nav/NavItem.vue +243 -0
- package/src/components/nav/NavNodes.ts +66 -0
- package/src/components/nav/NavSection.vue +105 -0
- package/src/components/nav/NavSidebar.vue +137 -0
- package/src/components/nav/index.ts +5 -0
- package/src/components/nav/navChain.ts +112 -0
- package/src/components/nav/navClasses.ts +229 -0
- package/src/components/nav/navNode.ts +10 -0
- package/src/components/nav/navRegistry.ts +24 -0
- package/src/components/notification-list/NotificationList.vue +314 -0
- package/src/components/notification-list/index.ts +2 -0
- package/src/components/notification-list/notifications.ts +21 -0
- package/src/components/pagination/Pagination.vue +296 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pin-field/PinField.vue +332 -0
- package/src/components/pin-field/index.ts +1 -0
- package/src/components/popover-panel/PopoverPanel.vue +115 -0
- package/src/components/popover-panel/index.ts +5 -0
- package/src/components/rating/Rating.vue +201 -0
- package/src/components/rating/index.ts +1 -0
- package/src/components/record-avatar/RecordAvatar.vue +76 -0
- package/src/components/record-avatar/index.ts +1 -0
- package/src/components/result-window/ResultWindow.vue +399 -0
- package/src/components/result-window/index.ts +2 -0
- package/src/components/result-window/results.ts +75 -0
- package/src/components/rich-editor/RichEditor.vue +370 -0
- package/src/components/rich-editor/RichEditorLinkDialog.vue +133 -0
- package/src/components/rich-editor/index.ts +8 -0
- package/src/components/row-actions/RowActions.vue +262 -0
- package/src/components/row-actions/index.ts +2 -0
- package/src/components/row-actions/rowActions.ts +44 -0
- package/src/components/search-select/SearchSelect.vue +599 -0
- package/src/components/search-select/index.ts +2 -0
- package/src/components/search-select/types.ts +14 -0
- package/src/components/segmented-choice/SegmentedChoice.vue +136 -0
- package/src/components/segmented-choice/index.ts +2 -0
- package/src/components/segmented-choice/segmentedOption.ts +6 -0
- package/src/components/select/Select.vue +18 -0
- package/src/components/select/SelectContent.vue +73 -0
- package/src/components/select/SelectGroup.vue +21 -0
- package/src/components/select/SelectItem.vue +47 -0
- package/src/components/select/SelectItemText.vue +12 -0
- package/src/components/select/SelectLabel.vue +17 -0
- package/src/components/select/SelectScrollDownButton.vue +36 -0
- package/src/components/select/SelectScrollUpButton.vue +36 -0
- package/src/components/select/SelectSeparator.vue +19 -0
- package/src/components/select/SelectTrigger.vue +52 -0
- package/src/components/select/SelectValue.vue +12 -0
- package/src/components/select/index.ts +11 -0
- package/src/components/session/IdleTimer.vue +71 -0
- package/src/components/session/SessionDialogs.vue +177 -0
- package/src/components/session/index.ts +2 -0
- package/src/components/split-button/SplitButton.vue +122 -0
- package/src/components/split-button/index.ts +2 -0
- package/src/components/split-button/splitButtonItem.ts +7 -0
- package/src/components/switch/Switch.vue +60 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/table/Table.vue +51 -0
- package/src/components/table/TableBody.vue +14 -0
- package/src/components/table/TableCaption.vue +17 -0
- package/src/components/table/TableCell.vue +22 -0
- package/src/components/table/TableEmpty.vue +72 -0
- package/src/components/table/TableFooter.vue +17 -0
- package/src/components/table/TableHead.vue +22 -0
- package/src/components/table/TableHeader.vue +14 -0
- package/src/components/table/TableRow.vue +22 -0
- package/src/components/table/index.ts +9 -0
- package/src/components/tabs/Tabs.vue +173 -0
- package/src/components/tabs/index.ts +2 -0
- package/src/components/tabs/tabItem.ts +12 -0
- package/src/components/textarea/LimitedTextarea.vue +81 -0
- package/src/components/textarea/TextLimitCounter.vue +107 -0
- package/src/components/textarea/Textarea.vue +42 -0
- package/src/components/textarea/index.ts +4 -0
- package/src/components/textarea/textLimit.ts +43 -0
- package/src/components/time-picker/TimePicker.vue +522 -0
- package/src/components/time-picker/index.ts +1 -0
- package/src/components/toast/ToastHost.vue +276 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/update-notice/UpdateNotice.vue +103 -0
- package/src/components/update-notice/index.ts +1 -0
- package/src/components/user-menu/UserMenu.vue +154 -0
- package/src/components/user-menu/index.ts +1 -0
- package/src/index.ts +182 -0
- package/src/lib/cn.ts +21 -0
- package/src/lib/panelFocus.ts +65 -0
- package/src/lib/sessionMonitor.ts +390 -0
- package/src/lib/slotContent.ts +17 -0
- package/src/lib/updateCheck.ts +133 -0
- package/src/styles.css +82 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The class strings of one navigation row, read by `NavItem` and by the group's trigger row so
|
|
3
|
+
* the two cannot drift. It is also the one place to read the approved record's row values from.
|
|
4
|
+
*
|
|
5
|
+
* INK. A resting row is `--sidebar-foreground` on `--sidebar`; a current row is
|
|
6
|
+
* `--primary-on-wash` on `--sidebar-accent`. Both pairs are gated at 4.5:1 in
|
|
7
|
+
* `packages/tokens/src/contract.json` at THEME level only: a kingfisher accent set rebinds
|
|
8
|
+
* `--primary-on-wash` for its subtree and the gate does not walk accent sets (see `NavSection`
|
|
9
|
+
* for the figures). This module draws those role names and no fixed palette colour.
|
|
10
|
+
*
|
|
11
|
+
* OPACITY lives on the icon and never on the row. The contrast walk refuses a reading below
|
|
12
|
+
* opacity 1, so ink under an element opacity is ink no gate measures.
|
|
13
|
+
*
|
|
14
|
+
* THE FOCUS RING is `ring-ring`, deliberately NOT `ring-sidebar-ring`. The tidier-looking role
|
|
15
|
+
* reads 2.44 (graphite light, a hex value, so the same on both of the gate's paths) and 2.47
|
|
16
|
+
* (kingfisher light, on the indicator path, which is the one a focus ring travels; the pair path
|
|
17
|
+
* reads 2.48) against `--sidebar`, under the 3:1 a non-text indicator needs. `--ring` clears 3:1
|
|
18
|
+
* against `--sidebar`, the column itself, in all three themes and both modes (3.12 at worst, noix
|
|
19
|
+
* light). That holds for the UNFILLED row
|
|
20
|
+
* only: the ring is inset, so it is painted inside the border box and its ground is the row's
|
|
21
|
+
* own fill, and a hovered or current row is filled with `--sidebar-accent`, against which
|
|
22
|
+
* `--ring` reads 2.90 in noix light. That second ground is a recorded, unenforced entry in the
|
|
23
|
+
* contract (a palette decision, the owner's), not a claim that it clears. Swapping the role
|
|
24
|
+
* for `--sidebar-ring` would make the ring invisible in two themes' light mode, and no test
|
|
25
|
+
* can see a colour. `--sidebar-ring` stays unused for that recorded reason.
|
|
26
|
+
*
|
|
27
|
+
* THE BAR marking the current row is the row's `::before`, hung 8px outside its start edge
|
|
28
|
+
* (`-start-2` against the row's `px-2`), which is why the row is `relative`. A collapsed row
|
|
29
|
+
* hangs it 6px out instead (see `navRowCollapsedClass`).
|
|
30
|
+
*
|
|
31
|
+
* THE RADIUS IS A PAIR, NOT A FIGURE: `rounded-md` on the row against `rounded-lg` on the flyout
|
|
32
|
+
* panel, which is the shape `menuClasses.ts` already draws (`rounded-lg` panel, `rounded-md` rows).
|
|
33
|
+
* `--radius-md` is `calc(var(--radius) - 2px)` and `--radius-lg` is `var(--radius)`, so the pair
|
|
34
|
+
* draws 6/8 under graphite, **8/10 under kingfisher** and 10/12 under noix. The record draws rows
|
|
35
|
+
* at 8px (`.navitem` and `.railicon`) and its panel at 10px — the kingfisher pair exactly, which is
|
|
36
|
+
* the theme the record is drawn in. So the step reproduces the record's 2px relationship where the
|
|
37
|
+
* record was drawn and scales it in the other two. **The cost, stated rather than buried:** under
|
|
38
|
+
* graphite a row draws 6px where the record shows 8px. That is an absolute px match in one theme
|
|
39
|
+
* given up for the relationship in all three — a px value is one theme's instance of an intent, and
|
|
40
|
+
* the intent a designer drew is a row tighter than the panel around it.
|
|
41
|
+
*
|
|
42
|
+
* DEPTH has three steps, 0, 1 and 2-and-deeper, and not one per level: below the second group
|
|
43
|
+
* the rows stop shrinking.
|
|
44
|
+
*/
|
|
45
|
+
export const navRowClass =
|
|
46
|
+
'relative flex w-full min-w-0 cursor-default items-center gap-[9px] rounded-md px-2 font-medium text-sidebar-foreground no-underline outline-none select-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring';
|
|
47
|
+
|
|
48
|
+
/** A row that can be pressed (a link, or a button trigger) takes the pointer a link does. */
|
|
49
|
+
export const navRowInteractiveClass = 'cursor-pointer';
|
|
50
|
+
|
|
51
|
+
/** The current row: wash, ink, weight and the bar. Replaces the resting ink. */
|
|
52
|
+
export const navRowCurrentClass =
|
|
53
|
+
'bg-sidebar-accent text-primary-on-wash font-[650] before:absolute before:-start-2 before:inset-y-1.5 before:w-[3px] before:rounded-e-[3px] before:bg-accent-base before:content-[""]';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A CURRENT ROW INSIDE A FLYOUT KEEPS ITS INK AND DROPS THE BAR. Read after the current classes,
|
|
57
|
+
* so `twMerge` replaces `before:content-[""]` with `content: none` and no pseudo-element is
|
|
58
|
+
* generated at all — the offset, width and ink left behind it draw nothing. It is a replacement
|
|
59
|
+
* and not a second rule in the cascade, so stylesheet order decides nothing here.
|
|
60
|
+
*
|
|
61
|
+
* WHY, and it is a decision and not a tidy-up: the bar is an EDGE MARKER AGAINST A COLUMN. It
|
|
62
|
+
* hugs the start edge of the 216px column or the 56px rail, which is why its offset is negative
|
|
63
|
+
* and why the rail needed its own −6px form. A panel is not a column and has no such edge, so
|
|
64
|
+
* there is nothing for the bar to mark — hung 8px outside a row whose panel pads it by 5px, it
|
|
65
|
+
* landed 2px OUTSIDE the panel, over its own border. Tuning the offset would keep a mark whose
|
|
66
|
+
* premise is absent, at a figure the record never draws: no row in the record's flyout is
|
|
67
|
+
* `.current`, so there is no figure to read.
|
|
68
|
+
*
|
|
69
|
+
* What carries it instead is the ink, `--primary-on-wash`, which the contract gates at 4.5:1 —
|
|
70
|
+
* and this is the case the family's note about two cues was written for. The argument there is
|
|
71
|
+
* that the bar can fail inside an accent set (amber's reads 2.91 in light mode) and the ink must
|
|
72
|
+
* be able to stand alone. In a panel it stands alone by design rather than by accident.
|
|
73
|
+
*/
|
|
74
|
+
export const navRowBarlessClass = 'before:content-none';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A collapsed row is its icon alone, centred, in the record's `.railicon` box: 38px by 34px
|
|
78
|
+
* whatever the depth. The rail's gutter is 6px, so the current row's bar hangs 6px out
|
|
79
|
+
* (`before:-start-1.5`) instead of the open column's 8px, which would put two of its three
|
|
80
|
+
* pixels on or past the column's edge. Read after the depth and current classes, so twMerge
|
|
81
|
+
* keeps this one's height, width and bar offset.
|
|
82
|
+
*/
|
|
83
|
+
export const navRowCollapsedClass = 'h-[34px] w-[38px] justify-center px-0 before:-start-1.5';
|
|
84
|
+
|
|
85
|
+
/** The row's height and type size at a depth. */
|
|
86
|
+
export function navRowDepthClass(depth: number): string {
|
|
87
|
+
if (depth <= 0) return 'h-[31px] text-[13px]';
|
|
88
|
+
if (depth === 1) return 'h-[28px] text-[12.5px]';
|
|
89
|
+
return 'h-[27px] text-[12px]';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The icon's box. Dimmed at rest, opaque when its row is current. It sizes its DIRECT svg child
|
|
94
|
+
* (`[&>svg]`, the record's `.navitem svg`), so a size class a consumer puts on that svg does not
|
|
95
|
+
* win: it draws 15px open and 16px in the rail. An svg nested deeper is not reached.
|
|
96
|
+
*/
|
|
97
|
+
export const navIconClass =
|
|
98
|
+
'inline-flex size-[15px] shrink-0 items-center justify-center [&>svg]:size-[15px]';
|
|
99
|
+
/** In the rail the record draws the icon at 16px (`.railicon svg`), a pixel over the open row's. */
|
|
100
|
+
export const navIconRailClass = 'size-4 [&>svg]:size-4';
|
|
101
|
+
export const navIconRestClass = 'opacity-[0.72]';
|
|
102
|
+
export const navIconCurrentClass = 'opacity-100';
|
|
103
|
+
|
|
104
|
+
/** The label, which truncates rather than wraps. */
|
|
105
|
+
export const navLabelClass = 'min-w-0 flex-1 truncate text-start';
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The container of a group's children, one level in from the group's own row. `level` is the
|
|
109
|
+
* depth of the rows inside it (1 for the children of a top-level group).
|
|
110
|
+
*
|
|
111
|
+
* The indent grows for three levels and then stops: 22px, 15px, then 13px for the third and
|
|
112
|
+
* every one after. Unclamped, a fourth level leaves the label 90px inside a 216px column;
|
|
113
|
+
* clamped it loses the step and keeps the word. The guide line carries the nesting from there on.
|
|
114
|
+
* The line sits at 14px for the first level and 7px from the second on. Its ink is
|
|
115
|
+
* `--sidebar-border`, recorded in the contract as under 3:1 against the column, which is why
|
|
116
|
+
* it is never the only cue to anything.
|
|
117
|
+
*/
|
|
118
|
+
export function navKidsClass(level: number): string {
|
|
119
|
+
const pad = level <= 1 ? 'ps-[22px]' : level === 2 ? 'ps-[15px]' : 'ps-[13px]';
|
|
120
|
+
const line = level <= 1 ? 'before:start-[14px]' : 'before:start-[7px]';
|
|
121
|
+
return `relative mt-px mb-0.5 grid gap-px ${pad} before:absolute before:inset-y-[3px] before:w-px before:bg-sidebar-border before:content-[""] ${line}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The disclosure chevron at the end of a group's row: dimmed, and turned when the group is shut.
|
|
126
|
+
* 15px at every depth, the size of the row's leading icon. The record's markup carries
|
|
127
|
+
* `width="12"` and `width="11"` but `.navitem svg { width: 15px }` overrides a presentation
|
|
128
|
+
* attribute, and the rendered record draws all of them at 15px.
|
|
129
|
+
*/
|
|
130
|
+
export const navChevronClass =
|
|
131
|
+
'ms-auto size-[15px] shrink-0 opacity-50 transition-transform duration-150';
|
|
132
|
+
|
|
133
|
+
export const navChevronShutClass = '-rotate-90';
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* What a shut group prints after its label to name the current page it holds. Drawn on the
|
|
137
|
+
* row that is then drawn as the current row, so its ground is `--sidebar-accent`.
|
|
138
|
+
*/
|
|
139
|
+
export const navHoldsClass =
|
|
140
|
+
'min-w-0 flex-1 truncate text-[11.5px] font-medium text-primary-on-wash';
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A navigation section's band: the header, its title and the dot an accent draws before it.
|
|
144
|
+
*
|
|
145
|
+
* The title's ink is `--muted-foreground` on `--sidebar`, gated at 4.5:1 in the contract. The
|
|
146
|
+
* dot is `--accent-base`, which a theme binds to its brand and an accent set may rebind for the
|
|
147
|
+
* subtree; the contract gates the theme-level bindings only, so the dot, like the current row's
|
|
148
|
+
* bar, is never the only cue to anything (it is decoration, and `aria-hidden`).
|
|
149
|
+
*/
|
|
150
|
+
export const navSectionClass = 'grid shrink-0 gap-px';
|
|
151
|
+
export const navSectionHeadClass = 'flex items-center gap-1.5 px-2 pt-[11px] pb-1';
|
|
152
|
+
export const navSectionTitleClass =
|
|
153
|
+
'min-w-0 truncate text-[9.5px] font-extrabold tracking-[0.08em] text-muted-foreground uppercase';
|
|
154
|
+
export const navSectionDotClass = 'size-[7px] flex-none rounded-[2px] bg-accent-base';
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The column itself. 216px is `w-54` (`--spacing` is 0.25rem, so 54 steps are 13.5rem) and the
|
|
158
|
+
* rail's 56px is `w-14`; both are the record's `.side` and `.side.rail` flex bases. The column
|
|
159
|
+
* is a flex column of 1px-gapped rows with the record's 8px / 12px padding; the rail narrows
|
|
160
|
+
* the gutter to 6px and centres its rows.
|
|
161
|
+
*
|
|
162
|
+
* A rail has no room for a band's header, so the section draws a separator in its place
|
|
163
|
+
* (`navSectionRailSepClass`); the first band's would sit above everything, and the
|
|
164
|
+
* record draws none there, so the rail hides the separator of the band that has no band before
|
|
165
|
+
* it. That is "the first band", not "the column's first child": a `#top` slot above it does
|
|
166
|
+
* not bring the separator back.
|
|
167
|
+
*
|
|
168
|
+
* NO SHRINK. The record pins `.side { flex: 0 0 216px }` and `.side.rail { flex-basis: 56px }`,
|
|
169
|
+
* so a column beside content wider than the remainder keeps its width. `w-54` alone leaves
|
|
170
|
+
* `flex-shrink: 1`, and measured at 420px the column collapsed to 17px. `shrink-0` is on both.
|
|
171
|
+
*
|
|
172
|
+
* IT SCROLLS ITSELF. `overflow-y-auto` does both jobs: it lets the column be shorter than its
|
|
173
|
+
* content and it keeps the overflow inside the column, because a non-visible overflow already
|
|
174
|
+
* suppresses the automatic minimum size (the rule `FrameSplit`'s docblock states for a grid item).
|
|
175
|
+
* `min-h-0` is deliberately absent: measured, it changes nothing in any host (see
|
|
176
|
+
* `docs/design/README.md`). The sections hold `shrink-0` so the rows keep their declared height
|
|
177
|
+
* when something resets a section's minimum. A drawer keeps the scroll and swaps nothing.
|
|
178
|
+
*/
|
|
179
|
+
export const navSidebarClass =
|
|
180
|
+
'flex w-54 shrink-0 flex-col gap-px overflow-y-auto border-e border-sidebar-border bg-sidebar px-2 pt-2 pb-3';
|
|
181
|
+
export const navSidebarRailClass =
|
|
182
|
+
'w-14 items-center px-1.5 [&>[data-slot=nav-section]:not([data-slot=nav-section]~[data-slot=nav-section])>[data-slot=nav-section-rail-sep]]:hidden';
|
|
183
|
+
/** In a drawer the column fills the panel, which is already the menu's own width. */
|
|
184
|
+
export const navSidebarDrawerClass = 'min-h-full max-w-full';
|
|
185
|
+
/** The record's `.railsep`: 22px by 1px with 6px above and below. */
|
|
186
|
+
export const navSectionRailSepClass =
|
|
187
|
+
'my-1.5 h-px w-[22px] flex-none justify-self-center bg-sidebar-border';
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The flyout panel a rail's group opens, and the panel a panel's group opens after it. The
|
|
191
|
+
* record's `.flyout`: at least 178px wide, 5px of padding, a `--popover` ground with
|
|
192
|
+
* `--popover-foreground` ink and a `--border` edge. Those are the popover's roles and not the
|
|
193
|
+
* column's: the panel sits over the page, not in the column, so it takes the ground every other
|
|
194
|
+
* overlay in this system takes.
|
|
195
|
+
*
|
|
196
|
+
* THE RADIUS IS THE THEME'S, NOT THE RECORD'S 10px, and the two are the same thing where the
|
|
197
|
+
* record was drawn. `rounded-lg` resolves to `--radius`, which each theme sets: measured 10px
|
|
198
|
+
* under kingfisher — the record's own figure, because the record is drawn in kingfisher — 8px
|
|
199
|
+
* under graphite and 12px under noix. A fixed `rounded-[10px]` would be one theme's value frozen,
|
|
200
|
+
* which in a themeable system is the same category of mistake as a fixed colour, and it was also
|
|
201
|
+
* the only panel in this package not on the named scale: `menuClasses.ts` uses `rounded-lg` for
|
|
202
|
+
* its panel and `rounded-md` for its rows, and the dialog surface `rounded-2xl`.
|
|
203
|
+
*
|
|
204
|
+
* **It is the larger half of a pair.** The row is `rounded-md`, 2px tighter, so the record's own
|
|
205
|
+
* 8px row against its 10px panel is reproduced exactly under kingfisher and scaled in the other two
|
|
206
|
+
* themes; `navRowClass` carries the arithmetic and what it costs under graphite.
|
|
207
|
+
*
|
|
208
|
+
* TWO FIGURES ARE NOT THE RECORD'S. The record's own shadow is two fixed black layers, which a
|
|
209
|
+
* theme cannot follow; this one mixes `--foreground` into transparency instead, as the shipped
|
|
210
|
+
* popover does, so the lift survives a dark mode. **It is also one layer and not two**, as
|
|
211
|
+
* `PopoverPanel` is, and its offsets and blur are the record's first layer exactly; the second was
|
|
212
|
+
* a 2px/6px contact shadow that this system draws nowhere else. And the record stacks the flyout
|
|
213
|
+
* at `z-index: 5` inside its own demo page; `z-50` is the layer every overlay in this package
|
|
214
|
+
* takes, and a flyout that sat under a dialog would be a flyout nobody could press.
|
|
215
|
+
*
|
|
216
|
+
* `min-w-` and not `w-`: the panel grows with the longest label it holds, which is what
|
|
217
|
+
* `min-width` on the record's `.flyout` says and what `min-width: max-content` on the engine's
|
|
218
|
+
* own positioner does.
|
|
219
|
+
*/
|
|
220
|
+
export const navFlyoutClass =
|
|
221
|
+
'z-50 min-w-[178px] rounded-lg border border-border bg-popover p-[5px] text-popover-foreground shadow-[0_8px_24px_color-mix(in_oklab,var(--foreground)_14%,transparent)] outline-none';
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The record's `.ftitle`: the panel names the group it belongs to, at the band header's scale and
|
|
225
|
+
* ink (9.5px, 800, 0.08em, uppercase, `--muted-foreground`) with the record's 5px/8px/4px padding.
|
|
226
|
+
* It is the panel's accessible name as well as its heading, which is why it is not decoration.
|
|
227
|
+
*/
|
|
228
|
+
export const navFlyoutTitleClass =
|
|
229
|
+
'min-w-0 truncate px-2 pt-[5px] pb-1 text-[9.5px] font-extrabold tracking-[0.08em] text-muted-foreground uppercase';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One node of the object door. A `section` node is a band, a node with `children` is a group
|
|
5
|
+
* and any other node is a row. The three are told apart by their keys, so a node can be only
|
|
6
|
+
* one of them: a row cannot also hold children, and a group's own `to` is not read.
|
|
7
|
+
*/
|
|
8
|
+
export type NavNode =
|
|
9
|
+
| { section: string; accent?: string; children: NavNode[] }
|
|
10
|
+
| { label: string; to?: string; icon?: Component; children?: NavNode[] };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InjectionKey, Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** What an item tells its enclosing group about itself. */
|
|
4
|
+
export interface NavEntry {
|
|
5
|
+
label: string;
|
|
6
|
+
current: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface NavGroupApi {
|
|
10
|
+
/** An item announces itself; the returned function withdraws it. */
|
|
11
|
+
register(entry: Readonly<Ref<Readonly<NavEntry>>>): () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Provided by a navigation group so the items inside it can announce their label and whether
|
|
16
|
+
* they are the current page. A shut group reads those to name the page it holds.
|
|
17
|
+
*/
|
|
18
|
+
export const NAV_GROUP: InjectionKey<NavGroupApi> = Symbol('nav-group');
|
|
19
|
+
|
|
20
|
+
/** 0 inside a section, 1 inside its first group, and so on. Unbounded. */
|
|
21
|
+
export const NAV_DEPTH: InjectionKey<Readonly<Ref<number>>> = Symbol('nav-depth');
|
|
22
|
+
|
|
23
|
+
/** The rail state, provided by NavSidebar so a row can drop its label. */
|
|
24
|
+
export const NAV_COLLAPSED: InjectionKey<Readonly<Ref<boolean>>> = Symbol('nav-collapsed');
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { formatLabel, useUiLabels } from '@noix-dev/brix-core';
|
|
3
|
+
import { computed, useAttrs, useId, useSlots, watch } from 'vue';
|
|
4
|
+
import { cn } from '../../lib/cn';
|
|
5
|
+
import { Badge } from '../badge';
|
|
6
|
+
import { BellIcon, CheckIcon } from '../icon';
|
|
7
|
+
import { PopoverPanel } from '../popover-panel';
|
|
8
|
+
import type { Notification, NotificationFilter } from './notifications';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The notification bell and the panel it opens: a trigger carrying an unread count, a row of
|
|
12
|
+
* filter chips, the rows, a status line, a mark-one-read affordance and a mark-all. Items arrive
|
|
13
|
+
* as a prop; opening, reading, reading all and filtering leave as events. Nothing polls, nothing
|
|
14
|
+
* subscribes, nothing knows an endpoint. The panel IS the published `PopoverPanel`, so its
|
|
15
|
+
* focus, Escape and outside-click behaviour is that shell's.
|
|
16
|
+
*
|
|
17
|
+
* - **Unread is one nullable field** (`Notification.readAt`, `null` for unread), not a flag beside
|
|
18
|
+
* a timestamp: two fields can disagree.
|
|
19
|
+
* - **Marking read is a consequence of opening.** One gesture on an unread row emits `open` and
|
|
20
|
+
* then `read`, and does not wait for the mark; a row that is already read emits `open` alone,
|
|
21
|
+
* so a consumer is never asked to mark a row twice. A small button on an unread row marks it
|
|
22
|
+
* read without opening it, and is described by that row's own open control.
|
|
23
|
+
* - **The family owns the chips, not the filtering.** It draws `filters`, presses the one whose
|
|
24
|
+
* key is `activeFilter` (`aria-pressed`), and emits `filter` with the key chosen. It never
|
|
25
|
+
* filters `items`: what a filter means is the consumer's, which refetches or filters its own
|
|
26
|
+
* array.
|
|
27
|
+
* - **The trigger's count is the unread items among the `items` it is given**, and nothing more.
|
|
28
|
+
* A consumer whose filter leaves unread rows out of `items` sees a smaller count than the
|
|
29
|
+
* truth: there is no separate count prop, by decision. Keep the unread rows in `items`, or
|
|
30
|
+
* draw the count yourself in the `bell` slot.
|
|
31
|
+
* - **`read-all` is not gated on that count.** It is an instruction the consumer fulfils against
|
|
32
|
+
* its own full data, not an operation on the list this family was handed; disabling it on the
|
|
33
|
+
* family's partial view would make it vanish exactly when a filter shows only read rows.
|
|
34
|
+
* - **There is no grouping.** Not by day, category or read state: neither source this family
|
|
35
|
+
* replaces groups, both are one flat list, newest first. A grouping by day also splits a short
|
|
36
|
+
* list a second time along an axis the reader did not choose, now that a read filter exists.
|
|
37
|
+
* - **It has a loading state, which neither source had** (and one of them had a test pinning the
|
|
38
|
+
* absence). One `role="status"` element carries the loading label, then the empty label or the
|
|
39
|
+
* number of rows, and only its TEXT changes. It lives in the panel, which the popover renders
|
|
40
|
+
* only while it is open, so it is inserted already holding text at open, which is the
|
|
41
|
+
* unreliable case: what a screen reader reliably gets is the CHANGE while the panel stays open
|
|
42
|
+
* (a filter changing the count, a load finishing). That is the valuable half and the
|
|
43
|
+
* arrangement is right for it. Two answers with the same count and the same scope announce
|
|
44
|
+
* nothing, because the text does not change. Rows already given stay while it loads. The line
|
|
45
|
+
* is only shown when loading or empty and is visually hidden otherwise.
|
|
46
|
+
* - **`cap` has no default.** The two sources chose different caps, which is why it is a prop;
|
|
47
|
+
* without it the count reads in full, and with it an unread count above `cap` reads `cap+`.
|
|
48
|
+
* - **The row slot is how a row gets its content.** `Notification` carries only `id` and
|
|
49
|
+
* `readAt`, so the family has nothing of its own to show: without the slot a row draws nothing
|
|
50
|
+
* visible, and development warns.
|
|
51
|
+
* - The bell and the read-one glyph are slots (`bell`, `check`) with drawn defaults (decision
|
|
52
|
+
* 0013), and the row is a slot (`row`) because the sources show different things in it.
|
|
53
|
+
*
|
|
54
|
+
* COPY comes from the label contract (`notificationsName`, `notificationsNameUnread`,
|
|
55
|
+
* `notificationsReadAll`, `notificationsReadOne`, `notificationsEmpty`, `notificationsLoading`,
|
|
56
|
+
* `notificationsCount`). The props `label`, `readAllLabel`, `readOneLabel`, `emptyLabel` and
|
|
57
|
+
* `loadingLabel` override ONE instance over the registry value and never replace the registry;
|
|
58
|
+
* `label` replaces the trigger's whole accessible name, count included.
|
|
59
|
+
*
|
|
60
|
+
* DO NOT WRITE `aria-expanded`, `aria-controls` OR `data-state` ON THE TRIGGER: the popover shell
|
|
61
|
+
* writes them and a copy of yours would replace its.
|
|
62
|
+
*
|
|
63
|
+
* ATTRIBUTES go to the trigger, where the person finds the control: `class`, `id`, `data-*` and
|
|
64
|
+
* `aria-*` land on the bell button, and `class` merges with its own through `cn`. The panel is
|
|
65
|
+
* not reachable by `class` (it is portalled and exists only while open), and the family draws
|
|
66
|
+
* its own. This is the split `FilterCheckMenu` and `IconPicker` make.
|
|
67
|
+
*
|
|
68
|
+
* FOCUS RING ON THE PRESSED CHIP. The chip's ring is inset (the panel is `p-0`, so an outset
|
|
69
|
+
* ring would clip at the panel's edge) and an inset ring is drawn ON the chip's fill. On the
|
|
70
|
+
* pressed chip the fill is `--primary`, and `--ring` is the same colour as `--primary` in five of
|
|
71
|
+
* the six theme and mode pairs, so the pressed chip names `focus-visible:ring-primary-foreground`,
|
|
72
|
+
* the pair this system gates at 4.5 for the chip's own label (see `CLAUDE.md`, "The first kind").
|
|
73
|
+
* A chip that is current is where focus lands first, so it is the one that must show it.
|
|
74
|
+
*/
|
|
75
|
+
defineOptions({ inheritAttrs: false });
|
|
76
|
+
|
|
77
|
+
const props = withDefaults(
|
|
78
|
+
defineProps<{
|
|
79
|
+
items: Notification[];
|
|
80
|
+
/**
|
|
81
|
+
* The chips. The family owns the row and the pressed state; the consumer owns the
|
|
82
|
+
* meaning.
|
|
83
|
+
*/
|
|
84
|
+
filters: NotificationFilter[];
|
|
85
|
+
activeFilter: string;
|
|
86
|
+
/**
|
|
87
|
+
* How high the trigger's count may read before it caps: the two sources chose
|
|
88
|
+
* differently.
|
|
89
|
+
*/
|
|
90
|
+
cap?: number;
|
|
91
|
+
loading?: boolean;
|
|
92
|
+
/** Replaces the trigger's whole accessible name for this instance. */
|
|
93
|
+
label?: string;
|
|
94
|
+
readAllLabel?: string;
|
|
95
|
+
readOneLabel?: string;
|
|
96
|
+
emptyLabel?: string;
|
|
97
|
+
loadingLabel?: string;
|
|
98
|
+
}>(),
|
|
99
|
+
{
|
|
100
|
+
cap: undefined,
|
|
101
|
+
loading: false,
|
|
102
|
+
label: undefined,
|
|
103
|
+
readAllLabel: undefined,
|
|
104
|
+
readOneLabel: undefined,
|
|
105
|
+
emptyLabel: undefined,
|
|
106
|
+
loadingLabel: undefined,
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const emit = defineEmits<{
|
|
111
|
+
(e: 'open', id: string): void;
|
|
112
|
+
(e: 'read', id: string): void;
|
|
113
|
+
(e: 'read-all'): void;
|
|
114
|
+
(e: 'filter', key: string): void;
|
|
115
|
+
}>();
|
|
116
|
+
|
|
117
|
+
defineSlots<{
|
|
118
|
+
row?: (props: { item: Notification }) => unknown;
|
|
119
|
+
bell?: () => unknown;
|
|
120
|
+
check?: () => unknown;
|
|
121
|
+
}>();
|
|
122
|
+
|
|
123
|
+
const labels = useUiLabels();
|
|
124
|
+
const slots = useSlots();
|
|
125
|
+
const attrs = useAttrs();
|
|
126
|
+
const uid = useId();
|
|
127
|
+
|
|
128
|
+
const open = defineModel<boolean>('open', { default: false });
|
|
129
|
+
|
|
130
|
+
// A plain function, not a `computed`: enumerating `useAttrs()` depends on the values of the
|
|
131
|
+
// attributes present when it runs and not on the key set, so a computed would never see a consumer
|
|
132
|
+
// add one later. Measured on Vue 3.5.46, identical in the development and the production build.
|
|
133
|
+
function triggerAttrs(): Record<string, unknown> {
|
|
134
|
+
return Object.fromEntries(Object.entries(attrs).filter(([key]) => key !== 'class'));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const unread = computed(() => props.items.filter((item) => item.readAt === null).length);
|
|
138
|
+
|
|
139
|
+
const shown = computed(() =>
|
|
140
|
+
props.cap !== undefined && unread.value > props.cap ? `${props.cap}+` : String(unread.value),
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const name = computed(
|
|
144
|
+
() =>
|
|
145
|
+
props.label ??
|
|
146
|
+
(unread.value > 0
|
|
147
|
+
? formatLabel(labels.value.notificationsNameUnread, { count: unread.value })
|
|
148
|
+
: labels.value.notificationsName),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const readAllText = computed(() => props.readAllLabel ?? labels.value.notificationsReadAll);
|
|
152
|
+
const readOneText = computed(() => props.readOneLabel ?? labels.value.notificationsReadOne);
|
|
153
|
+
|
|
154
|
+
const state = computed<'loading' | 'empty' | 'ready'>(() =>
|
|
155
|
+
props.loading ? 'loading' : props.items.length === 0 ? 'empty' : 'ready',
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const statusText = computed(() => {
|
|
159
|
+
if (state.value === 'loading') {
|
|
160
|
+
return props.loadingLabel ?? labels.value.notificationsLoading;
|
|
161
|
+
}
|
|
162
|
+
if (state.value === 'empty') {
|
|
163
|
+
return props.emptyLabel ?? labels.value.notificationsEmpty;
|
|
164
|
+
}
|
|
165
|
+
return formatLabel(labels.value.notificationsCount, { count: props.items.length });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const openId = (item: Notification): string => `${uid}-open-${item.id}`;
|
|
169
|
+
|
|
170
|
+
const rowMissing = computed(() => slots.row === undefined && props.items.length > 0);
|
|
171
|
+
watch(
|
|
172
|
+
rowMissing,
|
|
173
|
+
(missing) => {
|
|
174
|
+
if (missing && process.env.NODE_ENV !== 'production') {
|
|
175
|
+
console.warn(
|
|
176
|
+
'Warning: `NotificationList` draws nothing for a row without a `row` slot, ' +
|
|
177
|
+
'because a notification carries only an id and a read time. ' +
|
|
178
|
+
'Give it a `row` slot.',
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{ immediate: true },
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
function openRow(item: Notification): void {
|
|
186
|
+
emit('open', item.id);
|
|
187
|
+
if (item.readAt === null) {
|
|
188
|
+
emit('read', item.id);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<template>
|
|
194
|
+
<PopoverPanel v-model:open="open" align="end" class="w-96 p-0">
|
|
195
|
+
<template #trigger>
|
|
196
|
+
<button
|
|
197
|
+
type="button"
|
|
198
|
+
data-slot="notification-list-trigger"
|
|
199
|
+
v-bind="triggerAttrs()"
|
|
200
|
+
:aria-label="name"
|
|
201
|
+
:class="
|
|
202
|
+
cn(
|
|
203
|
+
'text-foreground hover:bg-accent focus-visible:ring-ring relative inline-flex size-9 items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
204
|
+
attrs.class as string | undefined,
|
|
205
|
+
)
|
|
206
|
+
"
|
|
207
|
+
>
|
|
208
|
+
<slot name="bell"><BellIcon class="size-5" /></slot>
|
|
209
|
+
<Badge
|
|
210
|
+
v-if="unread > 0"
|
|
211
|
+
tone="teal"
|
|
212
|
+
class="absolute -top-1 -right-1 min-w-5 justify-center px-1"
|
|
213
|
+
>
|
|
214
|
+
{{ shown }}
|
|
215
|
+
</Badge>
|
|
216
|
+
</button>
|
|
217
|
+
</template>
|
|
218
|
+
<template #panel>
|
|
219
|
+
<div class="flex items-center justify-between gap-2 border-b border-border p-2">
|
|
220
|
+
<div class="flex flex-wrap gap-1">
|
|
221
|
+
<button
|
|
222
|
+
v-for="filter in filters"
|
|
223
|
+
:key="filter.key"
|
|
224
|
+
type="button"
|
|
225
|
+
data-slot="notification-chip"
|
|
226
|
+
:data-testid="`notification-filter-${filter.key}`"
|
|
227
|
+
:aria-pressed="activeFilter === filter.key ? 'true' : 'false'"
|
|
228
|
+
:class="
|
|
229
|
+
cn(
|
|
230
|
+
'hover:bg-accent focus-visible:ring-ring inline-flex items-center gap-1.5 rounded-full border border-border px-2.5 py-1 text-xs outline-none focus-visible:ring-2 focus-visible:ring-inset',
|
|
231
|
+
activeFilter === filter.key &&
|
|
232
|
+
'bg-primary text-primary-foreground border-primary focus-visible:ring-primary-foreground font-semibold hover:bg-primary',
|
|
233
|
+
)
|
|
234
|
+
"
|
|
235
|
+
@click="emit('filter', filter.key)"
|
|
236
|
+
>
|
|
237
|
+
{{ filter.label }}
|
|
238
|
+
<span
|
|
239
|
+
v-if="filter.count !== undefined"
|
|
240
|
+
data-slot="notification-chip-count"
|
|
241
|
+
class="tabular-nums"
|
|
242
|
+
>
|
|
243
|
+
{{ filter.count }}
|
|
244
|
+
</span>
|
|
245
|
+
</button>
|
|
246
|
+
</div>
|
|
247
|
+
<button
|
|
248
|
+
type="button"
|
|
249
|
+
data-testid="notification-read-all"
|
|
250
|
+
class="text-primary hover:bg-accent focus-visible:ring-ring rounded-md px-2 py-1 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-inset"
|
|
251
|
+
@click="emit('read-all')"
|
|
252
|
+
>
|
|
253
|
+
{{ readAllText }}
|
|
254
|
+
</button>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<p
|
|
258
|
+
role="status"
|
|
259
|
+
data-testid="notification-status"
|
|
260
|
+
:data-state="state"
|
|
261
|
+
:class="
|
|
262
|
+
state === 'ready'
|
|
263
|
+
? 'sr-only'
|
|
264
|
+
: 'text-muted-foreground px-3 py-5 text-center text-sm'
|
|
265
|
+
"
|
|
266
|
+
>
|
|
267
|
+
{{ statusText }}
|
|
268
|
+
</p>
|
|
269
|
+
|
|
270
|
+
<ul v-if="items.length > 0" class="m-0 list-none p-0">
|
|
271
|
+
<li
|
|
272
|
+
v-for="item in items"
|
|
273
|
+
:key="item.id"
|
|
274
|
+
data-slot="notification-row"
|
|
275
|
+
:data-unread="item.readAt === null ? 'true' : 'false'"
|
|
276
|
+
class="border-border flex items-stretch border-b last:border-b-0"
|
|
277
|
+
>
|
|
278
|
+
<button
|
|
279
|
+
:id="openId(item)"
|
|
280
|
+
type="button"
|
|
281
|
+
:data-testid="`notification-open-${item.id}`"
|
|
282
|
+
class="hover:bg-accent focus-visible:ring-ring flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-inset"
|
|
283
|
+
@click="openRow(item)"
|
|
284
|
+
>
|
|
285
|
+
<span
|
|
286
|
+
aria-hidden="true"
|
|
287
|
+
:class="
|
|
288
|
+
cn(
|
|
289
|
+
'mt-1.5 size-2 shrink-0 rounded-full',
|
|
290
|
+
item.readAt === null ? 'bg-primary' : 'bg-transparent',
|
|
291
|
+
)
|
|
292
|
+
"
|
|
293
|
+
/>
|
|
294
|
+
<span class="min-w-0 flex-1">
|
|
295
|
+
<slot name="row" :item="item" />
|
|
296
|
+
</span>
|
|
297
|
+
</button>
|
|
298
|
+
<button
|
|
299
|
+
v-if="item.readAt === null"
|
|
300
|
+
type="button"
|
|
301
|
+
:data-testid="`notification-read-${item.id}`"
|
|
302
|
+
:aria-label="readOneText"
|
|
303
|
+
:aria-describedby="openId(item)"
|
|
304
|
+
:title="readOneText"
|
|
305
|
+
class="text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-ring px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-inset"
|
|
306
|
+
@click="emit('read', item.id)"
|
|
307
|
+
>
|
|
308
|
+
<slot name="check"><CheckIcon class="size-3.5" /></slot>
|
|
309
|
+
</button>
|
|
310
|
+
</li>
|
|
311
|
+
</ul>
|
|
312
|
+
</template>
|
|
313
|
+
</PopoverPanel>
|
|
314
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the notification list needs to know about an item, and nothing more: a product extends
|
|
3
|
+
* this with its own fields (a title, a body, a link) and draws them through the `row` slot.
|
|
4
|
+
*/
|
|
5
|
+
export interface Notification {
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* When it was read; `null` means unread. One nullable field, never a flag beside a timestamp:
|
|
9
|
+
* two fields can disagree, and both sources this family replaces test a read-at value against
|
|
10
|
+
* null and nothing else.
|
|
11
|
+
*/
|
|
12
|
+
readAt: string | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** One chip in the filter row. The family draws and presses it; the consumer owns its meaning. */
|
|
16
|
+
export interface NotificationFilter {
|
|
17
|
+
key: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** Drawn on the chip when given, for example the unread count on an "Unread" chip. */
|
|
20
|
+
count?: number;
|
|
21
|
+
}
|