lostcoords-ui 0.9.1 → 0.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f8077289d2f42d36c5ff8177f81097b42baafd100b6aa8adbb6e1123c5a5058
4
- data.tar.gz: 50de90e3b76b95d9875693b941003ae8918f84a97ad97c696a67ae61d3e85a31
3
+ metadata.gz: fc1eac8e5c8d5395e53290a9f939d22a981c17ee7a3badbfb4d88825d876be49
4
+ data.tar.gz: bfc62ca69d504fb8ae72e623ed031ee82dfaf0f904ef7bc94a6874cdbfaa1b16
5
5
  SHA512:
6
- metadata.gz: e8ac1886d108885b94b1f5a58b1ce75cc80a0331523aa2cfd50a716fd92fa530c14eba5d1c5715f8bd9e479e37a39bc4d161476f99a076dbe75226b069054617
7
- data.tar.gz: 0c248a33c017307f9c9620d7265b11a1c4f974657860cc150c3ceab6b2fc87b124f03184de7b16663cd01a772977acf85958908fada977dadc7fa731f7e5a06d
6
+ metadata.gz: 4f9c03d1e4b09af19ef947c081b9b308f51d16400987e149ee20a108bf1a48f20466561d12ce9704a0bd4eca92dcfd9d85e1826bbdb1510f0dce116694ad1e56
7
+ data.tar.gz: 5a444fd100b3af57bc79cc55529400791c70df467618599babc9e0d2fa39c703830008c1905fb40e586bc69802ac68e78d85eb7d1ab5ed47b4764f4bf7134289
data/README.md CHANGED
@@ -21,7 +21,7 @@ lockfile pins its gem version, so publishing a library update does not upgrade c
21
21
  ## Install
22
22
 
23
23
  ```ruby
24
- gem "lostcoords-ui", "~> 0.9.1"
24
+ gem "lostcoords-ui", "~> 0.10.0"
25
25
  ```
26
26
 
27
27
  The engine adds its rendering helpers to host views, its views and translations to the host's lookup
@@ -57,17 +57,17 @@ app's theme and keep your Tailwind theme declarations after the imports.
57
57
  `core.css` holds the tokens, buttons, badges, avatars, cards, alerts, form controls, choices,
58
58
  toggles, layout, typography and navigation. The opt-in entries are `dialog` (with the phone sheet),
59
59
  `menu` (menus and popovers), `toast`, `search`, `tooltip`, `collapsible`, `code-block`,
60
- `emoji-picker`, `table`, `prose` and `shell` (`lc_app_header`, `lc_docs_shell` and `lc_dock`; the dock's action
61
- menu also needs `menu`). A component whose entry is missing renders unstyled.
60
+ `emoji-picker`, `table`, `prose` and `shell` (`lc_app_header`, `lc_sidebar`, `lc_docs_shell` and `lc_dock`; the
61
+ dock's action menu and the sidebar's account menu also need `menu`). A component whose entry is missing renders unstyled.
62
62
 
63
63
  The gem's stylesheets write into the `components` and `modules` layers, so the host declares that layer order.
64
- The theme defines the `dark:` variant with `html[data-theme="dark"]`. Each entry carries its own `@source` lines, so Tailwind
64
+ The theme defines the `dark:` variant with `html[data-theme="dark"]`, and with `html[data-theme="system"]` under an OS dark preference. Each entry carries its own `@source` lines, so Tailwind
65
65
  scans the gem's helpers, views and JavaScript wherever the gem is installed.
66
66
 
67
67
  ### Theming
68
68
 
69
69
  Colors use [shadcn/ui](https://ui.shadcn.com/docs/theming) names, so a shadcn or tweakcn theme drops in.
70
- Set `data-theme="dark"` on `<html>` for dark mode; your app owns the switch and saved preference.
70
+ Set `data-theme="dark"` on `<html>` for dark mode, or `data-theme="system"` to follow the OS with no pre-paint script, which keeps cached HTML theme-agnostic. Your app owns the switch and saved preference. A dark override written for `html[data-theme="dark"]` does not reach `system`: use `light-dark()` for colors, or repeat it under `@media (prefers-color-scheme: dark)`.
71
71
  Override any of these after the engine import:
72
72
 
73
73
  ```css
@@ -170,6 +170,42 @@ Omit `only` to register every library controller. Unknown identifiers raise befo
170
170
  registered, and repeated calls on the same application keep later overrides, so register defaults
171
171
  before application overrides.
172
172
 
173
+ ## Changes in 0.10.0
174
+
175
+ Nothing needs an edit, but toggles look different:
176
+
177
+ - **A selected toggle pill fills solid.** Before: a pressed, checked or current `lc_toggle` (and a
178
+ `variant: :pills` toggle group item) had a soft primary fill, a primary edge and primary ink. After: it
179
+ fills with `--primary` and `--primary-foreground` ink over a transparent border, so selecting never shifts
180
+ its edge. A host that restyled the soft state for contrast can drop that override.
181
+ - **A segmented toggle group slides one indicator.** Items stretch to share the track, and their corners are
182
+ concentric with it. Where the browser supports anchor positioning, the current item's surface is one
183
+ indicator that slides from item to item, whichever state marks it (`aria-current`, `aria-selected`,
184
+ `aria-checked`, `aria-pressed`, a checked radio or `active:`); elsewhere each current item paints its own,
185
+ as before. Items carry `lc-toggle-group-item`, and the track `lc-toggle-group`.
186
+
187
+ New components and options, moved from apps that built them by hand:
188
+
189
+ - **`lc_tab_bar` is a row of links styled as underlined tabs.** The current tab is bold with a rounded
190
+ underline in `--lc-tab-bar-indicator`; `count:` adds a muted number and `fill: true` shares the row. Unlike
191
+ `lc_tabs`, each tab is a link to its own URL.
192
+ - **`lc_sidebar` is a sticky app sidebar that folds to an icon rail**, with the `lc-sidebar` controller, in the
193
+ `shell` entry. It keeps the reader's choice in a cookie the helper reads back, starts as a rail below
194
+ `rail_below:` unless expanded, and yields `sidebar.header` (with the toggle), `sidebar.body`, `sidebar.footer`
195
+ and `sidebar.account`, a row that opens an `lc_menu`. The `lc-rail:` variant styles your own content on the
196
+ rail, and `--lc-sidebar-indicator` paints the current link's bar. If you built a sidebar with a rail variant
197
+ and a cookie of your own, you can replace it and delete its stylesheet rules and controller.
198
+ - **`lc_stats` and `lc_stat` show headline numbers** in a description list, in a line or as tiles.
199
+ - **`lc_char_counter` is the character ring X shows under a post**, with the `lc-char-counter` controller. It
200
+ counts a field, or takes a count you supply for weighted characters.
201
+ - **`lc_time` renders the short relative time X shows**, "12m", "4h", "4 Nov", with the full date as its title.
202
+ - **`lc_split` and `lc_columns` lay out a main column beside an aside and balanced columns of groups**, with
203
+ `lc_split_class` and `lc_columns_class` for markup you render yourself.
204
+ - **`lc_empty_state` takes `title:`, `text:`, `icon:`, `level:` and `card:`** to lay out the usual empty state;
205
+ the block form still works.
206
+ - **`lc_toggle` takes `icon:`, `icon_only:` and `tooltip:`.** `icon_only: true` makes a square toggle of just the
207
+ icon whose label stays as its accessible name.
208
+
173
209
  ## Changes in 0.9.1
174
210
 
175
211
  Nothing needs an edit:
@@ -356,6 +392,8 @@ Badge, icon badge, Alert and Toast share `neutral`, `primary`, `success`, `warni
356
392
  `lc_toggle` renders a button that flips its own `aria-pressed`; set `aria-pressed` or `aria-expanded` yourself
357
393
  and it leaves the state to your controller. `href:` renders a link marked `aria-current` when active, and `name:`
358
394
  with `value:` a label around a visually hidden native radio, styled by `:checked`.
395
+ `icon:` adds a leading icon, and `icon_only: true` makes a square toggle of just that icon whose label stays as its
396
+ accessible name; `tooltip: true` shows the label on hover and focus, as on `lc_icon_button`.
359
397
  `lc_toggle_group` with `lc_toggle_group_item` holds mutually exclusive choices, and the group decides what its items are.
360
398
  With `name:` they are native radios in labels, which bring their own arrows, submitted value and reset; items take
361
399
  `value:` and `checked:`, and the group's `value:` checks the matching item. With `as: :nav` they are links in a
@@ -373,8 +411,37 @@ given another kind's arguments raises. `variant: :pills` lays any of them out as
373
411
  <%= lc_toggle_group_item "Annual", value: "annual" %>
374
412
  <% end %>
375
413
  <%= lc_toggle "Food", aria: { pressed: false }, data: { value: "food" } %>
414
+ <%= lc_toggle "Bold", icon: "bold", icon_only: true, tooltip: true %>
415
+ ```
416
+
417
+ `lc_empty_state(title:, text:, icon:)` lays out the usual empty state: a round icon badge, a heading
418
+ (`level:`, 2 by default), a line of muted text, then the block, such as an action. `card: true` puts it on a card.
419
+ Without those options the block is the whole content, as before.
420
+
421
+ ```erb
422
+ <%= lc_empty_state title: "No drafts yet", text: "Drafts appear here until you post them.", icon: "pencil-square", card: true do %>
423
+ <%= lc_button_link_to "New draft", new_draft_path, icon: "plus" %>
424
+ <% end %>
425
+ ```
426
+
427
+ `lc_stats` shows headline numbers as a description list of `lc_stat` items: the value in bold tabular figures
428
+ and its label in muted text. `layout: :inline` (the default) runs them along a line; `layout: :grid` gives each a
429
+ tile, in `columns:` 2, 3 or 4, or as many as fit. `tone:` colours a value with a status tone, and a block replaces
430
+ the value, such as a link around it.
431
+
432
+ ```erb
433
+ <%= lc_stats do %>
434
+ <%= lc_stat number_with_delimiter(@replies), label: "replies sent", tone: :primary %>
435
+ <%= lc_stat(label: "people") { link_to @people, people_path } %>
436
+ <% end %>
437
+ <%= lc_stats layout: :grid, columns: 2 do %>…<% end %>
376
438
  ```
377
439
 
440
+ `lc_time(time)` renders a `<time>` with the short text X shows: "now", "12m" and "4h" within a day, then
441
+ "4 Nov", and "4 Nov 2025" in another year. The full date and time is its title, and `detail:` adds to it. The
442
+ texts and date formats are translations under `lostcoords.ui.time`; month names come from the host's
443
+ `date.month_names`, as rails-i18n provides them, and fall back to English. `now:` sets the moment to count from.
444
+
378
445
  `lc_collapsible` expands content through a native `<details>` element. `lc_alert` renders persistent inline feedback;
379
446
  `lc_toast` adds timed dismissal.
380
447
 
@@ -405,7 +472,9 @@ makes the summary look like that `lc_button` without the native marker, and `ind
405
472
  only the group's ends round. Rows are card surfaces, so fields and buttons in them follow
406
473
  `--card-input` and `--card-secondary`. `lc_list_row` with a title lays out `icon:` (a name, or your own
407
474
  markup such as a logo), the title, `subtitle:` and the block as trailing content; `tag:` makes it a
408
- `label`, `li`, `details` or `a` (`href:`). Without a title the block is the whole row, and
475
+ `label`, `li`, `details` or `a` (`href:`). `href:` with `tag: :li` or `:div` links the title instead
476
+ and stretches it over the row, so the block can hold buttons and links of its own; a click anywhere
477
+ else in the row follows the title. Without a title the block is the whole row, and
409
478
  `padded: false` leaves the padding to content such as an `lc_list_item` button or summary, which lays
410
479
  out the same icon, title and subtitle inside your own element. `lc_list_section` adds the heading and
411
480
  footnote; with an `id:`, the heading labels the section. Put a form around `lc_list_group` inside it
@@ -483,6 +552,21 @@ attribute. `form.field … size: :sm` (or `lc_field size: :sm`) is the compact f
483
552
  with a caption label. Pass `builder: Lostcoords::Ui::FormBuilder` to `form_with` directly, or call `lc_field`
484
553
  with `error: record.errors.full_messages_for(:name)` when you keep your own builder.
485
554
 
555
+ `lc_char_counter(max:)` is the ring X shows under a post: it fills as a field nears `max:` characters, hides
556
+ while the field is empty, turns to the warning tone with the characters left once `warn:` (20) or fewer remain,
557
+ and to the destructive tone with a negative number past the limit. Its accessible name reads "120 of 280
558
+ characters". It counts the field whose id is `for:`, or the nearest field around it. To count another way,
559
+ such as X's weighted characters, set `data-lc-char-counter-count-value` or send it an event whose
560
+ `detail.count` is the count, as in `data: { action: "composer:count@window->lc-char-counter#update" }`; `count:` renders a count
561
+ before JavaScript runs.
562
+
563
+ ```erb
564
+ <%= lc_field label: "Post", id: "post" do |field| %>
565
+ <%= lc_textarea name: "post[text]", rows: 4, **field %>
566
+ <%= lc_char_counter max: 280, for: "post" %>
567
+ <% end %>
568
+ ```
569
+
486
570
  `lc_checkbox`, `lc_radio` and `lc_switch` render native inputs with a label and optional hint.
487
571
  Checkboxes and switches submit an unchecked value like Rails' `check_box`; pass `unchecked_value: nil`
488
572
  to omit it. A `nil` label renders the bare input, for a row selector the row labels; give it
@@ -507,15 +591,32 @@ Text that labels something other than one control, such as a list, uses `lc_text
507
591
  <%= lc_icon_button "Copy link", icon: "link", **tip %>
508
592
  <% end %>
509
593
 
594
+ <%= lc_icon_button "Stop", icon: "stop", tooltip: true %>
595
+
510
596
  <%= lc_description_list do |list| %>
511
597
  <%= list.item "Owner", @project.owner.name %>
512
598
  <%= list.item("Plan") { lc_badge @project.plan } %>
513
599
  <% end %>
514
600
  ```
515
601
 
602
+ ```erb
603
+ <%= lc_tab_bar label: "Drafts", fill: true do |bar| %>
604
+ <%= bar.link "Open", drafts_path, current: true, count: @open_count %>
605
+ <%= bar.link "Posted", drafts_path(status: :posted), count: @posted_count %>
606
+ <% end %>
607
+ ```
608
+
609
+ `lc_tab_bar` is a row of links styled as underlined tabs, for the views of a page that each have a URL; use
610
+ `lc_tabs` when the panels live on one page. The current tab carries `aria-current="page"`, bold text and a
611
+ rounded underline in `--lc-tab-bar-indicator` (the primary color by default). `count:` adds a muted number after
612
+ the label, and `fill: true` stretches the tabs to share the row. A row too long for its container scrolls
613
+ sideways and fades at the edge it continues past.
614
+
516
615
  Tabs follow the ARIA tabs pattern with arrow key, Home and End navigation, and dispatch
517
616
  `lc-tabs:change`. `orientation: :vertical` stacks the tabs beside their panels and moves with Arrow Up
518
- and Down; `activation: :manual` moves focus with the arrows and selects with Enter or Space; `list:` adds attributes to the tab list. Tooltips show on hover and keyboard focus, Escape hides them, and they describe
617
+ and Down; `activation: :manual` moves focus with the arrows and selects with Enter or Space; `list:` adds attributes to the tab list. Icon buttons take `tooltip: true` to show their label, or `tooltip: "text"` to describe themselves
618
+ with other text. A tooltip without an `id:` repeats its trigger's label and stays hidden from
619
+ assistive technology. Tooltips show on hover and keyboard focus, Escape hides them, and they describe
519
620
  their trigger, in the top layer; keep essential information visible. Description lists stack on phones and use two
520
621
  columns from `sm`.
521
622
 
@@ -580,6 +681,41 @@ the reader has scrolled to. This documentation site is built with them.
580
681
  <% end %>
581
682
  ```
582
683
 
684
+ `lc_sidebar` is a sticky, full-height app sidebar that folds to an icon rail. Its toggle stores the choice in a
685
+ cookie (`cookie:`, `lc_sidebar` by default) that the helper reads back, so the server renders the next page the
686
+ same way; `state: "collapsed"` or `"expanded"` overrides it. Below `rail_below:` (`:xl` by default; `:md`, `:lg`,
687
+ `:2xl`, or `false` for never) it starts as a rail unless the reader expanded it. On the rail, `lc_nav_list` group
688
+ titles and link labels stay for screen readers only and links center their icons, so give each link a `title:`.
689
+ The current link gets a bar at the sidebar's edge in `--lc-sidebar-indicator` (any background, such as a
690
+ gradient). `--lc-sidebar-width` (15rem) and `--lc-sidebar-rail-width` (4rem) set the widths, and the `lc-rail:`
691
+ variant styles your own content on the rail, as in `lc-rail:hidden`. It dispatches `lc-sidebar:toggle` with
692
+ `{ collapsed }`.
693
+
694
+ ```erb
695
+ <%= lc_sidebar cookie: "sidebar" do |sidebar| %>
696
+ <%= sidebar.header do %>
697
+ <%= link_to root_path, aria: { label: "Acme home" } do %>
698
+ <span class="lc-rail:hidden">Acme</span><span class="hidden lc-rail:inline" aria-hidden="true">A</span>
699
+ <% end %>
700
+ <% end %>
701
+ <%= sidebar.body do %>
702
+ <%= lc_nav_list label: "Main", indicator: true do |nav| %>
703
+ <%= nav.link "Inbox", inbox_path, icon: "inbox", title: "Inbox", current: true %>
704
+ <% end %>
705
+ <% end %>
706
+ <%= sidebar.footer do %>
707
+ <%= sidebar.account current_user.name, detail: current_user.email, avatar: lc_avatar(current_user.initials, size: :sm) do %>
708
+ <%= lc_menu_option "Settings", icon: "cog-6-tooth", href: settings_path %>
709
+ <%= lc_menu_option "Sign out", href: session_path, method: :delete %>
710
+ <% end %>
711
+ <% end %>
712
+ <% end %>
713
+ ```
714
+
715
+ `sidebar.header` renders the toggle after its block (`toggle: false` leaves it out; `sidebar.toggle` renders it
716
+ anywhere). `sidebar.account` is a full-width row, the avatar, name, a detail line and an ellipsis, that opens an
717
+ `lc_menu` of the block's options; on the rail only the avatar shows.
718
+
583
719
  For rendered Markdown, such as a Kiln `.md` view, pass the HTML to both: `lc_prose(anchors: true) { html }`
584
720
  links its headings, and `lc_toc(headings: html)` lists them. On phones, `lc_dock` floats `dock.nav` and a
585
721
  `dock.menu` of quick actions at the bottom of the screen; render it last, since it reserves its height there.
@@ -867,7 +1003,10 @@ styles a kicker or footer column label; under `lang="ja"` it keeps natural case
867
1003
  Stacks and inline groups take the spacing names from [Foundations](#foundations). `lc_stack`, `lc_inline`,
868
1004
  `lc_text` and `lc_card` take `as:` to render a meaningful element, such as `lc_stack(as: :ul)`, `lc_text(as: :span)` or
869
1005
  `lc_card(as: :section)`. `lc_section` leaves
870
- `heading` below its title and `content` between blocks. `lc_section_header` is that heading row on its own,
1006
+ `heading` below its title and `content` between blocks. `lc_split` lays out a main column and an aside: one
1007
+ column on small screens, and from `lg` a flexible main beside an aside of `aside: :sm` (16rem), `:md` (20rem)
1008
+ or `:lg` (24rem). `lc_columns(count: 2)` flows groups, such as settings sections, into balanced columns from
1009
+ `lg` (`count: 3` adds a third from `xl`) without breaking a group across two. `lc_section_header` is that heading row on its own,
871
1010
  for a heading that needs more than a title, such as a lede under it. `lc_container` provides `page`, `reading` and
872
1011
  `form` widths; only the page container adds gutters. Japanese headings inherit `lang="ja"` and use
873
1012
  natural letter spacing.
@@ -950,6 +1089,8 @@ Generated by `bin/rails lostcoords:ui:builders`; `bin/lint` checks this list aga
950
1089
  - `lc_stack_class(gap: :content, extra: nil)` (LayoutHelper)
951
1090
  - `lc_inline_class(gap: :related, extra: nil)` (LayoutHelper)
952
1091
  - `lc_container_class(size: :page, extra: nil)` (LayoutHelper)
1092
+ - `lc_split_class(aside: :md, extra: nil)` (LayoutHelper)
1093
+ - `lc_columns_class(count: 2, extra: nil)` (LayoutHelper)
953
1094
  - `lc_section_header_class(extra: nil)` (LayoutHelper)
954
1095
  - `lc_popover_class(align: :end, extra: nil)` (MenuHelper)
955
1096
  - `lc_menu_popover_class(align: :end, extra: nil)` (MenuHelper)
@@ -3,6 +3,7 @@
3
3
  @layer base {
4
4
  :root { color-scheme: light; }
5
5
  html[data-theme="dark"] { color-scheme: dark; }
6
+ html[data-theme="system"] { color-scheme: light dark; }
6
7
 
7
8
  body {
8
9
  background-color: var(--background);
@@ -1,4 +1,4 @@
1
- /* lc_app_header, lc_docs_shell and lc_dock. */
1
+ /* lc_app_header, lc_sidebar, lc_docs_shell and lc_dock. */
2
2
  @import "../shell.css";
3
3
  @source "../../../../../helpers/lostcoords/ui/shell_helper.rb";
4
- @source "../../../../../javascript/lostcoords/ui/controllers/lc_{app_header,dock}_controller.js";
4
+ @source "../../../../../javascript/lostcoords/ui/controllers/lc_{app_header,dock,sidebar}_controller.js";
@@ -5,7 +5,7 @@
5
5
  @import "./theme.css";
6
6
  @source "../../../../helpers/lostcoords/ui/{badge,button,card,choice,copy_button,description_list,feedback,form,glass,icon,layout,list_group,navigation,primitives,render_attributes,structures,tailwind,translation,typography}_helper.rb";
7
7
  @source "../../../../javascript/lostcoords/ui/helpers/*.js";
8
- @source "../../../../javascript/lostcoords/ui/controllers/lc_{copy,kbd,nav,scroll_keeper,selection,shortcut,tabs,toc,toggle}_controller.js";
8
+ @source "../../../../javascript/lostcoords/ui/controllers/lc_{char_counter,copy,kbd,nav,scroll_keeper,selection,shortcut,tabs,toc,toggle}_controller.js";
9
9
  @source "../../../../../lib/lostcoords/ui/parts.rb";
10
10
 
11
11
  @import "./glass.css";
@@ -18,4 +18,5 @@
18
18
  @import "./layout.css";
19
19
  @import "./field.css";
20
20
  @import "./choice.css";
21
+ @import "./toggle-group.css";
21
22
  @import "./copy-button.css";
@@ -4,25 +4,81 @@
4
4
  --lc-sticky-offset: 5rem;
5
5
  }
6
6
 
7
- @layer components {
8
- .lc-app-header__glass {
9
- opacity: 0;
10
- transition: opacity 300ms ease;
7
+ /* lc_sidebar folds to an icon rail when the reader collapsed it, or below its
8
+ rail_below breakpoint unless they expanded it. lc-rail: styles anything in it
9
+ for the rail, as in lc-rail:hidden. */
10
+ @custom-variant lc-rail {
11
+ &:where(.lc-sidebar[data-collapsed], .lc-sidebar[data-collapsed] *) {
12
+ @slot;
13
+ }
14
+ @media (width < 48rem) {
15
+ &:where(.lc-sidebar[data-rail-below="md"]:not([data-expanded]), .lc-sidebar[data-rail-below="md"]:not([data-expanded]) *) {
16
+ @slot;
17
+ }
11
18
  }
12
-
13
- .lc-app-header[data-scrolled] .lc-app-header__glass {
14
- opacity: 1;
19
+ @media (width < 64rem) {
20
+ &:where(.lc-sidebar[data-rail-below="lg"]:not([data-expanded]), .lc-sidebar[data-rail-below="lg"]:not([data-expanded]) *) {
21
+ @slot;
22
+ }
23
+ }
24
+ @media (width < 80rem) {
25
+ &:where(.lc-sidebar[data-rail-below="xl"]:not([data-expanded]), .lc-sidebar[data-rail-below="xl"]:not([data-expanded]) *) {
26
+ @slot;
27
+ }
28
+ }
29
+ @media (width < 96rem) {
30
+ &:where(.lc-sidebar[data-rail-below="2xl"]:not([data-expanded]), .lc-sidebar[data-rail-below="2xl"]:not([data-expanded]) *) {
31
+ @slot;
32
+ }
15
33
  }
34
+ }
16
35
 
36
+ @layer components {
17
37
  /* The sidebar scrolls on its own without a visible scrollbar. */
18
- .lc-docs-shell__sidebar {
38
+ .lc-sidebar {
19
39
  scrollbar-width: none;
20
40
  }
21
41
 
22
- .lc-docs-shell__sidebar::-webkit-scrollbar {
42
+ .lc-sidebar::-webkit-scrollbar {
23
43
  display: none;
24
44
  }
25
45
 
46
+ /* A bar at the sidebar's edge marks the current link. Set --lc-sidebar-indicator
47
+ to any background, such as a gradient. On the rail, links center their icons
48
+ and their labels and group titles stay for screen readers only. */
49
+ .lc-sidebar [data-slot="nav-link"] {
50
+ position: relative;
51
+
52
+ @apply lc-rail:justify-center;
53
+ }
54
+
55
+ .lc-sidebar [data-slot="nav-link"][aria-current="page"]::before {
56
+ content: "";
57
+ position: absolute;
58
+ inset-block: calc(var(--spacing) * 2);
59
+ inset-inline-start: calc(var(--spacing-related) * -1);
60
+ width: calc(var(--spacing) * 0.75);
61
+ border-radius: var(--radius-pill);
62
+ background: var(--lc-sidebar-indicator, var(--primary));
63
+ }
64
+
65
+ .lc-sidebar :is([data-slot="nav-group-title"], [data-slot="nav-link"] > span) {
66
+ @apply lc-rail:sr-only;
67
+ }
68
+
69
+ /* The toggle's chevrons point the way the sidebar will move. */
70
+ .lc-sidebar__toggle svg {
71
+ transition: rotate var(--lc-motion-control) var(--lc-ease-out);
72
+
73
+ @apply lc-rail:rotate-180;
74
+ }
75
+
76
+ .lc-sidebar__toggle:dir(rtl) svg {
77
+ rotate: 180deg;
78
+
79
+ @apply lc-rail:rotate-0;
80
+ }
81
+
26
82
  .lc-dock {
27
83
  --lc-dock-edge: max(1rem, env(safe-area-inset-left));
28
84
  --lc-dock-gap: max(1rem, env(safe-area-inset-right));
@@ -132,6 +188,7 @@
132
188
 
133
189
  @media (prefers-reduced-motion: reduce) {
134
190
  .lc-app-header__glass,
191
+ .lc-sidebar__toggle svg,
135
192
  .lc-dock__trigger svg,
136
193
  .lc-dock__scrim,
137
194
  .lc-dock__action,
@@ -109,7 +109,31 @@
109
109
  --container-form: 32rem;
110
110
  }
111
111
 
112
- @custom-variant dark (&:where(html[data-theme="dark"], html[data-theme="dark"] *));
112
+ /* data-theme="system" follows the OS, for a host that leaves the choice unresolved in cached HTML. */
113
+ @custom-variant dark {
114
+ &:where(html[data-theme="dark"], html[data-theme="dark"] *) {
115
+ @slot;
116
+ }
117
+
118
+ @media (prefers-color-scheme: dark) {
119
+ &:where(html[data-theme="system"], html[data-theme="system"] *) {
120
+ @slot;
121
+ }
122
+ }
123
+ }
124
+
125
+ /* The dark token block's own selector. A host may redefine `dark` to scope it; this one stays put. */
126
+ @custom-variant lc-dark-tokens {
127
+ &[data-theme="dark"] {
128
+ @slot;
129
+ }
130
+
131
+ @media (prefers-color-scheme: dark) {
132
+ &[data-theme="system"] {
133
+ @slot;
134
+ }
135
+ }
136
+ }
113
137
 
114
138
  @layer theme {
115
139
  :root {
@@ -213,44 +237,46 @@
213
237
  }
214
238
  }
215
239
 
216
- html[data-theme="dark"] {
217
- --background: oklch(20.5% 0 0deg);
218
- --foreground: oklch(91.5% 0 0deg);
219
- --primary: oklch(91.5% 0 0deg);
220
- --primary-foreground: var(--background);
221
- --muted: oklch(24.2% 0 0deg);
222
- --muted-foreground: color-mix(in oklab, var(--foreground) 76%, var(--background));
223
- --accent: oklch(28.4% 0 0deg);
224
- --destructive: oklch(78% 0.120 41.4deg);
225
- --success: oklch(78% 0.089 144.3deg);
226
- --warning: oklch(80% 0.110 86deg);
227
- --border: color-mix(in oklab, var(--foreground) 16%, transparent);
228
-
229
- --lc-scrim: rgb(0 0 0 / 0.6);
230
- --lc-scrim-soft: rgb(0 0 0 / 0.32);
231
- --lc-scrim-veil: rgb(0 0 0 / 0.4);
232
-
233
- --lc-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.2);
234
- --lc-shadow:
235
- 0 1px 2px rgb(0 0 0 / 0.16),
236
- 0 8px 24px -8px rgb(0 0 0 / 0.32);
237
- --lc-shadow-lg:
238
- 0 1px 3px rgb(0 0 0 / 0.2),
239
- 0 24px 48px -12px rgb(0 0 0 / 0.55);
240
-
241
- --lc-glass-fill: color-mix(in oklab, var(--background) 80%, transparent);
242
- --lc-glass-edge: transparent;
243
- --lc-glass-rim: 0 0 #0000;
244
- --lc-glass-bar-edge: rgb(255 255 255 / 0.06);
245
- --lc-glass-shadow: 0 1px 3px rgb(0 0 0 / 0.04), 0 4px 12px rgb(0 0 0 / 0.03);
246
- --lc-glass-hud-fill:
247
- linear-gradient(rgb(255 255 255 / 0.06), rgb(255 255 255 / 0) 60%),
248
- color-mix(in oklab, var(--accent) 90%, transparent);
249
- --lc-glass-hud-solid: var(--accent);
250
- --lc-glass-hud-shadow:
251
- inset 0 1px 0 rgb(255 255 255 / 0.1),
252
- inset 0 0 0 1px rgb(255 255 255 / 0.1),
253
- 0 8px 20px -8px rgb(0 0 0 / 0.6);
240
+ html {
241
+ @variant lc-dark-tokens {
242
+ --background: oklch(20.5% 0 0deg);
243
+ --foreground: oklch(91.5% 0 0deg);
244
+ --primary: oklch(91.5% 0 0deg);
245
+ --primary-foreground: var(--background);
246
+ --muted: oklch(24.2% 0 0deg);
247
+ --muted-foreground: color-mix(in oklab, var(--foreground) 76%, var(--background));
248
+ --accent: oklch(28.4% 0 0deg);
249
+ --destructive: oklch(78% 0.120 41.4deg);
250
+ --success: oklch(78% 0.089 144.3deg);
251
+ --warning: oklch(80% 0.110 86deg);
252
+ --border: color-mix(in oklab, var(--foreground) 16%, transparent);
253
+
254
+ --lc-scrim: rgb(0 0 0 / 0.6);
255
+ --lc-scrim-soft: rgb(0 0 0 / 0.32);
256
+ --lc-scrim-veil: rgb(0 0 0 / 0.4);
257
+
258
+ --lc-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.2);
259
+ --lc-shadow:
260
+ 0 1px 2px rgb(0 0 0 / 0.16),
261
+ 0 8px 24px -8px rgb(0 0 0 / 0.32);
262
+ --lc-shadow-lg:
263
+ 0 1px 3px rgb(0 0 0 / 0.2),
264
+ 0 24px 48px -12px rgb(0 0 0 / 0.55);
265
+
266
+ --lc-glass-fill: color-mix(in oklab, var(--background) 80%, transparent);
267
+ --lc-glass-edge: transparent;
268
+ --lc-glass-rim: 0 0 #0000;
269
+ --lc-glass-bar-edge: rgb(255 255 255 / 0.06);
270
+ --lc-glass-shadow: 0 1px 3px rgb(0 0 0 / 0.04), 0 4px 12px rgb(0 0 0 / 0.03);
271
+ --lc-glass-hud-fill:
272
+ linear-gradient(rgb(255 255 255 / 0.06), rgb(255 255 255 / 0) 60%),
273
+ color-mix(in oklab, var(--accent) 90%, transparent);
274
+ --lc-glass-hud-solid: var(--accent);
275
+ --lc-glass-hud-shadow:
276
+ inset 0 1px 0 rgb(255 255 255 / 0.1),
277
+ inset 0 0 0 1px rgb(255 255 255 / 0.1),
278
+ 0 8px 20px -8px rgb(0 0 0 / 0.6);
279
+ }
254
280
  }
255
281
 
256
282
  html:lang(ja) { --font-sans: var(--font-japanese); }
@@ -0,0 +1,58 @@
1
+ /* Segmented toggle group (lc_toggle_group_class, lc_toggle_group_item_class).
2
+
3
+ Where anchor positioning is supported, the current item's surface is one
4
+ indicator on the track that slides from item to item, whichever state marks
5
+ it (aria-current, aria-selected, aria-checked, aria-pressed, a checked radio
6
+ or the active: class). Elsewhere each current item paints its own surface. */
7
+
8
+ @layer components {
9
+ /* Concentric with the track: its radius (rounded-2xl) less its padding (p-1).
10
+ Spelled out because --radius-2xl resolves at :root, before lc-squircle
11
+ scales it. */
12
+ .lc-toggle-group {
13
+ --lc-toggle-item-radius: calc(var(--radius) * 2 * var(--lc-corner-scale, 1) - var(--spacing));
14
+ position: relative;
15
+ isolation: isolate;
16
+ }
17
+ }
18
+
19
+ @supports (anchor-name: --a) and (anchor-scope: all) {
20
+ .lc-toggle-group {
21
+ anchor-scope: --lc-toggle-current;
22
+ }
23
+
24
+ .lc-toggle-group::after {
25
+ content: "";
26
+ position: absolute;
27
+ z-index: -1;
28
+ position-anchor: --lc-toggle-current;
29
+ inset: anchor(top) anchor(right) anchor(bottom) anchor(left);
30
+ border-radius: var(--lc-toggle-item-radius);
31
+ corner-shape: inherit;
32
+ background-color: var(--color-background);
33
+ pointer-events: none;
34
+ }
35
+
36
+ @media (prefers-reduced-motion: no-preference) {
37
+ .lc-toggle-group::after {
38
+ transition: inset var(--lc-motion-control) var(--lc-ease-out);
39
+ }
40
+ }
41
+
42
+ /* Unlayered, so it wins over the items' own aria-*:bg-background utilities. */
43
+ .lc-toggle-group .lc-toggle-group-item {
44
+ background-color: transparent;
45
+ }
46
+
47
+ .lc-toggle-group
48
+ .lc-toggle-group-item:is(
49
+ [aria-current]:not([aria-current="false"]),
50
+ [aria-selected="true"],
51
+ [aria-checked="true"],
52
+ [aria-pressed="true"],
53
+ :has(input:checked),
54
+ .lc-toggle-group-item-active
55
+ ) {
56
+ anchor-name: --lc-toggle-current;
57
+ }
58
+ }
@@ -80,21 +80,23 @@ module Lostcoords::Ui
80
80
 
81
81
  BADGE_SHAPES = { rounded: "", pill: "rounded-full px-2.5" }.freeze
82
82
 
83
+ # A selected pill fills solid with the primary color; its border stays transparent, so the
84
+ # fill alone carries the state and selecting never shifts the pill's edge.
83
85
  TOGGLE_BASE =
84
86
  "inline-flex items-center justify-center gap-related rounded-pill " \
85
87
  "border border-transparent bg-(--lc-field-bg,var(--input)) " \
86
88
  "font-sans text-muted-foreground whitespace-nowrap cursor-pointer no-underline " \
87
89
  "transition-[background-color,border-color,color,transform] duration-(--lc-motion-quick) ease-(--lc-ease-out) " \
88
90
  "lc-press hover:text-foreground " \
89
- "aria-pressed:bg-primary-soft aria-pressed:border-primary aria-pressed:text-primary aria-pressed:shadow-none " \
90
- "aria-checked:bg-primary-soft aria-checked:border-primary aria-checked:text-primary aria-checked:shadow-none " \
91
- "aria-[current]:not-aria-[current=false]:bg-primary-soft aria-[current]:not-aria-[current=false]:border-primary " \
92
- "aria-[current]:not-aria-[current=false]:text-primary aria-[current]:not-aria-[current=false]:shadow-none " \
93
- "has-checked:bg-primary-soft has-checked:border-primary has-checked:text-primary has-checked:shadow-none " \
94
- "aria-expanded:bg-primary-soft aria-expanded:border-primary aria-expanded:text-primary aria-expanded:shadow-none " \
91
+ "aria-pressed:bg-primary aria-pressed:border-transparent aria-pressed:text-primary-foreground aria-pressed:shadow-none " \
92
+ "aria-checked:bg-primary aria-checked:border-transparent aria-checked:text-primary-foreground aria-checked:shadow-none " \
93
+ "aria-[current]:not-aria-[current=false]:bg-primary aria-[current]:not-aria-[current=false]:border-transparent " \
94
+ "aria-[current]:not-aria-[current=false]:text-primary-foreground aria-[current]:not-aria-[current=false]:shadow-none " \
95
+ "has-checked:bg-primary has-checked:border-transparent has-checked:text-primary-foreground has-checked:shadow-none " \
96
+ "aria-expanded:bg-primary aria-expanded:border-transparent aria-expanded:text-primary-foreground aria-expanded:shadow-none " \
95
97
  "[&_svg]:size-[1.1em] [&_svg]:shrink-0"
96
98
 
97
- TOGGLE_ACTIVE = "bg-primary-soft border-primary text-primary hover:text-primary shadow-none"
99
+ TOGGLE_ACTIVE = "bg-primary border-transparent text-primary-foreground hover:text-primary-foreground shadow-none"
98
100
 
99
101
  TOGGLE_GHOST = "border-dashed border-muted-foreground/40 [background:none] shadow-none text-muted-foreground"
100
102