@alepha/ui 0.36.0 → 0.37.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/dist/account/$pageAccount.d.ts +1 -1
- package/dist/account/$pageAccount.d.ts.map +1 -1
- package/dist/account/$pageAccount.js.map +1 -1
- package/dist/account/AccountDisplay.d.ts +13 -0
- package/dist/account/AccountDisplay.d.ts.map +1 -0
- package/dist/account/AccountDisplay.js +48 -0
- package/dist/account/AccountDisplay.js.map +1 -0
- package/dist/account/AccountProfile.d.ts.map +1 -1
- package/dist/account/AccountProfile.js +14 -10
- package/dist/account/AccountProfile.js.map +1 -1
- package/dist/account/AccountRouter.d.ts +6 -6
- package/dist/account/AccountRouter.d.ts.map +1 -1
- package/dist/account/index.d.ts +5 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +2 -1
- package/dist/admin/$pageAdmin.d.ts +1 -1
- package/dist/admin/$pageAdmin.d.ts.map +1 -1
- package/dist/admin/$pageAdmin.js.map +1 -1
- package/dist/admin/AdminAudits.js.map +1 -1
- package/dist/admin/AdminJobDetail.js.map +1 -1
- package/dist/admin/AdminJobs.js.map +1 -1
- package/dist/admin/AdminNotifications.js.map +1 -1
- package/dist/admin/AdminRouter.d.ts +14 -14
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/ParameterHistoryItem.js.map +1 -1
- package/dist/ai/AiChat.d.ts +26 -39
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +65 -123
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatDock.d.ts +23 -0
- package/dist/ai/AiChatDock.d.ts.map +1 -0
- package/dist/ai/AiChatDock.js +90 -0
- package/dist/ai/AiChatDock.js.map +1 -0
- package/dist/ai/AiChatDockSlot.d.ts +15 -0
- package/dist/ai/AiChatDockSlot.d.ts.map +1 -0
- package/dist/ai/AiChatDockSlot.js +20 -0
- package/dist/ai/AiChatDockSlot.js.map +1 -0
- package/dist/ai/AiChatLauncher.d.ts +17 -0
- package/dist/ai/AiChatLauncher.d.ts.map +1 -0
- package/dist/ai/AiChatLauncher.js +42 -0
- package/dist/ai/AiChatLauncher.js.map +1 -0
- package/dist/ai/AiChatMessage.d.ts +7 -1
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +27 -7
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/AiChatPanel.d.ts +71 -0
- package/dist/ai/AiChatPanel.d.ts.map +1 -0
- package/dist/ai/AiChatPanel.js +143 -0
- package/dist/ai/AiChatPanel.js.map +1 -0
- package/dist/ai/index.d.ts +8 -4
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -1
- package/dist/ai/useAiChat.d.ts +17 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +38 -17
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/auth/AuthLogin.d.ts +9 -0
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +2 -2
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthRegister.d.ts +4 -1
- package/dist/auth/AuthRegister.d.ts.map +1 -1
- package/dist/auth/AuthRegister.js +1 -1
- package/dist/auth/AuthRegister.js.map +1 -1
- package/dist/auth/AuthResetPassword.d.ts +8 -0
- package/dist/auth/AuthResetPassword.d.ts.map +1 -1
- package/dist/auth/AuthResetPassword.js +2 -2
- package/dist/auth/AuthResetPassword.js.map +1 -1
- package/dist/auth/AuthRouter.d.ts +4 -4
- package/dist/auth/AuthRouter.d.ts.map +1 -1
- package/dist/core/Badge.d.ts.map +1 -1
- package/dist/core/Badge.js +7 -3
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Collapsible.d.ts +50 -0
- package/dist/core/Collapsible.d.ts.map +1 -0
- package/dist/core/Collapsible.js +70 -0
- package/dist/core/Collapsible.js.map +1 -0
- package/dist/core/Combobox.d.ts +7 -1
- package/dist/core/Combobox.d.ts.map +1 -1
- package/dist/core/Combobox.js +2 -2
- package/dist/core/Combobox.js.map +1 -1
- package/dist/core/PaneRail.d.ts +24 -7
- package/dist/core/PaneRail.d.ts.map +1 -1
- package/dist/core/PaneRail.js +24 -19
- package/dist/core/PaneRail.js.map +1 -1
- package/dist/core/Stepper.d.ts +36 -0
- package/dist/core/Stepper.d.ts.map +1 -0
- package/dist/core/Stepper.js +54 -0
- package/dist/core/Stepper.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/useToast.js +13 -13
- package/dist/core/useToast.js.map +1 -1
- package/dist/form/AutoForm.d.ts.map +1 -1
- package/dist/form/AutoForm.js +29 -0
- package/dist/form/AutoForm.js.map +1 -1
- package/dist/form/AutoFormErrorPopover.js +13 -3
- package/dist/form/AutoFormErrorPopover.js.map +1 -1
- package/dist/form/Control.d.ts +14 -1
- package/dist/form/Control.d.ts.map +1 -1
- package/dist/form/Control.js +12 -2
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlDate.d.ts.map +1 -1
- package/dist/form/ControlDate.js +3 -0
- package/dist/form/ControlDate.js.map +1 -1
- package/dist/form/ControlDateRange.d.ts +12 -1
- package/dist/form/ControlDateRange.d.ts.map +1 -1
- package/dist/form/ControlDateRange.js +11 -1
- package/dist/form/ControlDateRange.js.map +1 -1
- package/dist/form/ControlNumber.d.ts.map +1 -1
- package/dist/form/ControlNumber.js +2 -0
- package/dist/form/ControlNumber.js.map +1 -1
- package/dist/form/ControlObject.d.ts.map +1 -1
- package/dist/form/ControlObject.js +15 -1
- package/dist/form/ControlObject.js.map +1 -1
- package/dist/form/ControlPassword.d.ts +4 -0
- package/dist/form/ControlPassword.d.ts.map +1 -1
- package/dist/form/ControlPassword.js +1 -0
- package/dist/form/ControlPassword.js.map +1 -1
- package/dist/form/ControlSelect.d.ts +23 -1
- package/dist/form/ControlSelect.d.ts.map +1 -1
- package/dist/form/ControlSelect.js +5 -0
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlSelectCombobox.d.ts +11 -1
- package/dist/form/ControlSelectCombobox.d.ts.map +1 -1
- package/dist/form/ControlSelectCombobox.js +9 -1
- package/dist/form/ControlSelectCombobox.js.map +1 -1
- package/dist/form/ControlUpload.d.ts.map +1 -1
- package/dist/form/ControlUpload.js +1 -0
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/form/FormField.d.ts +5 -0
- package/dist/form/FormField.d.ts.map +1 -1
- package/dist/form/FormField.js +7 -0
- package/dist/form/FormField.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +15 -0
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/shell/$pageNav.d.ts +2 -2
- package/dist/shell/$pageNav.d.ts.map +1 -1
- package/dist/shell/$pageNav.js.map +1 -1
- package/dist/shell/AppShell.d.ts +6 -0
- package/dist/shell/AppShell.d.ts.map +1 -1
- package/dist/shell/AppShell.js +31 -27
- package/dist/shell/AppShell.js.map +1 -1
- package/dist/shell/ButtonSettings.d.ts +6 -2
- package/dist/shell/ButtonSettings.d.ts.map +1 -1
- package/dist/shell/ButtonSettings.js +17 -3
- package/dist/shell/ButtonSettings.js.map +1 -1
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts +16 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts.map +1 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js +24 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js.map +1 -0
- package/dist/shell/ButtonVision.d.ts +28 -0
- package/dist/shell/ButtonVision.d.ts.map +1 -0
- package/dist/shell/ButtonVision.js +46 -0
- package/dist/shell/ButtonVision.js.map +1 -0
- package/dist/shell/index.d.ts +6 -3
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -1
- package/dist/styles.css +57 -0
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +29 -4
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableColumnPicker.d.ts.map +1 -1
- package/dist/table/DataTableColumnPicker.js +1 -0
- package/dist/table/DataTableColumnPicker.js.map +1 -1
- package/dist/table/DataTableFilterBar.d.ts +1 -1
- package/dist/table/DataTableFilterBar.d.ts.map +1 -1
- package/dist/table/DataTableFilterBar.js +5 -108
- package/dist/table/DataTableFilterBar.js.map +1 -1
- package/dist/table/DataTableHeaderFilter.d.ts +51 -0
- package/dist/table/DataTableHeaderFilter.d.ts.map +1 -0
- package/dist/table/DataTableHeaderFilter.js +113 -0
- package/dist/table/DataTableHeaderFilter.js.map +1 -0
- package/dist/table/DataTableHeaderRow.d.ts +7 -0
- package/dist/table/DataTableHeaderRow.d.ts.map +1 -1
- package/dist/table/DataTableHeaderRow.js +92 -74
- package/dist/table/DataTableHeaderRow.js.map +1 -1
- package/dist/table/DataTableTabs.d.ts +42 -0
- package/dist/table/DataTableTabs.d.ts.map +1 -0
- package/dist/table/DataTableTabs.js +55 -0
- package/dist/table/DataTableTabs.js.map +1 -0
- package/dist/table/dataTableBaseProps.d.ts +12 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.js +4 -2
- package/dist/table/dataTablePersistence.js.map +1 -1
- package/dist/table/dataTableTypes.d.ts +18 -0
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/index.d.ts +5 -2
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +2 -1
- package/dist/table/useDataTableColumns.d.ts.map +1 -1
- package/dist/table/useDataTableColumns.js +1 -0
- package/dist/table/useDataTableColumns.js.map +1 -1
- package/dist/table/useDataTableFilterModel.d.ts +110 -0
- package/dist/table/useDataTableFilterModel.d.ts.map +1 -0
- package/dist/table/useDataTableFilterModel.js +154 -0
- package/dist/table/useDataTableFilterModel.js.map +1 -0
- package/docs/packages-alepha-ui-account.md +4 -0
- package/docs/packages-alepha-ui-ai.md +5 -5
- package/docs/packages-alepha-ui-shell.md +4 -3
- package/docs/packages-alepha-ui-table.md +4 -2
- package/package.json +8 -8
- package/src/account/$pageAccount.tsx +5 -4
- package/src/account/AccountDisplay.tsx +58 -0
- package/src/account/AccountProfile.tsx +30 -42
- package/src/account/__tests__/AccountProfile.browser.spec.tsx +141 -0
- package/src/account/__tests__/AccountRecoveryCodes.browser.spec.tsx +1 -1
- package/src/account/index.ts +5 -0
- package/src/admin/$pageAdmin.tsx +5 -4
- package/src/admin/AdminAudits.tsx +1 -1
- package/src/admin/AdminJobDetail.tsx +1 -1
- package/src/admin/AdminJobs.tsx +1 -1
- package/src/admin/AdminNotifications.tsx +1 -1
- package/src/admin/AdminUserDetail.tsx +1 -1
- package/src/admin/AdminUsers.tsx +1 -1
- package/src/admin/ParameterHistoryItem.tsx +1 -1
- package/src/admin/__tests__/AdminFilesUsageCard.browser.spec.tsx +17 -9
- package/src/ai/AiChat.tsx +94 -183
- package/src/ai/AiChatDock.tsx +129 -0
- package/src/ai/AiChatDockSlot.tsx +23 -0
- package/src/ai/AiChatLauncher.tsx +58 -0
- package/src/ai/AiChatMessage.tsx +48 -9
- package/src/ai/AiChatPanel.tsx +252 -0
- package/src/ai/__tests__/AiChat.browser.spec.tsx +197 -5
- package/src/ai/index.ts +8 -4
- package/src/ai/useAiChat.ts +80 -14
- package/src/auth/AuthLogin.tsx +19 -4
- package/src/auth/AuthRegister.tsx +6 -3
- package/src/auth/AuthResetPassword.tsx +18 -8
- package/src/auth/__tests__/AuthCancel.browser.spec.tsx +129 -0
- package/src/core/Badge.tsx +7 -3
- package/src/core/Collapsible.tsx +95 -0
- package/src/core/Combobox.tsx +11 -3
- package/src/core/PaneRail.tsx +36 -20
- package/src/core/Stepper.tsx +118 -0
- package/src/core/__tests__/Badge.browser.spec.tsx +5 -5
- package/src/core/__tests__/Collapsible.browser.spec.tsx +88 -0
- package/src/core/__tests__/PaneRail.browser.spec.tsx +48 -0
- package/src/core/__tests__/Stepper.browser.spec.tsx +39 -0
- package/src/core/__tests__/primitiveSlots.spec.ts +7 -0
- package/src/core/index.ts +15 -0
- package/src/form/AutoForm.tsx +32 -0
- package/src/form/AutoFormErrorPopover.tsx +27 -6
- package/src/form/Control.tsx +22 -0
- package/src/form/ControlDate.tsx +3 -0
- package/src/form/ControlDateRange.tsx +87 -58
- package/src/form/ControlNumber.tsx +2 -0
- package/src/form/ControlObject.tsx +20 -1
- package/src/form/ControlPassword.tsx +5 -0
- package/src/form/ControlSelect.tsx +32 -1
- package/src/form/ControlSelectCombobox.tsx +82 -56
- package/src/form/ControlUpload.tsx +1 -0
- package/src/form/FormField.tsx +23 -1
- package/src/form/__tests__/ControlFieldErrors.browser.spec.tsx +253 -0
- package/src/form/__tests__/ControlValidateMode.browser.spec.tsx +217 -0
- package/src/form/__tests__/ControlVariantErrors.browser.spec.tsx +133 -0
- package/src/i18n/fr/uiFr.ts +19 -1
- package/src/markdown/css.d.ts +11 -0
- package/src/shell/$pageNav.tsx +6 -4
- package/src/shell/AppShell.tsx +7 -0
- package/src/shell/ButtonSettings.tsx +20 -5
- package/src/shell/ButtonSettingsVisionMenuItem.tsx +40 -0
- package/src/shell/ButtonVision.tsx +73 -0
- package/src/shell/__tests__/ButtonSettings.browser.spec.tsx +42 -2
- package/src/shell/__tests__/ButtonVision.browser.spec.tsx +73 -0
- package/src/shell/__tests__/visionTokens.spec.ts +104 -0
- package/src/shell/index.ts +6 -3
- package/src/styles.css +57 -0
- package/src/table/DataTable.tsx +52 -4
- package/src/table/DataTableColumnPicker.tsx +3 -0
- package/src/table/DataTableFilterBar.tsx +18 -191
- package/src/table/DataTableHeaderFilter.tsx +156 -0
- package/src/table/DataTableHeaderRow.tsx +78 -40
- package/src/table/DataTableTabs.tsx +114 -0
- package/src/table/__tests__/DataTableHeaderFilter.browser.spec.tsx +174 -0
- package/src/table/__tests__/DataTableStaleColumns.browser.spec.tsx +80 -0
- package/src/table/__tests__/DataTableTabs.browser.spec.tsx +72 -0
- package/src/table/dataTableBaseProps.ts +12 -0
- package/src/table/dataTablePersistence.ts +11 -5
- package/src/table/dataTableTypes.ts +18 -0
- package/src/table/index.ts +9 -2
- package/src/table/useDataTableColumns.ts +1 -0
- package/src/table/useDataTableFilterModel.tsx +240 -0
package/src/shell/$pageNav.tsx
CHANGED
|
@@ -14,7 +14,8 @@ export interface PageNavOptions<
|
|
|
14
14
|
TConfig extends PageConfigSchema = PageConfigSchema,
|
|
15
15
|
TProps extends object = TPropsDefault,
|
|
16
16
|
TPropsParent extends object = TPropsParentDefault,
|
|
17
|
-
|
|
17
|
+
TName extends string = string,
|
|
18
|
+
> extends PagePrimitiveOptions<TConfig, TProps, TPropsParent, TName> {
|
|
18
19
|
/**
|
|
19
20
|
* Nav metadata, widened to {@link NavMeta} so an entry can name the
|
|
20
21
|
* catalogue keys the shell resolves for its label and its group heading.
|
|
@@ -46,9 +47,10 @@ export const $pageNav = <
|
|
|
46
47
|
TConfig extends PageConfigSchema = PageConfigSchema,
|
|
47
48
|
TProps extends object = TPropsDefault,
|
|
48
49
|
TPropsParent extends object = TPropsParentDefault,
|
|
50
|
+
TName extends string = string,
|
|
49
51
|
>(
|
|
50
|
-
options: PageNavOptions<TConfig, TProps, TPropsParent>,
|
|
51
|
-
): PagePrimitive<TConfig, TProps, TPropsParent> => {
|
|
52
|
+
options: PageNavOptions<TConfig, TProps, TPropsParent, TName>,
|
|
53
|
+
): PagePrimitive<TConfig, TProps, TPropsParent, TName> => {
|
|
52
54
|
const { permission, use, nav, ...rest } = options;
|
|
53
55
|
const permissions = permission
|
|
54
56
|
? Array.isArray(permission)
|
|
@@ -56,7 +58,7 @@ export const $pageNav = <
|
|
|
56
58
|
: [permission]
|
|
57
59
|
: undefined;
|
|
58
60
|
|
|
59
|
-
return $page<TConfig, TProps, TPropsParent>({
|
|
61
|
+
return $page<TConfig, TProps, TPropsParent, TName>({
|
|
60
62
|
...rest,
|
|
61
63
|
use: permissions ? [$secure({ permissions }), ...(use ?? [])] : use,
|
|
62
64
|
nav: nav ? { ...nav, permission: nav.permission ?? permission } : nav,
|
package/src/shell/AppShell.tsx
CHANGED
|
@@ -119,6 +119,12 @@ export interface AppShellProps {
|
|
|
119
119
|
* Top-bar right-side content (search, theme toggle, user menu).
|
|
120
120
|
*/
|
|
121
121
|
topbarActions?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* A column on the right of the page, beside it rather than over it: the
|
|
124
|
+
* page narrows to make room. Where an app docks a panel that works with
|
|
125
|
+
* the page, such as `AiChatDockSlot` for the assistant.
|
|
126
|
+
*/
|
|
127
|
+
aside?: ReactNode;
|
|
122
128
|
/**
|
|
123
129
|
* Layout variant.
|
|
124
130
|
* - `sidebar` (default): sidebar and page sit flush side-by-side.
|
|
@@ -377,6 +383,7 @@ export const AppShell = (props: AppShellProps) => {
|
|
|
377
383
|
{mainNode}
|
|
378
384
|
</SidebarInset>
|
|
379
385
|
)}
|
|
386
|
+
{props.aside}
|
|
380
387
|
</SidebarProvider>
|
|
381
388
|
</>
|
|
382
389
|
);
|
|
@@ -14,8 +14,10 @@ import { ButtonLanguage } from "./ButtonLanguage.tsx";
|
|
|
14
14
|
import { ButtonSettingsColorModeMenu } from "./ButtonSettingsColorModeMenu.tsx";
|
|
15
15
|
import { ButtonSettingsLanguageMenu } from "./ButtonSettingsLanguageMenu.tsx";
|
|
16
16
|
import { ButtonSettingsThemeMenu } from "./ButtonSettingsThemeMenu.tsx";
|
|
17
|
+
import { ButtonSettingsVisionMenuItem } from "./ButtonSettingsVisionMenuItem.tsx";
|
|
17
18
|
import { ButtonTheme } from "./ButtonTheme.tsx";
|
|
18
19
|
import { ButtonUser } from "./ButtonUser.tsx";
|
|
20
|
+
import { ButtonVision } from "./ButtonVision.tsx";
|
|
19
21
|
|
|
20
22
|
export interface ButtonSettingsProps {
|
|
21
23
|
/**
|
|
@@ -66,7 +68,8 @@ export interface ButtonSettingsProps {
|
|
|
66
68
|
* default and French through `uiFr`, so the admin console and the account
|
|
67
69
|
* area are localised without passing any. `language`, `theme` and
|
|
68
70
|
* `colorMode` name the control in both placements: the submenu in the
|
|
69
|
-
* menu, the tooltip and `aria-label` as a button.
|
|
71
|
+
* menu, the tooltip and `aria-label` as a button. `vision` names the
|
|
72
|
+
* colour-blind button, which only exists as a button.
|
|
70
73
|
*/
|
|
71
74
|
labels?: {
|
|
72
75
|
signIn?: string;
|
|
@@ -80,6 +83,7 @@ export interface ButtonSettingsProps {
|
|
|
80
83
|
colorModeSystem?: string;
|
|
81
84
|
colorModeDark?: string;
|
|
82
85
|
colorModeLight?: string;
|
|
86
|
+
vision?: string;
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
/**
|
|
@@ -92,7 +96,7 @@ export interface ButtonSettingsProps {
|
|
|
92
96
|
/**
|
|
93
97
|
* Below `sm`, drop the settings BUTTONS and keep only the account button.
|
|
94
98
|
* It never touches the menu, so a signed-in viewer on a phone still reaches
|
|
95
|
-
* all
|
|
99
|
+
* all of them there under the default `placement`.
|
|
96
100
|
*/
|
|
97
101
|
compact?: boolean;
|
|
98
102
|
|
|
@@ -108,8 +112,8 @@ export interface ButtonSettingsProps {
|
|
|
108
112
|
* The account button with the viewer's settings attached: language, theme
|
|
109
113
|
* and display mode, wrapped around {@link ButtonUser}.
|
|
110
114
|
*
|
|
111
|
-
* Signed out, it draws
|
|
112
|
-
*
|
|
115
|
+
* Signed out, it draws icon buttons: language, theme, dark mode,
|
|
116
|
+
* colour-blind mode (`ButtonVision`), sign in. Signed in, it draws ONE button, the avatar, and
|
|
113
117
|
* the settings move into its menu:
|
|
114
118
|
*
|
|
115
119
|
* ```
|
|
@@ -124,6 +128,12 @@ export interface ButtonSettingsProps {
|
|
|
124
128
|
* Logout
|
|
125
129
|
* ```
|
|
126
130
|
*
|
|
131
|
+
* Colour-blind mode is not in that menu: it is set once, so a signed-in
|
|
132
|
+
* viewer finds it on the account page (`AccountDisplay`, on the profile). A
|
|
133
|
+
* signed-out visitor has no account page, and keeps the `ButtonVision` icon.
|
|
134
|
+
* `ButtonSettings.VisionMenuItem` is still exported for an application that
|
|
135
|
+
* wants the item among its own `children`.
|
|
136
|
+
*
|
|
127
137
|
* Pass `placement="buttons"` to keep them as buttons once signed in too.
|
|
128
138
|
*
|
|
129
139
|
* Each part still decides whether it has anything to offer: language and
|
|
@@ -162,6 +172,9 @@ export const ButtonSettings = (props: ButtonSettingsProps) => {
|
|
|
162
172
|
colorModeLight:
|
|
163
173
|
given.colorModeLight ??
|
|
164
174
|
tr("shell.settings.colorModeLight", { default: "Light" }),
|
|
175
|
+
vision:
|
|
176
|
+
given.vision ??
|
|
177
|
+
tr("shell.settings.vision", { default: "Colour-blind mode" }),
|
|
165
178
|
};
|
|
166
179
|
const variant = props.variant ?? "minimal";
|
|
167
180
|
const inMenu = !!auth.user && (props.placement ?? "menu") === "menu";
|
|
@@ -170,12 +183,13 @@ export const ButtonSettings = (props: ButtonSettingsProps) => {
|
|
|
170
183
|
<div className={cn("flex items-center gap-1", props.className)}>
|
|
171
184
|
{props.before}
|
|
172
185
|
{!inMenu && (
|
|
173
|
-
// `contents` keeps the
|
|
186
|
+
// `contents` keeps the four direct children of the flex row and its
|
|
174
187
|
// `gap-1`; `hidden` wins over it below the breakpoint.
|
|
175
188
|
<div className={cn(props.compact ? "hidden sm:contents" : "contents")}>
|
|
176
189
|
<ButtonLanguage variant={variant} label={labels.language} />
|
|
177
190
|
<ButtonTheme variant={variant} label={labels.theme} />
|
|
178
191
|
<ButtonDark variant={variant} label={labels.colorMode} />
|
|
192
|
+
<ButtonVision variant={variant} label={labels.vision} />
|
|
179
193
|
</div>
|
|
180
194
|
)}
|
|
181
195
|
<ButtonUser
|
|
@@ -218,3 +232,4 @@ export const ButtonSettings = (props: ButtonSettingsProps) => {
|
|
|
218
232
|
ButtonSettings.LanguageMenu = ButtonSettingsLanguageMenu;
|
|
219
233
|
ButtonSettings.ThemeMenu = ButtonSettingsThemeMenu;
|
|
220
234
|
ButtonSettings.ColorModeMenu = ButtonSettingsColorModeMenu;
|
|
235
|
+
ButtonSettings.VisionMenuItem = ButtonSettingsVisionMenuItem;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
void React;
|
|
4
|
+
|
|
5
|
+
import { useVisionMode } from "alepha/react/ui";
|
|
6
|
+
import { Eye } from "lucide-react";
|
|
7
|
+
|
|
8
|
+
import { DropdownMenuCheckboxItem } from "../core/DropdownMenu.tsx";
|
|
9
|
+
|
|
10
|
+
export interface ButtonSettingsVisionMenuItemProps {
|
|
11
|
+
/**
|
|
12
|
+
* Item label. Defaults to `"Colour-blind mode"`.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The vision mode as a checkbox item of the account menu: checked while the
|
|
19
|
+
* colour-blind palette is on, through `useVisionMode()`.
|
|
20
|
+
*
|
|
21
|
+
* Reading the mode during render is safe here, as in the color-mode submenu:
|
|
22
|
+
* the menu mounts only when opened, so the server never renders it.
|
|
23
|
+
*/
|
|
24
|
+
export const ButtonSettingsVisionMenuItem = (
|
|
25
|
+
props: ButtonSettingsVisionMenuItemProps,
|
|
26
|
+
) => {
|
|
27
|
+
const { vision, setVision } = useVisionMode();
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<DropdownMenuCheckboxItem
|
|
31
|
+
checked={vision === "cvd"}
|
|
32
|
+
onCheckedChange={(checked: boolean) =>
|
|
33
|
+
setVision(checked ? "cvd" : "normal")
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
<Eye className="size-4" />
|
|
37
|
+
{props.label ?? "Colour-blind mode"}
|
|
38
|
+
</DropdownMenuCheckboxItem>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
void React;
|
|
4
|
+
|
|
5
|
+
import { useVisionMode } from "alepha/react/ui";
|
|
6
|
+
import { Eye, EyeOff } from "lucide-react";
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
|
|
9
|
+
import { Button } from "../core/Button.tsx";
|
|
10
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../core/Tooltip.tsx";
|
|
11
|
+
|
|
12
|
+
export interface ButtonVisionProps {
|
|
13
|
+
/**
|
|
14
|
+
* Optional aria-label override. Defaults to `"Colour-blind mode"`.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Visual variant. Defaults to `"minimal"`. Pass `"outlined"` for a
|
|
19
|
+
* bordered toolbar look.
|
|
20
|
+
*/
|
|
21
|
+
variant?: "minimal" | "outlined";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Both icons, always rendered, with the `cvd` class on `<html>` revealing
|
|
26
|
+
* one: the vision mode is a paint, not a render, for the reason
|
|
27
|
+
* `ButtonDark` gives. A prerendered page carries the default icon, and the
|
|
28
|
+
* boot script has already set the class from the cookie by first paint, so
|
|
29
|
+
* the visitor sees their own state with no hydration mismatch.
|
|
30
|
+
*/
|
|
31
|
+
const ICONS: ReactNode = (
|
|
32
|
+
<>
|
|
33
|
+
<Eye className="size-4 [.cvd_&]:hidden" />
|
|
34
|
+
<EyeOff className="hidden size-4 [.cvd_&]:block" />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Colour-blind mode toggle: flips the vision mode between `normal` and `cvd`
|
|
40
|
+
* through `useVisionMode()`, persisted in the UI cookie beside the color mode
|
|
41
|
+
* and the theme, and independent of both.
|
|
42
|
+
*
|
|
43
|
+
* `cvd` puts the class `cvd` on `<html>`, under which the kit's stylesheet
|
|
44
|
+
* swaps its signal colours (success, warning, danger, the chart palette) for
|
|
45
|
+
* a colour-blind-safe palette. An app remaps its own signal tokens in a
|
|
46
|
+
* `.cvd` block (and `.cvd.dark` for dark mode).
|
|
47
|
+
*
|
|
48
|
+
* `aria-pressed` reports the state to assistive technology. It reads the
|
|
49
|
+
* default until hydration has committed, like every UI preference (see
|
|
50
|
+
* `useUiState`), and the visitor's value right after.
|
|
51
|
+
*/
|
|
52
|
+
export const ButtonVision = (props: ButtonVisionProps) => {
|
|
53
|
+
const { vision, toggle } = useVisionMode();
|
|
54
|
+
const label = props.label ?? "Colour-blind mode";
|
|
55
|
+
return (
|
|
56
|
+
<Tooltip>
|
|
57
|
+
<TooltipTrigger
|
|
58
|
+
render={
|
|
59
|
+
<Button
|
|
60
|
+
variant={props.variant ?? "minimal"}
|
|
61
|
+
size="icon"
|
|
62
|
+
aria-label={label}
|
|
63
|
+
aria-pressed={vision === "cvd"}
|
|
64
|
+
onClick={toggle}
|
|
65
|
+
/>
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
{ICONS}
|
|
69
|
+
</TooltipTrigger>
|
|
70
|
+
<TooltipContent>{label}</TooltipContent>
|
|
71
|
+
</Tooltip>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
1
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
2
2
|
import { Alepha } from "alepha";
|
|
3
3
|
import { AlephaContext } from "alepha/react";
|
|
4
4
|
import { AlephaReactI18n } from "alepha/react/i18n";
|
|
5
5
|
import { AlephaReactRouter } from "alepha/react/router";
|
|
6
|
-
import { AlephaReactUi } from "alepha/react/ui";
|
|
6
|
+
import { AlephaReactUi, uiAtom } from "alepha/react/ui";
|
|
7
7
|
import { setupJsdomMocks } from "alepha/testing/react";
|
|
8
8
|
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
9
9
|
|
|
@@ -118,4 +118,44 @@ describe("ButtonSettings", () => {
|
|
|
118
118
|
expect(screen.getByRole("menuitemradio", { name: "Sombre" })).toBeTruthy();
|
|
119
119
|
expect(screen.getByRole("menuitemradio", { name: "Clair" })).toBeTruthy();
|
|
120
120
|
});
|
|
121
|
+
|
|
122
|
+
it("draws the colour-blind toggle beside display mode when signed out", async () => {
|
|
123
|
+
await mount({ signedIn: false });
|
|
124
|
+
|
|
125
|
+
expect(screen.getByLabelText("Colour-blind mode")).toBeTruthy();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("keeps colour-blind mode out of the signed-in menu: it lives on the account page", async () => {
|
|
129
|
+
await mount({ signedIn: true });
|
|
130
|
+
// No button either: signed in, the settings are not drawn as buttons.
|
|
131
|
+
expect(screen.queryByLabelText("Colour-blind mode")).toBeNull();
|
|
132
|
+
|
|
133
|
+
openMenu();
|
|
134
|
+
// The menu is open (its display-mode submenu is there) and has no such item.
|
|
135
|
+
expect(
|
|
136
|
+
await screen.findByRole("menuitem", { name: "Display Mode" }),
|
|
137
|
+
).toBeTruthy();
|
|
138
|
+
expect(
|
|
139
|
+
screen.queryByRole("menuitemcheckbox", { name: "Colour-blind mode" }),
|
|
140
|
+
).toBeNull();
|
|
141
|
+
expect(screen.queryByText("Colour-blind mode")).toBeNull();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("keeps the colour-blind button when placement is 'buttons'", async () => {
|
|
145
|
+
await mount({ signedIn: true, props: { placement: "buttons" } });
|
|
146
|
+
|
|
147
|
+
const button = screen.getByLabelText("Colour-blind mode");
|
|
148
|
+
await act(async () => fireEvent.click(button));
|
|
149
|
+
|
|
150
|
+
expect(alepha!.store.get(uiAtom).vision).toBe("cvd");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("names the colour-blind button from labels", async () => {
|
|
154
|
+
await mount({
|
|
155
|
+
signedIn: false,
|
|
156
|
+
props: { labels: { vision: "Mode daltonien" } },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(screen.getByLabelText("Mode daltonien")).toBeTruthy();
|
|
160
|
+
});
|
|
121
161
|
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import { Alepha } from "alepha";
|
|
3
|
+
import { AlephaContext } from "alepha/react";
|
|
4
|
+
import { AlephaReactUi, ColorScheme, uiAtom } from "alepha/react/ui";
|
|
5
|
+
import { setupJsdomMocks } from "alepha/testing/react";
|
|
6
|
+
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { ButtonVision, type ButtonVisionProps } from "../ButtonVision.tsx";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `ButtonVision` flips the vision mode, and with `ColorScheme` mounted the
|
|
12
|
+
* `cvd` class on `<html>` follows. Both icons are in the markup whatever the
|
|
13
|
+
* state, so a prerendered page and the visitor's render agree.
|
|
14
|
+
*/
|
|
15
|
+
describe("ButtonVision", () => {
|
|
16
|
+
let alepha: Alepha | undefined;
|
|
17
|
+
|
|
18
|
+
beforeAll(() => {
|
|
19
|
+
setupJsdomMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(async () => {
|
|
23
|
+
await alepha?.stop();
|
|
24
|
+
alepha = undefined;
|
|
25
|
+
document.documentElement.className = "";
|
|
26
|
+
document.documentElement.removeAttribute("data-vision");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const mount = async (props: ButtonVisionProps = {}) => {
|
|
30
|
+
alepha = Alepha.create().with(AlephaReactUi);
|
|
31
|
+
await alepha.start();
|
|
32
|
+
return render(
|
|
33
|
+
<AlephaContext.Provider value={alepha}>
|
|
34
|
+
<ColorScheme />
|
|
35
|
+
<ButtonVision {...props} />
|
|
36
|
+
</AlephaContext.Provider>,
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
it("toggles the vision mode and the cvd class, reporting it in aria-pressed", async () => {
|
|
41
|
+
await mount();
|
|
42
|
+
const button = screen.getByLabelText("Colour-blind mode");
|
|
43
|
+
expect(button.getAttribute("aria-pressed")).toBe("false");
|
|
44
|
+
|
|
45
|
+
await act(async () => fireEvent.click(button));
|
|
46
|
+
|
|
47
|
+
expect(alepha!.store.get(uiAtom).vision).toBe("cvd");
|
|
48
|
+
expect(document.documentElement.classList.contains("cvd")).toBe(true);
|
|
49
|
+
expect(button.getAttribute("aria-pressed")).toBe("true");
|
|
50
|
+
|
|
51
|
+
await act(async () => fireEvent.click(button));
|
|
52
|
+
|
|
53
|
+
expect(alepha!.store.get(uiAtom).vision).toBe("normal");
|
|
54
|
+
expect(document.documentElement.classList.contains("cvd")).toBe(false);
|
|
55
|
+
expect(button.getAttribute("aria-pressed")).toBe("false");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("renders both icons whatever the state, for CSS to reveal one", async () => {
|
|
59
|
+
await mount();
|
|
60
|
+
const button = screen.getByLabelText("Colour-blind mode");
|
|
61
|
+
expect(button.querySelectorAll("svg").length).toBe(2);
|
|
62
|
+
|
|
63
|
+
await act(async () => fireEvent.click(button));
|
|
64
|
+
|
|
65
|
+
expect(button.querySelectorAll("svg").length).toBe(2);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("takes its label from props", async () => {
|
|
69
|
+
await mount({ label: "Mode daltonien", variant: "outlined" });
|
|
70
|
+
|
|
71
|
+
expect(screen.getByLabelText("Mode daltonien")).toBeTruthy();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The colour-blind palette is CSS only: `ButtonVision` sets the class `cvd`
|
|
9
|
+
* on `<html>`, and these blocks of the kit's stylesheet are what that class
|
|
10
|
+
* changes. jsdom applies no stylesheet, so the tokens are pinned by reading
|
|
11
|
+
* the file; the showcase's e2e checks the computed values in a real browser.
|
|
12
|
+
*/
|
|
13
|
+
describe("colour-blind tokens in styles.css", () => {
|
|
14
|
+
const css = readFileSync(
|
|
15
|
+
join(fileURLToPath(new URL(".", import.meta.url)), "../../styles.css"),
|
|
16
|
+
"utf8",
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const block = (selector: string): Record<string, string> => {
|
|
20
|
+
const start = css.indexOf(`${selector} {`);
|
|
21
|
+
expect(start, `${selector} block`).toBeGreaterThan(-1);
|
|
22
|
+
const body = css.slice(
|
|
23
|
+
css.indexOf("{", start) + 1,
|
|
24
|
+
css.indexOf("}", start),
|
|
25
|
+
);
|
|
26
|
+
const tokens: Record<string, string> = {};
|
|
27
|
+
for (const match of body.matchAll(/(--[\w-]+):\s*([^;]+);/g)) {
|
|
28
|
+
tokens[match[1]!] = match[2]!.trim();
|
|
29
|
+
}
|
|
30
|
+
return tokens;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const SIGNALS = [
|
|
34
|
+
"--success",
|
|
35
|
+
"--success-foreground",
|
|
36
|
+
"--success-text",
|
|
37
|
+
"--warning",
|
|
38
|
+
"--warning-foreground",
|
|
39
|
+
"--warning-text",
|
|
40
|
+
"--danger",
|
|
41
|
+
"--danger-foreground",
|
|
42
|
+
"--danger-text",
|
|
43
|
+
"--chart-1",
|
|
44
|
+
"--chart-2",
|
|
45
|
+
"--chart-3",
|
|
46
|
+
"--chart-4",
|
|
47
|
+
"--chart-5",
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
it("remaps every signal token in light and in dark", () => {
|
|
51
|
+
expect(Object.keys(block(":root.cvd")).sort()).toEqual([...SIGNALS].sort());
|
|
52
|
+
expect(Object.keys(block(":root.cvd.dark")).sort()).toEqual(
|
|
53
|
+
[...SIGNALS].sort(),
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("turns the red/green pair into vermillion/blue", () => {
|
|
58
|
+
const light = block(":root.cvd");
|
|
59
|
+
expect(light["--success"]).toBe("#0072b2");
|
|
60
|
+
expect(light["--danger"]).toBe("#d55e00");
|
|
61
|
+
expect(block(":root.cvd.dark")["--success-text"]).toBe("#4ea8e0");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("leaves the brand and the surfaces alone", () => {
|
|
65
|
+
for (const selector of [":root.cvd", ":root.cvd.dark"]) {
|
|
66
|
+
const tokens = block(selector);
|
|
67
|
+
expect(tokens["--primary"]).toBeUndefined();
|
|
68
|
+
expect(tokens["--background"]).toBeUndefined();
|
|
69
|
+
expect(tokens["--foreground"]).toBeUndefined();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* WCAG 2 relative luminance contrast, so a retuned value that drops text
|
|
75
|
+
* under AA fails here rather than in a reader's eyes.
|
|
76
|
+
*/
|
|
77
|
+
const contrast = (a: string, b: string) => {
|
|
78
|
+
const lum = (hex: string) => {
|
|
79
|
+
const [r, g, bl] = [1, 3, 5]
|
|
80
|
+
.map((i) => Number.parseInt(hex.slice(i, i + 2), 16) / 255)
|
|
81
|
+
.map((v) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4));
|
|
82
|
+
return 0.2126 * r! + 0.7152 * g! + 0.0722 * bl!;
|
|
83
|
+
};
|
|
84
|
+
const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x);
|
|
85
|
+
return (hi! + 0.05) / (lo! + 0.05);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
it("keeps every foreground at AA against what it is drawn on", () => {
|
|
89
|
+
const pages = { ":root.cvd": "#ffffff", ":root.cvd.dark": "#171717" };
|
|
90
|
+
for (const [selector, page] of Object.entries(pages)) {
|
|
91
|
+
const tokens = block(selector);
|
|
92
|
+
for (const intent of ["success", "warning", "danger"]) {
|
|
93
|
+
expect(
|
|
94
|
+
contrast(tokens[`--${intent}`]!, tokens[`--${intent}-foreground`]!),
|
|
95
|
+
`${selector} ${intent} fill`,
|
|
96
|
+
).toBeGreaterThanOrEqual(4.5);
|
|
97
|
+
expect(
|
|
98
|
+
contrast(tokens[`--${intent}-text`]!, page),
|
|
99
|
+
`${selector} ${intent} text`,
|
|
100
|
+
).toBeGreaterThanOrEqual(4.5);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
package/src/shell/index.ts
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* `AppShell` is the sidebar-and-header frame of an application and `NavShell`
|
|
9
9
|
* the page-tree variant with its `Spotlight` search. `PlateLayout` and
|
|
10
10
|
* `DetailLayout` frame a page, `AppActions` a toolbar. `ButtonDark`,
|
|
11
|
-
* `ButtonTheme`, `ButtonLanguage`, `ButtonInbox` and
|
|
12
|
-
* header buttons, and `ButtonSettings` is the account
|
|
13
|
-
* theme
|
|
11
|
+
* `ButtonVision`, `ButtonTheme`, `ButtonLanguage`, `ButtonInbox` and
|
|
12
|
+
* `ButtonUser` are the header buttons, and `ButtonSettings` is the account
|
|
13
|
+
* button with language, theme, display mode and colour-blind mode folded
|
|
14
|
+
* into its menu once signed in.
|
|
14
15
|
* `ActionErrorToaster` turns a failed action into a toast.
|
|
15
16
|
*
|
|
16
17
|
* @module alepha.ui.shell
|
|
@@ -35,8 +36,10 @@ export { ButtonSettings, type ButtonSettingsProps } from "./ButtonSettings.tsx";
|
|
|
35
36
|
export type { ButtonSettingsColorModeMenuProps } from "./ButtonSettingsColorModeMenu.tsx";
|
|
36
37
|
export type { ButtonSettingsLanguageMenuProps } from "./ButtonSettingsLanguageMenu.tsx";
|
|
37
38
|
export type { ButtonSettingsThemeMenuProps } from "./ButtonSettingsThemeMenu.tsx";
|
|
39
|
+
export type { ButtonSettingsVisionMenuItemProps } from "./ButtonSettingsVisionMenuItem.tsx";
|
|
38
40
|
export { ButtonTheme, type ButtonThemeProps } from "./ButtonTheme.tsx";
|
|
39
41
|
export { ButtonUser, type ButtonUserProps } from "./ButtonUser.tsx";
|
|
42
|
+
export { ButtonVision, type ButtonVisionProps } from "./ButtonVision.tsx";
|
|
40
43
|
export type { ButtonUserAccountMenuItemProps } from "./ButtonUserAccountMenuItem.tsx";
|
|
41
44
|
export type { ButtonUserAdminMenuItemProps } from "./ButtonUserAdminMenuItem.tsx";
|
|
42
45
|
export type { ButtonUserEmailProps } from "./ButtonUserEmail.tsx";
|
package/src/styles.css
CHANGED
|
@@ -433,6 +433,63 @@
|
|
|
433
433
|
--sidebar-ring: oklch(0.556 0 0);
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
+
/*
|
|
437
|
+
* Colour-blind mode (colour vision deficiency): the `cvd` class on `<html>`,
|
|
438
|
+
* set by `alepha/react/ui` (`useVisionMode`, `ButtonVision`) and painted
|
|
439
|
+
* before first paint by its boot script. Independent of `.dark` and of the
|
|
440
|
+
* theme palette, so it combines with both.
|
|
441
|
+
*
|
|
442
|
+
* It swaps only the tokens that CARRY MEANING (success, warning, danger and
|
|
443
|
+
* the chart palette) for Okabe and Ito's colour-blind-safe palette, as Wong
|
|
444
|
+
* popularised it: blue #0072b2, vermillion #d55e00, bluish green #009e73,
|
|
445
|
+
* reddish purple #cc79a7, orange #e69f00, with lighter variants in dark. The
|
|
446
|
+
* red/green pair, the one most deficiencies merge, becomes vermillion/blue.
|
|
447
|
+
* `--primary` and the neutrals are brand and surface, not signal, and stay.
|
|
448
|
+
*
|
|
449
|
+
* Contrast holds AA (4.5:1) on every foreground: a fill's `-foreground`
|
|
450
|
+
* against the fill, a `-text` against the page. Vermillion and orange are
|
|
451
|
+
* too light for white text, so their fills take the dark foreground the
|
|
452
|
+
* warning already used, and their `-text` is a darker step of the same hue.
|
|
453
|
+
*
|
|
454
|
+
* `:root.cvd` rather than `.cvd`: (0,2,0) beats a bare `.theme-*` and
|
|
455
|
+
* `:root.cvd.dark` (0,3,0) beats `.theme-*.dark`, so the palette wins over a
|
|
456
|
+
* theme loaded after this file, whichever it is. An app remaps its own
|
|
457
|
+
* signal tokens the same way, in a `.cvd` and a `.cvd.dark` block.
|
|
458
|
+
*/
|
|
459
|
+
:root.cvd {
|
|
460
|
+
--success: #0072b2;
|
|
461
|
+
--success-foreground: #ffffff;
|
|
462
|
+
--success-text: #0072b2;
|
|
463
|
+
--warning: #e69f00;
|
|
464
|
+
--warning-foreground: #111418;
|
|
465
|
+
--warning-text: #8f6200;
|
|
466
|
+
--danger: #d55e00;
|
|
467
|
+
--danger-foreground: #111418;
|
|
468
|
+
--danger-text: #b34f00;
|
|
469
|
+
--chart-1: #0072b2;
|
|
470
|
+
--chart-2: #e69f00;
|
|
471
|
+
--chart-3: #009e73;
|
|
472
|
+
--chart-4: #cc79a7;
|
|
473
|
+
--chart-5: #d55e00;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
:root.cvd.dark {
|
|
477
|
+
--success: #0072b2;
|
|
478
|
+
--success-foreground: #ffffff;
|
|
479
|
+
--success-text: #4ea8e0;
|
|
480
|
+
--warning: #e69f00;
|
|
481
|
+
--warning-foreground: #111418;
|
|
482
|
+
--warning-text: #ffba33;
|
|
483
|
+
--danger: #d55e00;
|
|
484
|
+
--danger-foreground: #111418;
|
|
485
|
+
--danger-text: #ff8a3d;
|
|
486
|
+
--chart-1: #4ea8e0;
|
|
487
|
+
--chart-2: #ffba33;
|
|
488
|
+
--chart-3: #2bc999;
|
|
489
|
+
--chart-4: #e3a8c5;
|
|
490
|
+
--chart-5: #ff8a3d;
|
|
491
|
+
}
|
|
492
|
+
|
|
436
493
|
/*
|
|
437
494
|
* `--surface` follows the surface utilities rather than being set by hand
|
|
438
495
|
* in each component: a hand-written `bg-card` panel is as much a surface as
|