@apliteni/apliteni-ui 0.180.0 → 0.181.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.
@@ -58,8 +58,9 @@ Neither attribute changes the type. `--font-display` is for headings and brand m
58
58
  `--font-sans` is for all text that the user reads, and `--font-mono` is for code. The package
59
59
  does not ship the font files, so your page loads them. See [Typefaces](foundations.md#typefaces).
60
60
 
61
- Use `ThemeToggle` to let the user choose the theme. Put `THEME_INIT_SCRIPT` in a `<script>` in
62
- the `<head>`, so the first paint has the stored theme. Use `AccentPicker` to let the user choose
61
+ Use `ThemeToggle` to let the user choose the theme from a bar. Use [`ThemeChoice`](#theme-choice)
62
+ on a settings page. Put `THEME_INIT_SCRIPT` in a `<script>` in the `<head>`, so the first paint has
63
+ the stored theme. Use `AccentPicker` to let the user choose
63
64
  the accent. It calls `onChange`. Your page sets `data-accent` and stores the choice. `ACCENTS`
64
65
  from the root entry lists the accent names.
65
66
 
@@ -164,7 +165,8 @@ in their own row under the title. `back` puts a [back link](#back-link) above th
164
165
  **The account menu.** `accountItems` adds rows, such as Account settings and Support, at the top
165
166
  of every account menu. A row takes `href` to go to a page, or `onSelect` to open something in
166
167
  place. A separator stands before Sign out. In the topbar layout, a Theme row opens a submenu with
167
- Auto, Light and Dark.
168
+ Auto, Light and Dark. The account button's name is "Signed in as", the name and the address. It
169
+ holds each line of text that the button shows, and the menu takes the same name.
168
170
 
169
171
  **Topbar layout only.**
170
172
 
@@ -636,6 +638,29 @@ wider. A long label wraps inside its own option.
636
638
  keys move and choose, wrap at the ends and skip disabled options. Home and End go to the first and
637
639
  last enabled option. In forced colours the chosen option uses the system highlight colours.
638
640
 
641
+ ### Theme choice
642
+
643
+ Use `ThemeChoice` for the theme on a settings page. Use `ThemeToggle` in a bar. Use `Segmented`
644
+ for other preferences.
645
+
646
+ ```tsx
647
+ <Card title="Theme"><ThemeChoice /></Card>
648
+ ```
649
+
650
+ `label` names the group, `Theme` by default. The choice applies and is stored at once, as with
651
+ `ThemeToggle`, so the page needs no Save.
652
+
653
+ **What the user sees.** Three cards in one row at every width: System, Light and Dark. Each card is
654
+ a small picture of a page in that theme, drawn from the theme's tokens, with its name under it.
655
+ System is half light and half dark. The chosen card has a fill, and its name is in strong, heavier
656
+ ink. Hover gives another card half that fill. The first and last pictures sit on the card's text
657
+ edges. The fill extends 8 px into the card's padding, and the focus ring extends 3 px more. So put
658
+ the group in a padded container, such as `Card`.
659
+
660
+ **Keyboard and screen reader.** One named radio group, with one Tab stop on the chosen card. The
661
+ arrow keys move and choose. The focus ring is the kit's band around the card, and nothing else.
662
+ In forced colours the chosen card's name takes the system highlight colour.
663
+
639
664
  ### Tabs
640
665
 
641
666
  Use `Tabs` when each choice shows a different block of content on the same page. Use
@@ -978,8 +1003,10 @@ tooltip or a picker already used closes only that overlay. The next Escape close
978
1003
 
979
1004
  ### Account window
980
1005
 
981
- Use `AccountWindow` for account and settings. Do not make account and settings a page of the
982
- product: [Account and settings](../guidelines/account-and-settings.md).
1006
+ Use `AccountWindow` for an account area of several groups. When the account area is only a
1007
+ profile and a few preferences, open a Profile page and a Preferences page in the app shell from
1008
+ the account menu, with no second navigation column:
1009
+ [Account and settings](../guidelines/account-and-settings.md).
983
1010
 
984
1011
  ```tsx
985
1012
  <AccountWindow open={open} onClose={close} reader={{ name: 'Dana Reyes', email: 'dana@example.com' }}
@@ -1079,7 +1106,8 @@ least 4.5:1 on a plain or a selected row.
1079
1106
  **Scrolling.** With `stickyHeader` or `pinnedIdentity`, the table stands in a named scroll region.
1080
1107
  `pinnedIdentity` pins the first column, or the column whose key you give. A table wider than its
1081
1108
  frame scrolls sideways, and the page does not. The pinned column draws its divider only when the
1082
- region can scroll. Below 720px a pinned cell keeps one line and is cut at
1109
+ region can scroll. When the region is scrolled, the next column's text stops one cell padding
1110
+ short of the divider. Below 720px a pinned cell keeps one line and is cut at
1083
1111
  `--ui-table-identity-max`. Lower that cap for a table with a selection column. Below 560px the
1084
1112
  frame has no scrollbar. `scrollLabel` names the region, `Table` by default. Use the subject of the table, such as
1085
1113
  `Invoices`, and name the gesture only when the columns overflow at every width.
@@ -1098,10 +1126,14 @@ selected. A dense table marks a selected row only with its box.
1098
1126
  focus. A `.ui-table__sub` puts a second value under the first, such as an email under a name.
1099
1127
  `.ui-table__pair` groups a reference and a status, and stacks them when the cell is narrow.
1100
1128
 
1101
- **Keyboard and screen reader.** The scroll region takes the focus and draws the ring inside its
1102
- edge, so the arrow keys, a trackpad and a finger reach the same columns.
1129
+ **Keyboard and screen reader.** When its content overflows, the scroll region takes the focus and
1130
+ draws the ring inside its edge, so the arrow keys, a trackpad and a finger reach the same columns.
1131
+ When the content fits, also after a resize, the region is not a Tab stop. A control in the region
1132
+ that takes the focus by keyboard or by script scrolls fully into view.
1103
1133
 
1104
1134
  **In a card.** The table reaches the card's edges, and its end cells keep the card's text edge.
1135
+ At 560px and narrower, a row table's end cells pad by 16px, so its first column starts 8px
1136
+ outside the card's text edge. A row table has hover and is neither zebra nor dense.
1105
1137
  `.ui-card--fit` makes the card end at the table's content.
1106
1138
 
1107
1139
  ### Pagination
@@ -1,28 +1,28 @@
1
1
  # Account and settings
2
2
 
3
- ## Open the account area in one modal
3
+ ## Choose pages or the account window by size
4
4
 
5
5
  <!-- rule: modal -->
6
6
 
7
- **Rule:** Open account and settings in the kit's account window, over the product, with its sections beside the pane.
7
+ **Rule:** Open Profile and Preferences as two pages in the app shell, and keep the account window for an account area of several groups.
8
8
 
9
- **Why:** The reader has not left the work behind it, and one overlay holds every setting.
9
+ **Why:** A column of sections beside the app sidebar reads as a second navigation, and a name and a theme fill no column.
10
10
 
11
- **Do:** Give the window the reader and the sections, and let it draw the rail, the title, the close and the dimmed page.
11
+ **Do:** Open each page from the account menu, with no sidebar entry lit.
12
12
 
13
- **Don't:** Slide a full-width sheet in with columns inside it.
13
+ **Don't:** Open a window with its own sections for a photo and a theme.
14
14
 
15
- **Except:** On a phone the sections become tabs under the reader, where a column beside the pane would leave it narrower than its rows.
15
+ **Except:** On a phone the window's sections become tabs under the reader.
16
16
 
17
- ## Give the modal its own navigation
17
+ ## Give the account window its own navigation
18
18
 
19
19
  <!-- rule: nav -->
20
20
 
21
- **Rule:** Give the modal one entry per group a reader arrives to change.
21
+ **Rule:** Give the account window one entry per group a reader arrives to change.
22
22
 
23
23
  **Why:** A reader already knows which group they came for, and a list of names is read faster than every group in turn.
24
24
 
25
- **Do:** Stand the entries beside the pane — above it on a phone — and mark the one on screen.
25
+ **Do:** Stand the entries beside the pane — above it on a phone — and mark the one shown.
26
26
 
27
27
  **Don't:** Run all five groups down one scroll.
28
28
 
@@ -32,11 +32,11 @@
32
32
 
33
33
  <!-- rule: menu -->
34
34
 
35
- **Rule:** Keep the account menu to the reader, a few ways in, a Theme submenu and Sign out.
35
+ **Rule:** Keep the account menu to the reader, the ways in, Support and Sign out, and Theme only where no page holds it.
36
36
 
37
37
  **Why:** A setting answered inside a menu has no address to link, search or come back to.
38
38
 
39
- **Do:** Name the reader, then Account settings and Support.
39
+ **Do:** Name the reader, then Profile, Preferences and Support.
40
40
 
41
41
  **Don't:** Answer the settings in the menu, a row per setting.
42
42
 
@@ -50,7 +50,7 @@
50
50
 
51
51
  **Do:** Flip the weekly digest where it is named.
52
52
 
53
- **Don't:** Open the modal on a pane to flip one switch.
53
+ **Don't:** Open the account window on a pane to flip one switch.
54
54
 
55
55
  **Except:** A question that must be answered before anything else still stops the page.
56
56
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  **Rule:** Name an account pane’s action after the change it makes.
62
62
 
63
- **Why:** On a pane of agents and the tokens they hold, Save does not say what the press changes.
63
+ **Why:** On a pane of agent tokens, Save does not say what the press changes.
64
64
 
65
65
  **Do:** End the tokens pane with “Create token”.
66
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.180.0",
3
+ "version": "0.181.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
package/react/README.md CHANGED
@@ -682,6 +682,20 @@ cannot change an earlier paint.
682
682
  <script nonce={nonce} dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />
683
683
  ```
684
684
 
685
+ ## ThemeChoice
686
+
687
+ ThemeChoice shows the theme as three picture cards on a settings page: System, Light
688
+ and Dark. It reads and stores the choice as ThemeToggle does, with the same key, the
689
+ same root attributes and the same event.
690
+
691
+ ```tsx
692
+ import { Card, ThemeChoice } from '@apliteni/apliteni-ui/react';
693
+
694
+ <Card title="Theme"><ThemeChoice /></Card>
695
+ ```
696
+
697
+ `label` names the radio group, `Theme` by default.
698
+
685
699
  ## AppShell
686
700
 
687
701
  AppShell includes the kit’s rail and top band. Pass the current router pathname so the longest matching section path becomes active. Spread the props from `renderLink` onto your router link. The rail’s folded state is saved in a shared cookie. On phones, the bar shows up to four sections. If there are more, it shows three sections and a More sheet. Provide no more than one primary page action. The palette defaults to section links; pass `palette` to add custom commands. Import both the kit CSS and React CSS.
@@ -1457,3 +1457,120 @@
1457
1457
  .ui-auth__brand > span {
1458
1458
  display: flex;
1459
1459
  }
1460
+
1461
+ /* src/ThemeChoice.css */
1462
+ .ui-theme-choice {
1463
+ display: grid;
1464
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1465
+ gap: var(--space-3);
1466
+ margin-inline: calc(-1 * var(--space-2));
1467
+ }
1468
+ .ui-theme-choice__option {
1469
+ display: flex;
1470
+ flex-direction: column;
1471
+ align-items: center;
1472
+ gap: var(--space-2);
1473
+ min-width: 0;
1474
+ padding: var(--space-2);
1475
+ border-radius: var(--radius-lg);
1476
+ color: var(--text);
1477
+ cursor: pointer;
1478
+ transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
1479
+ }
1480
+ .ui-theme-choice__pic {
1481
+ position: relative;
1482
+ display: block;
1483
+ container-type: inline-size;
1484
+ width: 100%;
1485
+ aspect-ratio: 2 / 1.1;
1486
+ overflow: hidden;
1487
+ border: 1px solid var(--border);
1488
+ border-radius: var(--radius-md);
1489
+ transition: transform var(--dur-fast) var(--ease);
1490
+ }
1491
+ .ui-theme-choice__option:not(:has(:checked)):hover {
1492
+ background: color-mix(in srgb, var(--surface-3) 50%, transparent);
1493
+ color: var(--strong);
1494
+ }
1495
+ .ui-theme-choice__option:has(:checked) {
1496
+ background: var(--surface-3);
1497
+ color: var(--strong);
1498
+ font-weight: var(--weight-semibold);
1499
+ }
1500
+ .ui-theme-choice__option:has(.ui-theme-choice__input:focus-visible) {
1501
+ outline: var(--ring);
1502
+ outline-offset: var(--ring-offset);
1503
+ }
1504
+ .ui-theme-choice__option:active .ui-theme-choice__pic {
1505
+ transform: translateY(1px);
1506
+ }
1507
+ .ui-theme-choice__name {
1508
+ overflow-wrap: anywhere;
1509
+ text-align: center;
1510
+ }
1511
+ .ui-theme-choice__scene {
1512
+ position: absolute;
1513
+ inset: 0;
1514
+ display: grid;
1515
+ grid-template-columns: 24% minmax(0, 1fr);
1516
+ background: var(--bg);
1517
+ }
1518
+ .ui-theme-choice__scene + .ui-theme-choice__scene {
1519
+ clip-path: inset(0 0 0 50%);
1520
+ }
1521
+ .ui-theme-choice__rail {
1522
+ display: flex;
1523
+ flex-direction: column;
1524
+ gap: 4cqi;
1525
+ padding: 8cqi 5cqi;
1526
+ border-inline-end: 1px solid var(--border);
1527
+ background: var(--surface);
1528
+ }
1529
+ .ui-theme-choice__main {
1530
+ display: flex;
1531
+ flex-direction: column;
1532
+ gap: 5cqi;
1533
+ padding: 8cqi 7cqi;
1534
+ }
1535
+ .ui-theme-choice__title {
1536
+ width: 40%;
1537
+ height: 3cqi;
1538
+ border-radius: 2cqi;
1539
+ background: var(--strong);
1540
+ }
1541
+ .ui-theme-choice__card {
1542
+ display: flex;
1543
+ flex: 1;
1544
+ flex-direction: column;
1545
+ justify-content: center;
1546
+ gap: 4cqi;
1547
+ padding-inline: 7cqi;
1548
+ border: 1px solid var(--border);
1549
+ border-radius: 4cqi;
1550
+ background: var(--surface);
1551
+ }
1552
+ .ui-theme-choice__rail > span,
1553
+ .ui-theme-choice__card > span {
1554
+ height: 2cqi;
1555
+ border-radius: 1cqi;
1556
+ background: var(--text);
1557
+ }
1558
+ .ui-theme-choice__rail > span,
1559
+ .ui-theme-choice__card > span + span {
1560
+ background: var(--muted);
1561
+ }
1562
+ .ui-theme-choice__card > span + span {
1563
+ width: 55%;
1564
+ }
1565
+ @media (forced-colors: active) {
1566
+ .ui-theme-choice__pic {
1567
+ forced-color-adjust: none;
1568
+ }
1569
+ .ui-theme-choice__input:checked ~ .ui-theme-choice__name {
1570
+ forced-color-adjust: none;
1571
+ padding-inline: var(--space-2);
1572
+ border-radius: var(--radius-sm);
1573
+ background: Highlight;
1574
+ color: HighlightText;
1575
+ }
1576
+ }
@@ -1102,6 +1102,14 @@ type ThemeToggleProps = {
1102
1102
  };
1103
1103
  declare function ThemeToggle({ labelled }: ThemeToggleProps): react.JSX.Element;
1104
1104
 
1105
+ type ThemeChoiceProps = {
1106
+ /** The group's name. Give the name of the card or the row that holds it. */
1107
+ label?: string;
1108
+ };
1109
+ /** The theme as three picture cards: System, Light and Dark. One radio group, so Tab
1110
+ * stops once and the arrow keys move. A choice applies and is stored at once. */
1111
+ declare function ThemeChoice({ label }: ThemeChoiceProps): react.JSX.Element;
1112
+
1105
1113
  type TooltipProps = {
1106
1114
  text?: string;
1107
1115
  label?: string;
@@ -1475,5 +1483,5 @@ declare const NavTabs: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedH
1475
1483
  declare const PAGE_SIZES: readonly number[];
1476
1484
  declare const DEFAULT_PAGE_SIZE: number;
1477
1485
 
1478
- export { AccentPicker, AccountMenu, AccountWindow, AppShell, AuthShell, Avatar, BackLink, Badge, BusyRegion, Button, Callout, Card, Chart, CheckList, Checkbox, CommandPalette, Confirm, DEFAULT_PAGE_SIZE, DataTable, DatePicker, DeltaValue, Denied, Drawer, DrawerSection, Dropdown, EmptyState, Feedback, Field, FileDrop, FileField, FilterBar, Footer, Icon, KeyValueList, Modal, NavTabs, NumericValue, PAGE_SIZES, Pagination, Pill, RowIdentity, SearchField, Segmented, SelectField, SidebarNav, Skeleton, SkeletonTable, Snippet, StatBand, StatusDot, Success, SuccessCheck, SuccessPanel, Switch, THEME_INIT_SCRIPT, Tabs, TextArea, TextField, ThemeToggle, Timeline, Toast, Tooltip, TopBar, VersionSwitcher, ViewSwitch, sortTableRows, useToast };
1479
- export type { Accent, AccentPickerProps, AccountMenuProps, AccountReader, AccountSection, AccountWindowProps, AddFilter, AppShellGroup, AppShellLink, AppShellProps, AppShellSection, AuthShellProps, AvatarProps, BackLinkOwnProps, BackLinkProps, BusyRegionProps, ButtonLinkProps, ButtonProps, CalloutProps, CalloutVariant, ChartAreaLook, ChartBridgeStep, ChartBridgeTones, ChartDonutLook, ChartLineLook, ChartLookSeries, ChartPeriod, ChartProps, ChartSeries, ChartSlice, ChartStackedLook, ChartTone, CheckListProps, CheckboxProps, Column, CommandGroup, CommandItem, CommandPaletteProps, ConfirmProps, DataTableProps, DatePickerMode, DatePickerPreset, DatePickerProps, DatePickerRange, DeltaValueProps, DeniedProps, DrawerProps, DrawerSectionProps, DropdownAvatar, DropdownBadge, DropdownEntry, DropdownItem, DropdownProps, DropdownRowProps, DropdownSearch, DropdownSection, DropdownSeparator, EmptyStateProps, EmptyStateVariant, FeedbackPayload, FeedbackProps, FeedbackResult, FeedbackSection, FieldControlProps, FieldProps, FileDropFile, FileDropProps, FileDropStatus, FileFieldProps, Filter, FilterBarProps, FooterColumn, FooterLink, FooterProps, FooterSocial, KeyValueListProps, KeyValueRow, ModalProps, NativeButtonProps, NavTabBadge, NavTabItem, NavTabsProps, NumericValueProps, PaginationProps, PillProps, RowIdentityProps, SearchFieldProps, SegmentOption, SegmentedProps, SelectFieldProps, SidebarNavBadge, SidebarNavBlock, SidebarNavGroup, SidebarNavItem, SidebarNavLeaf, SidebarNavProps, SidebarNavRow, SidebarNavSection, SidebarNavSections, SkeletonProps, SkeletonTableProps, SnippetProps, StatBandProps, StatDelta, StatFigure, StatTone, StatVariant, StatusDotProps, SuccessCheckProps, SuccessCountdown, SuccessPanelProps, SuccessProps, SwitchProps, TabItem, TableSort, TabsProps, TextAreaProps, TextFieldProps, ThemeToggleProps, TimelineEvent, TimelineEventKind, TimelineProps, ToastNotice, ToastProps, TooltipProps, TopBarProps, Version, VersionSwitcherProps, ViewSwitchItem, ViewSwitchProps };
1486
+ export { AccentPicker, AccountMenu, AccountWindow, AppShell, AuthShell, Avatar, BackLink, Badge, BusyRegion, Button, Callout, Card, Chart, CheckList, Checkbox, CommandPalette, Confirm, DEFAULT_PAGE_SIZE, DataTable, DatePicker, DeltaValue, Denied, Drawer, DrawerSection, Dropdown, EmptyState, Feedback, Field, FileDrop, FileField, FilterBar, Footer, Icon, KeyValueList, Modal, NavTabs, NumericValue, PAGE_SIZES, Pagination, Pill, RowIdentity, SearchField, Segmented, SelectField, SidebarNav, Skeleton, SkeletonTable, Snippet, StatBand, StatusDot, Success, SuccessCheck, SuccessPanel, Switch, THEME_INIT_SCRIPT, Tabs, TextArea, TextField, ThemeChoice, ThemeToggle, Timeline, Toast, Tooltip, TopBar, VersionSwitcher, ViewSwitch, sortTableRows, useToast };
1487
+ export type { Accent, AccentPickerProps, AccountMenuProps, AccountReader, AccountSection, AccountWindowProps, AddFilter, AppShellGroup, AppShellLink, AppShellProps, AppShellSection, AuthShellProps, AvatarProps, BackLinkOwnProps, BackLinkProps, BusyRegionProps, ButtonLinkProps, ButtonProps, CalloutProps, CalloutVariant, ChartAreaLook, ChartBridgeStep, ChartBridgeTones, ChartDonutLook, ChartLineLook, ChartLookSeries, ChartPeriod, ChartProps, ChartSeries, ChartSlice, ChartStackedLook, ChartTone, CheckListProps, CheckboxProps, Column, CommandGroup, CommandItem, CommandPaletteProps, ConfirmProps, DataTableProps, DatePickerMode, DatePickerPreset, DatePickerProps, DatePickerRange, DeltaValueProps, DeniedProps, DrawerProps, DrawerSectionProps, DropdownAvatar, DropdownBadge, DropdownEntry, DropdownItem, DropdownProps, DropdownRowProps, DropdownSearch, DropdownSection, DropdownSeparator, EmptyStateProps, EmptyStateVariant, FeedbackPayload, FeedbackProps, FeedbackResult, FeedbackSection, FieldControlProps, FieldProps, FileDropFile, FileDropProps, FileDropStatus, FileFieldProps, Filter, FilterBarProps, FooterColumn, FooterLink, FooterProps, FooterSocial, KeyValueListProps, KeyValueRow, ModalProps, NativeButtonProps, NavTabBadge, NavTabItem, NavTabsProps, NumericValueProps, PaginationProps, PillProps, RowIdentityProps, SearchFieldProps, SegmentOption, SegmentedProps, SelectFieldProps, SidebarNavBadge, SidebarNavBlock, SidebarNavGroup, SidebarNavItem, SidebarNavLeaf, SidebarNavProps, SidebarNavRow, SidebarNavSection, SidebarNavSections, SkeletonProps, SkeletonTableProps, SnippetProps, StatBandProps, StatDelta, StatFigure, StatTone, StatVariant, StatusDotProps, SuccessCheckProps, SuccessCountdown, SuccessPanelProps, SuccessProps, SwitchProps, TabItem, TableSort, TabsProps, TextAreaProps, TextFieldProps, ThemeChoiceProps, ThemeToggleProps, TimelineEvent, TimelineEventKind, TimelineProps, ToastNotice, ToastProps, TooltipProps, TopBarProps, Version, VersionSwitcherProps, ViewSwitchItem, ViewSwitchProps };