@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,44 @@
|
|
|
1
|
+
export { default as AppearancePicker } from './AppearancePicker.vue';
|
|
2
|
+
|
|
3
|
+
/** Which shape the picker takes: a settings card of rows, or one trigger with a panel. */
|
|
4
|
+
export type AppearanceLayout = 'rows' | 'popover';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which edge of the trigger the `popover` layout's panel lines up with. `start` is the
|
|
8
|
+
* default and the original behaviour; `end` right-aligns the panel, which is what a
|
|
9
|
+
* trigger at the right-hand end of an application's header needs — pinned to `start`
|
|
10
|
+
* there, a 340px panel hangs off the right of the window and gives the whole document a
|
|
11
|
+
* horizontal scrollbar. Inert in the `rows` layout, which has no panel.
|
|
12
|
+
*/
|
|
13
|
+
export type AppearanceAlign = 'start' | 'end';
|
|
14
|
+
|
|
15
|
+
/** One option of a segmented group. */
|
|
16
|
+
export interface AppearanceOption {
|
|
17
|
+
/** What gets applied and stored, and the last part of the option's `data-testid`. */
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/** The `d` of each path of a 24×24 stroke glyph shown before the label. */
|
|
21
|
+
glyph?: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* A theme option shows a colour swatch instead of a glyph. The swatch carries the
|
|
24
|
+
* theme's own `data-brix-theme`, so it paints itself in the theme it offers rather than in
|
|
25
|
+
* the one currently applied — see `AppearanceSegment.vue`.
|
|
26
|
+
*/
|
|
27
|
+
swatch?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One segmented group: the options, which of them is in force, and the writer that applies
|
|
32
|
+
* and persists a pick. The writer travels with the group so that both layouts can render
|
|
33
|
+
* the same group without restating what a pick means.
|
|
34
|
+
*/
|
|
35
|
+
export interface AppearanceGroup {
|
|
36
|
+
/** Middle part of every option's `data-testid`: `appearance-<name>-<value>`. */
|
|
37
|
+
name: string;
|
|
38
|
+
title: string;
|
|
39
|
+
/** The one-line explanation; the rows layout shows it, the popover does not. */
|
|
40
|
+
text: string;
|
|
41
|
+
options: AppearanceOption[];
|
|
42
|
+
selected: string;
|
|
43
|
+
choose: (value: string) => void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { type ComponentPublicInstance, computed, ref, watch } from 'vue';
|
|
3
|
+
import { Button } from '../button';
|
|
4
|
+
import { Checkbox } from '../checkbox';
|
|
5
|
+
import { Dialog } from '../dialog';
|
|
6
|
+
import { Input } from '../input';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The one dialog behind every "take over" button: a searchable list of entries the person
|
|
10
|
+
* picks from.
|
|
11
|
+
*
|
|
12
|
+
* It holds the search and the ticks and knows nothing about where the entries come from or what
|
|
13
|
+
* becomes of them. A single dialog hands back the clicked label and asks to close; a multiple one
|
|
14
|
+
* hands back the ticked labels on confirm and leaves the closing to the caller, so a refusal can
|
|
15
|
+
* keep it open with the rest still ticked.
|
|
16
|
+
*
|
|
17
|
+
* Every string comes in as a prop, so an app that translates passes its own. The default slot
|
|
18
|
+
* replaces the list and the buttons (an edit view in the same dialog); `header-action` sits beside
|
|
19
|
+
* the hint, `extra` between the search and the list, and `entry` (scoped: `label`, `value`) beside
|
|
20
|
+
* each ticked entry of a multiple dialog.
|
|
21
|
+
*/
|
|
22
|
+
const props = defineProps<{
|
|
23
|
+
open: boolean;
|
|
24
|
+
title: string;
|
|
25
|
+
hint?: string;
|
|
26
|
+
entries: { value: string; label: string }[];
|
|
27
|
+
multiple?: boolean;
|
|
28
|
+
/** Labels that are taken already; compared trimmed and case-insensitively. */
|
|
29
|
+
disabledLabels?: string[];
|
|
30
|
+
/** How many more may be ticked; unset is no limit. */
|
|
31
|
+
limitLeft?: number;
|
|
32
|
+
busy?: boolean;
|
|
33
|
+
/** The caller's own reason the ticked set cannot be taken over yet (a rating still to give). */
|
|
34
|
+
confirmDisabled?: boolean;
|
|
35
|
+
error?: string | null;
|
|
36
|
+
searchPlaceholder: string;
|
|
37
|
+
cancelLabel: string;
|
|
38
|
+
confirmLabel: (count: number) => string;
|
|
39
|
+
alreadyLabel: string;
|
|
40
|
+
emptyLabel: string;
|
|
41
|
+
/** The close button's accessible name; unset keeps the Dialog's own default. */
|
|
42
|
+
closeLabel?: string;
|
|
43
|
+
}>();
|
|
44
|
+
const emit = defineEmits<{
|
|
45
|
+
(e: 'update:open', value: boolean): void;
|
|
46
|
+
(e: 'pick', label: string): void;
|
|
47
|
+
(e: 'confirm', labels: string[]): void;
|
|
48
|
+
/** Forwarded from the Dialog: the caller returns the focus to the button it opened from. */
|
|
49
|
+
(e: 'closeAutoFocus', event: Event): void;
|
|
50
|
+
}>();
|
|
51
|
+
|
|
52
|
+
const search = ref('');
|
|
53
|
+
/** The values the person ticked. What counts is `chosen`: a tick on a taken entry does not. */
|
|
54
|
+
const ticked = ref<string[]>([]);
|
|
55
|
+
const searchField = ref<ComponentPublicInstance | null>(null);
|
|
56
|
+
|
|
57
|
+
function normalize(text: string): string {
|
|
58
|
+
return text.trim().toLocaleLowerCase();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const taken = computed(() => new Set((props.disabledLabels ?? []).map(normalize)));
|
|
62
|
+
function isTaken(label: string): boolean {
|
|
63
|
+
return taken.value.has(normalize(label));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const shown = computed(() => {
|
|
67
|
+
const needle = normalize(search.value);
|
|
68
|
+
return props.entries.filter((e) => needle === '' || normalize(e.label).includes(needle));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/** In the list's order, without entries that are gone or have been taken meanwhile. */
|
|
72
|
+
const chosen = computed(() =>
|
|
73
|
+
props.entries
|
|
74
|
+
.filter((e) => ticked.value.includes(e.value) && !isTaken(e.label))
|
|
75
|
+
.map((e) => e.value),
|
|
76
|
+
);
|
|
77
|
+
const full = computed(
|
|
78
|
+
() => props.limitLeft !== undefined && chosen.value.length >= props.limitLeft,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
function isOff(entry: { value: string; label: string }): boolean {
|
|
82
|
+
if (isTaken(entry.label)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return props.multiple === true && full.value && !chosen.value.includes(entry.value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function toggle(value: string, on: boolean): void {
|
|
89
|
+
ticked.value = on ? [...chosen.value, value] : chosen.value.filter((v) => v !== value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A close (X, Escape, outside click) is refused while a save runs: its failure report must land. */
|
|
93
|
+
function requestOpen(value: boolean): void {
|
|
94
|
+
if (!value && props.busy) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
emit('update:open', value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function pick(label: string): void {
|
|
101
|
+
emit('pick', label);
|
|
102
|
+
emit('update:open', false);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function confirm(): void {
|
|
106
|
+
if (chosen.value.length === 0 || props.busy || props.confirmDisabled) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
emit(
|
|
110
|
+
'confirm',
|
|
111
|
+
props.entries.filter((e) => chosen.value.includes(e.value)).map((e) => e.label),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Ticks exactly these labels: the caller narrows a retry down to what was not taken over. */
|
|
116
|
+
function setTicked(labels: string[]): void {
|
|
117
|
+
const wanted = new Set(labels.map(normalize));
|
|
118
|
+
ticked.value = props.entries.filter((e) => wanted.has(normalize(e.label))).map((e) => e.value);
|
|
119
|
+
}
|
|
120
|
+
defineExpose({ setTicked });
|
|
121
|
+
|
|
122
|
+
watch(
|
|
123
|
+
() => props.open,
|
|
124
|
+
(isOpen) => {
|
|
125
|
+
if (isOpen) {
|
|
126
|
+
search.value = '';
|
|
127
|
+
ticked.value = [];
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{ immediate: true },
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
/** Typing is what one does here first: the search gets the focus, not the close X. */
|
|
134
|
+
function focusSearch(event: Event): void {
|
|
135
|
+
const field = searchField.value?.$el as HTMLElement | undefined;
|
|
136
|
+
if (field) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
field.focus();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
|
|
143
|
+
<template>
|
|
144
|
+
<Dialog
|
|
145
|
+
:open="props.open"
|
|
146
|
+
:title="props.title"
|
|
147
|
+
:description="props.hint"
|
|
148
|
+
:close-label="props.closeLabel"
|
|
149
|
+
size="md"
|
|
150
|
+
@update:open="requestOpen"
|
|
151
|
+
@open-auto-focus="focusSearch"
|
|
152
|
+
@close-auto-focus="(e: Event) => emit('closeAutoFocus', e)"
|
|
153
|
+
>
|
|
154
|
+
<div class="flex flex-col gap-2.5">
|
|
155
|
+
<div v-if="props.hint || $slots['header-action']" class="flex items-start gap-3">
|
|
156
|
+
<!-- The Dialog reads the hint out as its description: the visible one stays silent. -->
|
|
157
|
+
<p
|
|
158
|
+
v-if="props.hint"
|
|
159
|
+
data-testid="autofill-hint"
|
|
160
|
+
aria-hidden="true"
|
|
161
|
+
class="text-xs text-muted-foreground"
|
|
162
|
+
>
|
|
163
|
+
{{ props.hint }}
|
|
164
|
+
</p>
|
|
165
|
+
<div v-if="$slots['header-action']" class="ml-auto shrink-0">
|
|
166
|
+
<slot name="header-action" />
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<slot v-if="$slots.default" />
|
|
171
|
+
<template v-else>
|
|
172
|
+
<Input
|
|
173
|
+
ref="searchField"
|
|
174
|
+
v-model="search"
|
|
175
|
+
data-testid="autofill-search"
|
|
176
|
+
:placeholder="props.searchPlaceholder"
|
|
177
|
+
:aria-label="props.searchPlaceholder"
|
|
178
|
+
autocomplete="off"
|
|
179
|
+
/>
|
|
180
|
+
<slot v-if="props.multiple" name="extra" />
|
|
181
|
+
|
|
182
|
+
<div class="flex max-h-[45vh] flex-col gap-0.5 overflow-y-auto">
|
|
183
|
+
<p
|
|
184
|
+
v-if="shown.length === 0"
|
|
185
|
+
data-testid="autofill-empty"
|
|
186
|
+
class="px-2 py-1.5 text-xs text-muted-foreground"
|
|
187
|
+
>
|
|
188
|
+
{{ props.emptyLabel }}
|
|
189
|
+
</p>
|
|
190
|
+
<template v-for="e in shown" :key="e.value">
|
|
191
|
+
<!-- The entry slot sits outside the label: a click on its control
|
|
192
|
+
(a rating) must not toggle the tick. -->
|
|
193
|
+
<div
|
|
194
|
+
v-if="props.multiple"
|
|
195
|
+
class="flex items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] hover:bg-muted"
|
|
196
|
+
:class="isOff(e) && 'text-muted-foreground'"
|
|
197
|
+
>
|
|
198
|
+
<label class="flex flex-1 items-center gap-2">
|
|
199
|
+
<Checkbox
|
|
200
|
+
:data-testid="`autofill-entry-${e.value}`"
|
|
201
|
+
:model-value="chosen.includes(e.value)"
|
|
202
|
+
:disabled="isOff(e)"
|
|
203
|
+
@update:model-value="(on: boolean) => toggle(e.value, on)"
|
|
204
|
+
/>
|
|
205
|
+
<span>{{ e.label }}</span>
|
|
206
|
+
<span v-if="isTaken(e.label)" class="text-[11px]">{{
|
|
207
|
+
props.alreadyLabel
|
|
208
|
+
}}</span>
|
|
209
|
+
</label>
|
|
210
|
+
<slot
|
|
211
|
+
v-if="chosen.includes(e.value)"
|
|
212
|
+
name="entry"
|
|
213
|
+
:label="e.label"
|
|
214
|
+
:value="e.value"
|
|
215
|
+
/>
|
|
216
|
+
</div>
|
|
217
|
+
<button
|
|
218
|
+
v-else
|
|
219
|
+
type="button"
|
|
220
|
+
:data-testid="`autofill-entry-${e.value}`"
|
|
221
|
+
:disabled="isTaken(e.label) || props.busy"
|
|
222
|
+
class="flex items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent"
|
|
223
|
+
@click="pick(e.label)"
|
|
224
|
+
>
|
|
225
|
+
<span>{{ e.label }}</span>
|
|
226
|
+
<span v-if="isTaken(e.label)" class="text-[11px]">{{
|
|
227
|
+
props.alreadyLabel
|
|
228
|
+
}}</span>
|
|
229
|
+
</button>
|
|
230
|
+
</template>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<p
|
|
234
|
+
v-if="props.error"
|
|
235
|
+
role="alert"
|
|
236
|
+
data-testid="autofill-error"
|
|
237
|
+
class="text-xs text-destructive"
|
|
238
|
+
>
|
|
239
|
+
{{ props.error }}
|
|
240
|
+
</p>
|
|
241
|
+
</template>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
<template v-if="props.multiple && !$slots.default" #footer>
|
|
245
|
+
<Button
|
|
246
|
+
type="button"
|
|
247
|
+
variant="outline"
|
|
248
|
+
data-testid="autofill-cancel"
|
|
249
|
+
:disabled="props.busy"
|
|
250
|
+
@click="emit('update:open', false)"
|
|
251
|
+
>
|
|
252
|
+
{{ props.cancelLabel }}
|
|
253
|
+
</Button>
|
|
254
|
+
<Button
|
|
255
|
+
type="button"
|
|
256
|
+
data-testid="autofill-confirm"
|
|
257
|
+
:disabled="chosen.length === 0 || props.busy || props.confirmDisabled"
|
|
258
|
+
@click="confirm"
|
|
259
|
+
>
|
|
260
|
+
{{ props.confirmLabel(chosen.length) }}
|
|
261
|
+
</Button>
|
|
262
|
+
</template>
|
|
263
|
+
</Dialog>
|
|
264
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AutoFillDialog } from './AutoFillDialog.vue';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import type { BadgeVariants } from '.';
|
|
4
|
+
import { cn } from '../../lib/cn';
|
|
5
|
+
import { badgeVariants } from '.';
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(
|
|
8
|
+
defineProps<{ tone?: BadgeVariants['tone']; class?: HTMLAttributes['class'] }>(),
|
|
9
|
+
{
|
|
10
|
+
tone: 'neutral',
|
|
11
|
+
},
|
|
12
|
+
);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<span
|
|
17
|
+
data-slot="badge"
|
|
18
|
+
:data-tone="props.tone"
|
|
19
|
+
:class="cn(badgeVariants({ tone: props.tone }), props.class)"
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</span>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
export { default as Badge } from './Badge.vue';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The colour half of every tone — background, text and their dark-mode variants, with no
|
|
8
|
+
* size or shape. `Badge` adds its own shape on top; a chip that sets its own size takes
|
|
9
|
+
* these classes directly instead of spelling out hex values, which is how a chip of that
|
|
10
|
+
* kind otherwise ends up with no dark mode at all.
|
|
11
|
+
*
|
|
12
|
+
* `badgeVariants` is built from this map, so the two can never drift apart.
|
|
13
|
+
*
|
|
14
|
+
* `teal` is the theme's own primary pair — `--primary` as the wash, `--primary-on-wash`
|
|
15
|
+
* as the text — and not a brand rung. A hue that clears WCAG AA on the page does not
|
|
16
|
+
* clear it on a 10% wash of itself, which is why the contract carries a separate
|
|
17
|
+
* on-wash role and gates that pair in every theme: bound to the raw rung this tone
|
|
18
|
+
* measured 2.93 in one of the three shipped themes. One consequence worth knowing: an
|
|
19
|
+
* accent set rebinds `--primary`, so inside `[data-brix-accent]` this tone follows the
|
|
20
|
+
* section's hue — and stays readable, because every accent set restates
|
|
21
|
+
* `--primary-on-wash`.
|
|
22
|
+
*
|
|
23
|
+
* `orange` is where the rung half of that rule is spent, and the only place in
|
|
24
|
+
* `packages/vue/src` where a ramp rung carries **text** or is carried on. There are four other
|
|
25
|
+
* production sites that bind a rung — `grep -rnE -- '--brand|brand-alt' packages/vue/src`
|
|
26
|
+
* finds them, where a bare `--brand` misses the utilities:
|
|
27
|
+
*
|
|
28
|
+
* - `../rating/Rating.vue` draws a given star in `text-brand-alt`, which is a rung as ink.
|
|
29
|
+
* It is a glyph rather than text and clears the 3:1 a graphic needs in all six theme/mode
|
|
30
|
+
* pairs (3.04 at its floor, kingfisher light), with a shape cue beside the colour; the six
|
|
31
|
+
* figures and that judgement are in CLAUDE.md's invariant 3, item 1.
|
|
32
|
+
* - `../record-avatar/RecordAvatar.vue` takes `var(--brand-alt)` as a gradient stop and
|
|
33
|
+
* `../input/Input.vue` a 4% tint of `--brand` as a shadow. Nothing is read on either.
|
|
34
|
+
* - `../date-picker/CalendarPanel.vue` draws today's day with an inset ring of
|
|
35
|
+
* `--brand-alt`. A ring, not ink: the day's number is `--foreground`.
|
|
36
|
+
*
|
|
37
|
+
* The button's gradient and shadows name `--primary`, and the comment above its `brand`
|
|
38
|
+
* variant in `../button/index.ts` says why.
|
|
39
|
+
*
|
|
40
|
+
* `orange` itself draws the second brand ramp on a wash of itself —
|
|
41
|
+
* `--brand-alt-dark` on 10% `--brand-alt` in light,
|
|
42
|
+
* `--brand-alt-light` on 15% in dark — which is rung ink on a rung's wash, the shape the
|
|
43
|
+
* rule exists to forbid. There is no role pair to bind instead: the alternate ramp has
|
|
44
|
+
* rungs only. Nothing catches it either. The eight brand rungs are themselves
|
|
45
|
+
* contract roles, so `portability.test.ts` passes this line by construction — a rung being
|
|
46
|
+
* in the contract is a promise that every theme BINDS it, never a promise that anything is
|
|
47
|
+
* readable on it. Only `pairs` is that promise, and it covers the two `--primary` pairings
|
|
48
|
+
* and nothing else.
|
|
49
|
+
*
|
|
50
|
+
* So it was measured by hand, over `--background`, in all three shipped themes:
|
|
51
|
+
*
|
|
52
|
+
* light, `--brand-alt-dark` on 10%: kingfisher 3.40 graphite 6.99 noix 7.84
|
|
53
|
+
* dark, `--brand-alt-light` on 15%: kingfisher 7.38 graphite 7.42 noix 7.13
|
|
54
|
+
*
|
|
55
|
+
* kingfisher's light tone is therefore below AA — the 2.93 failure again, in the ramp that
|
|
56
|
+
* has no role to move to.
|
|
57
|
+
*
|
|
58
|
+
* `neutral` — the tone a badge gets when the caller names none — is the same exposure one
|
|
59
|
+
* step further in, and it took a reviewer rather than a gate to find it. `bg-muted` with
|
|
60
|
+
* `text-muted-foreground` is role on role, so nothing in this repository objects to it, and
|
|
61
|
+
* nothing measures it either: both tokens are names every theme binds, and only `pairs` is
|
|
62
|
+
* a promise about reading one on the other. Measured over `--muted`, same method as above:
|
|
63
|
+
*
|
|
64
|
+
* light: kingfisher 4.34 graphite 5.13 noix 5.09
|
|
65
|
+
* dark: kingfisher 5.83 graphite 6.21 noix 6.56
|
|
66
|
+
*
|
|
67
|
+
* kingfisher's light default is below AA as well. It is the same open palette decision, held
|
|
68
|
+
* together with the other four in `CLAUDE.md`'s invariant 3 rather than repaired here: the
|
|
69
|
+
* tone is drawn on every list screen, so moving either side of it is a look change across
|
|
70
|
+
* three themes.
|
|
71
|
+
*
|
|
72
|
+
* The `orange` pairing is deliberately NOT in `contract.json`'s `pairs`:
|
|
73
|
+
* added there the gate goes red on exactly that 3.40, and a red gate is not something this
|
|
74
|
+
* repository keeps. It also cannot be expressed there as the shape stands — a pair carries
|
|
75
|
+
* no mode, so the light ink would be measured against the dark wash too, which is a pairing
|
|
76
|
+
* nothing draws. Closing it means a decision across all three themes (a role pair for the
|
|
77
|
+
* alternate ramp, or a darker `--brand-alt-dark`), so it is written down here rather than
|
|
78
|
+
* quietly repaired or quietly left. Do not read it as licence for the next rung pairing.
|
|
79
|
+
*/
|
|
80
|
+
export const toneClasses = {
|
|
81
|
+
// The default tone, and role on role: 4.34:1 in kingfisher's light mode, below AA and
|
|
82
|
+
// ungated. The note above has the figures for all three themes.
|
|
83
|
+
neutral: 'bg-muted text-muted-foreground',
|
|
84
|
+
gray: 'bg-gray-100 text-gray-600 dark:bg-white/10 dark:text-white/70',
|
|
85
|
+
blue: 'bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300',
|
|
86
|
+
teal: 'bg-primary/10 text-primary-on-wash dark:bg-primary/15 dark:text-primary-on-wash',
|
|
87
|
+
// Rung ink on a rung's wash: the exception the note above measures and explains.
|
|
88
|
+
// 3.40:1 in kingfisher's light mode, which is below AA, and not gated by `pairs`.
|
|
89
|
+
orange: 'bg-brand-alt/10 text-brand-alt-dark dark:bg-brand-alt/15 dark:text-brand-alt-light',
|
|
90
|
+
purple: 'bg-purple-50 text-purple-700 dark:bg-purple-500/15 dark:text-purple-300',
|
|
91
|
+
green: 'bg-green-50 text-green-700 dark:bg-green-500/15 dark:text-green-300',
|
|
92
|
+
red: 'bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300',
|
|
93
|
+
} as const;
|
|
94
|
+
|
|
95
|
+
/** The tones a badge or a chip can carry. */
|
|
96
|
+
export type Tone = keyof typeof toneClasses;
|
|
97
|
+
|
|
98
|
+
export const badgeVariants = cva(
|
|
99
|
+
'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10.5px] font-bold whitespace-nowrap',
|
|
100
|
+
{
|
|
101
|
+
variants: { tone: toneClasses },
|
|
102
|
+
defaultVariants: { tone: 'neutral' },
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export type BadgeVariants = VariantProps<typeof badgeVariants>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useUiLabels } from '@noix-dev/brix-core';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Which build is on screen, as one small line for the foot of an application's navigation.
|
|
7
|
+
*
|
|
8
|
+
* The build comes in as two props and nothing else: the component reads no bundler constant and
|
|
9
|
+
* no bundler metadata object, because brix ships source and a consumer's bundler may not be the one that
|
|
10
|
+
* defines such a global (ADR 0017). An application with a build passes `version`, and `commit`
|
|
11
|
+
* where it has one; absent `version` means no build behind this screen, and the line says DEV
|
|
12
|
+
* instead of borrowing a number it cannot vouch for.
|
|
13
|
+
*
|
|
14
|
+
* COLOUR. Every colour is a role. The line is `text-muted-foreground`, the role for secondary
|
|
15
|
+
* text, so it is measured against the surface it sits on (the page or the sidebar), and the
|
|
16
|
+
* commit shares it, set apart by the mono face and not by tone. The DEV mark is a 10% wash of
|
|
17
|
+
* `--warning` with `--warning-on-wash` ink, exactly the share the contrast gate holds for that
|
|
18
|
+
* pair; the upstream drew 15%, a share nothing here measures. No `dark:` variant survives: the
|
|
19
|
+
* roles are rebound per mode.
|
|
20
|
+
*
|
|
21
|
+
* A record, not a live claim: measured on 2026-11-30 with the tokens package's own wash and
|
|
22
|
+
* contrast functions, over `--background` and over `--sidebar`, in kingfisher, graphite and noix,
|
|
23
|
+
* light and dark. DEV ink on its wash: 6.57:1 lowest (graphite, light, on the sidebar), 10.25:1
|
|
24
|
+
* highest. The line's `--muted-foreground`: 4.53:1 lowest (kingfisher, light, on the sidebar),
|
|
25
|
+
* 8.32:1 highest, against the 4.5:1 text bar. Nothing re-measures these; `pnpm theme:check` holds
|
|
26
|
+
* the DEV pair, not this line.
|
|
27
|
+
*/
|
|
28
|
+
const props = defineProps<{
|
|
29
|
+
/** The build's version. Absent means there is no build, and the mark says DEV. */
|
|
30
|
+
version?: string;
|
|
31
|
+
/** The short commit the build was cut from; null or absent where there is none to name. */
|
|
32
|
+
commit?: string | null;
|
|
33
|
+
}>();
|
|
34
|
+
|
|
35
|
+
const labels = useUiLabels();
|
|
36
|
+
|
|
37
|
+
const title = computed(() => {
|
|
38
|
+
if (props.version === undefined) {
|
|
39
|
+
return labels.value.buildStampDev;
|
|
40
|
+
}
|
|
41
|
+
const head = labels.value.buildStampTitle.replace('{version}', props.version);
|
|
42
|
+
|
|
43
|
+
return props.commit ? `${head} · ${props.commit}` : head;
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<p
|
|
49
|
+
data-slot="build-stamp"
|
|
50
|
+
:title="title"
|
|
51
|
+
class="text-muted-foreground px-2.5 py-1.5 text-[10px]"
|
|
52
|
+
>
|
|
53
|
+
<span
|
|
54
|
+
v-if="version === undefined"
|
|
55
|
+
class="bg-warning/10 text-warning-on-wash rounded px-1.5 py-0.5 font-bold tracking-wider"
|
|
56
|
+
>DEV</span
|
|
57
|
+
>
|
|
58
|
+
<template v-else
|
|
59
|
+
>{{ version }}<span v-if="commit" class="font-mono"> · {{ commit }}</span></template
|
|
60
|
+
>
|
|
61
|
+
</p>
|
|
62
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuildStamp } from './BuildStamp.vue';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import type { ButtonVariants } from '.';
|
|
5
|
+
import { Primitive } from 'reka-ui';
|
|
6
|
+
import { cn } from '../../lib/cn';
|
|
7
|
+
import { buttonVariants } from '.';
|
|
8
|
+
|
|
9
|
+
interface Props extends PrimitiveProps {
|
|
10
|
+
variant?: ButtonVariants['variant'];
|
|
11
|
+
size?: ButtonVariants['size'];
|
|
12
|
+
class?: HTMLAttributes['class'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
as: 'button',
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<Primitive
|
|
22
|
+
data-slot="button"
|
|
23
|
+
:data-variant="variant"
|
|
24
|
+
:data-size="size"
|
|
25
|
+
:as="as"
|
|
26
|
+
:as-child="asChild"
|
|
27
|
+
:class="cn(buttonVariants({ variant, size }), props.class)"
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</Primitive>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
export { default as Button } from './Button.vue';
|
|
5
|
+
|
|
6
|
+
// The focus and invalid treatments are CLAUDE.md's control-state recipe, and the figures
|
|
7
|
+
// behind both are there. Two things in this string are easy to "simplify" back into defects:
|
|
8
|
+
//
|
|
9
|
+
// `dark:aria-invalid:border-destructive` looks redundant beside
|
|
10
|
+
// `aria-invalid:border-destructive`, and is on every variant except `outline`: there
|
|
11
|
+
// `dark:border-input` outranks the bare utility in dark, so without it an invalid outline
|
|
12
|
+
// button's edge is `--input` at 1.48-1.82:1 against the page. With it: 6.32-7.50:1. Do not
|
|
13
|
+
// remove it, and do not give it an alpha (/50 measured 2.34-2.72:1).
|
|
14
|
+
//
|
|
15
|
+
// The focus ring is full strength and sits on a `--background` gap. It has no
|
|
16
|
+
// `focus-visible:border-ring` to help it, because this button's edge is transparent: a ring
|
|
17
|
+
// colour drawn on it measures 1.00 against the button's own `bg-primary` fill, `--ring` being
|
|
18
|
+
// the same value as `--primary` in five of the six theme/mode pairs. That border was the
|
|
19
|
+
// whole indication here, with a `ring-ring/50` halo at 1.79-3.92 behind it.
|
|
20
|
+
export const buttonVariants = cva(
|
|
21
|
+
'focus-visible:ring-ring focus-visible:ring-offset-background aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-2 focus-visible:ring-offset-2 aria-invalid:ring-3 active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*=size-])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
|
|
26
|
+
outline:
|
|
27
|
+
'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
|
|
28
|
+
secondary:
|
|
29
|
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
|
|
30
|
+
ghost: 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
|
|
31
|
+
// Role ink on a wash of itself: the shape `--destructive-on-wash` exists for, and
|
|
32
|
+
// the variant names it. That ink differs from `--destructive` in exactly one
|
|
33
|
+
// place, kingfisher light (`#d40014` against `#e30117`); graphite, noix and
|
|
34
|
+
// kingfisher dark alias it. So naming it moves one rendered colour in the whole
|
|
35
|
+
// system, and it is the one that read 4.11 (now 4.63).
|
|
36
|
+
//
|
|
37
|
+
// The wash is 10% in both modes. At 20% in dark, a button on a dialog's panel
|
|
38
|
+
// (`--popover`, lighter than the page in dark) measured 4.29 in graphite dark
|
|
39
|
+
// against 4.72 on a page; a component cannot know its host, so it clears the
|
|
40
|
+
// worse one. At 10% it is 5.09. Resting figures, ink on wash over the page / over a
|
|
41
|
+
// panel, light then dark, graphite / noix / kingfisher: light 5.58 / 4.87 / 4.63
|
|
42
|
+
// on both; dark 5.09 / 5.88 / 5.49 over a panel.
|
|
43
|
+
//
|
|
44
|
+
// NOT SOLVED: hover. `hover:bg-destructive/20` (`dark:hover:...30`) deepens the
|
|
45
|
+
// wash while the ink stays, so pointing at the button makes its label less
|
|
46
|
+
// readable. Under the ink above (`--destructive-on-wash`): 3.83 in kingfisher
|
|
47
|
+
// light, 3.58 in graphite dark on a panel (3.41 was the figure under the old
|
|
48
|
+
// `text-destructive`, and is stale). No alpha
|
|
49
|
+
// closes it (walking it down only returns toward the resting figure and erases
|
|
50
|
+
// the cue); it needs a different hover treatment, which is a design decision and
|
|
51
|
+
// is parked with the owner. The hover classes are deliberately left as they were.
|
|
52
|
+
// The focus ring is the base recipe's, not a tint of this variant's own hue:
|
|
53
|
+
// `ring-destructive/20` measured 1.38-1.44 against the page and the dark
|
|
54
|
+
// `/40` 1.95-2.15, so a variant that recoloured its own focus ring would be
|
|
55
|
+
// a variant with no visible focus. The fill and the ink carry the variant.
|
|
56
|
+
destructive:
|
|
57
|
+
'bg-destructive/10 hover:bg-destructive/20 dark:bg-destructive/10 text-destructive-on-wash dark:hover:bg-destructive/30',
|
|
58
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
59
|
+
// The one marketing-weight variant: full-width entry surfaces, sign-in
|
|
60
|
+
// above all.
|
|
61
|
+
//
|
|
62
|
+
// Fill and ink are the primary role pair, not a brand rung, because that
|
|
63
|
+
// pair is the one a theme guarantees is readable together — white on a
|
|
64
|
+
// mid-brand hue is not. `contract.json` gates it in every theme and both
|
|
65
|
+
// modes, so this variant cannot go below AA without `pnpm theme:check`
|
|
66
|
+
// saying so.
|
|
67
|
+
//
|
|
68
|
+
// The second gradient stop has no role of its own, so it is computed
|
|
69
|
+
// from the first: 84% of `--primary` mixed away from the ink's end of the
|
|
70
|
+
// scale — toward black under a light mode's light ink, toward white under
|
|
71
|
+
// a dark mode's dark ink. Moving away from the ink is monotone in
|
|
72
|
+
// contrast, so if the gated pair clears AA the far corner clears it too.
|
|
73
|
+
// 84% was chosen by measurement, as the mix that reproduces the palette
|
|
74
|
+
// this variant was first drawn for (#0d4f4f -> #083d3d, two 8-bit steps
|
|
75
|
+
// from its old #0a3d3d).
|
|
76
|
+
//
|
|
77
|
+
// A raw CSS value names the role token (`var(--primary)`) and not the
|
|
78
|
+
// Tailwind colour name (`--color-primary`): `inline` in the token wiring
|
|
79
|
+
// is documented as not emitting the alias, so a value that leant on it
|
|
80
|
+
// would be leaning on an implementation detail that has already moved
|
|
81
|
+
// inside Tailwind 4.x, and a role token reads here exactly as it reads in
|
|
82
|
+
// every theme file.
|
|
83
|
+
//
|
|
84
|
+
// The two shadows are elevation under this button's own fill, so they tint
|
|
85
|
+
// from the same role: `color-mix(in srgb, <hue> 55%, transparent)` is the
|
|
86
|
+
// same colour as that hue at `alpha: 0.55`. `--brand` would be a
|
|
87
|
+
// different hue wherever a theme binds `--primary` to another rung, and a
|
|
88
|
+
// literal `rgba()` would be one palette's hue in every theme. (The large
|
|
89
|
+
// input's shadow still names `--brand`: a brand tint on a neutral field
|
|
90
|
+
// is not elevation under a fill.)
|
|
91
|
+
//
|
|
92
|
+
// `disabled:shadow-none` is what makes an empty form read as "waiting"
|
|
93
|
+
// rather than "broken": a faded gradient that still casts a lifted
|
|
94
|
+
// shadow looks like a rendering glitch. Dropping the shadow is this
|
|
95
|
+
// variant's own disabled treatment; the fade is the recipe's `opacity-50`
|
|
96
|
+
// from the base, the same as every other control.
|
|
97
|
+
brand: 'bg-[linear-gradient(135deg,var(--primary)_0%,color-mix(in_oklab,var(--primary)_84%,black)_100%)] dark:bg-[linear-gradient(135deg,var(--primary)_0%,color-mix(in_oklab,var(--primary)_84%,white)_100%)] text-primary-foreground shadow-[0_8px_18px_-8px_color-mix(in_srgb,var(--primary)_55%,transparent)] hover:shadow-[0_10px_22px_-8px_color-mix(in_srgb,var(--primary)_65%,transparent)] disabled:shadow-none',
|
|
98
|
+
},
|
|
99
|
+
size: {
|
|
100
|
+
default:
|
|
101
|
+
'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
|
102
|
+
xs: 'h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3',
|
|
103
|
+
sm: 'h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3.5',
|
|
104
|
+
lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
|
105
|
+
icon: 'size-8',
|
|
106
|
+
'icon-xs':
|
|
107
|
+
'size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*=size-])]:size-3',
|
|
108
|
+
'icon-sm':
|
|
109
|
+
'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
|
|
110
|
+
'icon-lg': 'size-9',
|
|
111
|
+
// Pairs with the `brand` variant on full-width entry surfaces; dense
|
|
112
|
+
// screens stay on the compact sizes above.
|
|
113
|
+
xl: 'h-13 gap-2.5 rounded-xl px-5 text-[15px] font-bold [&_svg:not([class*=size-])]:size-[18px]',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
defaultVariants: {
|
|
117
|
+
variant: 'default',
|
|
118
|
+
size: 'default',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|