velvetkit 0.4.1 → 0.5.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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +143 -2
  3. data/lib/velvetkit/version.rb +1 -1
  4. data/registry/app/components/ui/accordion/trigger.rb +1 -1
  5. data/registry/app/components/ui/badge.rb +1 -1
  6. data/registry/app/components/ui/base.rb +2 -2
  7. data/registry/app/components/ui/button.rb +1 -1
  8. data/registry/app/components/ui/card/action.html.erb +1 -0
  9. data/registry/app/components/ui/card/action.rb +14 -0
  10. data/registry/app/components/ui/card/content.html.erb +1 -1
  11. data/registry/app/components/ui/card/content.rb +4 -2
  12. data/registry/app/components/ui/card/description.html.erb +1 -1
  13. data/registry/app/components/ui/card/description.rb +4 -2
  14. data/registry/app/components/ui/card/footer.html.erb +1 -1
  15. data/registry/app/components/ui/card/footer.rb +4 -2
  16. data/registry/app/components/ui/card/header.html.erb +1 -1
  17. data/registry/app/components/ui/card/header.rb +9 -2
  18. data/registry/app/components/ui/card/title.html.erb +1 -1
  19. data/registry/app/components/ui/card/title.rb +4 -2
  20. data/registry/app/components/ui/card.html.erb +1 -1
  21. data/registry/app/components/ui/card.rb +49 -3
  22. data/registry/app/components/ui/carousel.html.erb +7 -0
  23. data/registry/app/components/ui/carousel.rb +60 -0
  24. data/registry/app/components/ui/chart.html.erb +3 -3
  25. data/registry/app/components/ui/chart.rb +18 -10
  26. data/registry/app/components/ui/checkbox.html.erb +6 -0
  27. data/registry/app/components/ui/checkbox.rb +11 -4
  28. data/registry/app/components/ui/fieldset.html.erb +6 -0
  29. data/registry/app/components/ui/fieldset.rb +76 -0
  30. data/registry/app/components/ui/gallery/image.rb +14 -1
  31. data/registry/app/components/ui/gallery.html.erb +32 -3
  32. data/registry/app/components/ui/gallery.rb +46 -7
  33. data/registry/app/components/ui/link.rb +1 -1
  34. data/registry/app/components/ui/menu/item.rb +1 -1
  35. data/registry/app/components/ui/radio_group/item.html.erb +1 -1
  36. data/registry/app/components/ui/radio_group/item.rb +5 -1
  37. data/registry/app/components/ui/radio_group.html.erb +1 -1
  38. data/registry/app/components/ui/radio_group.rb +42 -2
  39. data/registry/app/components/ui/scrubber.html.erb +18 -0
  40. data/registry/app/components/ui/scrubber.rb +62 -0
  41. data/registry/app/components/ui/select.html.erb +1 -1
  42. data/registry/app/components/ui/select.rb +16 -1
  43. data/registry/app/components/ui/selection_bar.html.erb +7 -0
  44. data/registry/app/components/ui/selection_bar.rb +75 -0
  45. data/registry/app/components/ui/sidebar/group_label.rb +1 -1
  46. data/registry/app/components/ui/sidebar/inset.rb +5 -2
  47. data/registry/app/components/ui/sidebar/menu_button.rb +24 -9
  48. data/registry/app/components/ui/sidebar/menu_item.html.erb +1 -1
  49. data/registry/app/components/ui/sidebar/menu_item.rb +31 -5
  50. data/registry/app/components/ui/sidebar/menu_sub.rb +59 -0
  51. data/registry/app/components/ui/sidebar.html.erb +3 -3
  52. data/registry/app/components/ui/sidebar.rb +91 -13
  53. data/registry/app/components/ui/switch.rb +2 -2
  54. data/registry/app/components/ui/table/column.html.erb +1 -1
  55. data/registry/app/components/ui/table/column.rb +26 -2
  56. data/registry/app/components/ui/table/head.html.erb +1 -1
  57. data/registry/app/components/ui/table/head.rb +15 -2
  58. data/registry/app/components/ui/table/row.html.erb +1 -1
  59. data/registry/app/components/ui/table/row.rb +19 -5
  60. data/registry/app/components/ui/table.html.erb +2 -2
  61. data/registry/app/components/ui/table.rb +29 -4
  62. data/registry/app/components/ui/tabs/trigger.rb +1 -1
  63. data/registry/app/components/ui/toggle_group.html.erb +1 -1
  64. data/registry/app/components/ui/toggle_group.rb +26 -3
  65. data/registry/app/javascript/controllers/ui/carousel_controller.ts +63 -0
  66. data/registry/app/javascript/controllers/ui/file_field_controller.ts +1 -1
  67. data/registry/app/javascript/controllers/ui/gallery_controller.ts +52 -14
  68. data/registry/app/javascript/controllers/ui/scrubber_controller.ts +188 -0
  69. data/registry/app/javascript/controllers/ui/selection_bar_controller.ts +122 -0
  70. data/registry/app/javascript/controllers/ui/sidebar_controller.ts +102 -32
  71. data/registry/components.yml +12 -4
  72. data/registry/config/locales/velvetkit.en.yml +16 -0
  73. data/registry/icons/lucide/arrow-down.svg +16 -0
  74. data/registry/icons/lucide/arrow-up.svg +16 -0
  75. data/registry/icons/lucide/image.svg +17 -0
  76. data/registry/icons/lucide/star.svg +15 -0
  77. data/registry/icons/phosphor/arrow-down.svg +2 -0
  78. data/registry/icons/phosphor/arrow-up.svg +2 -0
  79. data/registry/icons/phosphor/image.svg +2 -0
  80. data/registry/icons/phosphor/star.svg +2 -0
  81. data/registry/icons/tabler/arrow-down.svg +18 -0
  82. data/registry/icons/tabler/arrow-up.svg +18 -0
  83. data/registry/icons/tabler/photo.svg +19 -0
  84. data/registry/icons/tabler/star.svg +16 -0
  85. data/registry/icons.yml +4 -0
  86. data/registry/test/components/previews/ui/card_preview/edge_to_edge.html.erb +19 -0
  87. data/registry/test/components/previews/ui/card_preview/image.html.erb +12 -0
  88. data/registry/test/components/previews/ui/card_preview/just_content.html.erb +10 -0
  89. data/registry/test/components/previews/ui/card_preview/open_bill.html.erb +18 -0
  90. data/registry/test/components/previews/ui/card_preview/playground.html.erb +17 -0
  91. data/registry/test/components/previews/ui/card_preview/settings_form.html.erb +15 -24
  92. data/registry/test/components/previews/ui/card_preview/sign_in.html.erb +23 -0
  93. data/registry/test/components/previews/ui/card_preview/small.html.erb +17 -0
  94. data/registry/test/components/previews/ui/card_preview/spacing.html.erb +13 -0
  95. data/registry/test/components/previews/ui/card_preview/stats.html.erb +11 -0
  96. data/registry/test/components/previews/ui/card_preview/team.html.erb +21 -0
  97. data/registry/test/components/previews/ui/card_preview.rb +42 -28
  98. data/registry/test/components/previews/ui/carousel_preview/highlights.html.erb +17 -0
  99. data/registry/test/components/previews/ui/carousel_preview.rb +22 -0
  100. data/registry/test/components/previews/ui/chart_preview/whole_dollars.html.erb +19 -0
  101. data/registry/test/components/previews/ui/chart_preview.rb +7 -1
  102. data/registry/test/components/previews/ui/checkbox_preview/in_form.html.erb +2 -3
  103. data/registry/test/components/previews/ui/fieldset_preview/block_of_fields.html.erb +18 -0
  104. data/registry/test/components/previews/ui/fieldset_preview/groups.html.erb +14 -0
  105. data/registry/test/components/previews/ui/fieldset_preview/model_errors.html.erb +22 -0
  106. data/registry/test/components/previews/ui/fieldset_preview/playground.html.erb +5 -0
  107. data/registry/test/components/previews/ui/fieldset_preview.rb +24 -0
  108. data/registry/test/components/previews/ui/gallery_preview/grid.html.erb +25 -0
  109. data/registry/test/components/previews/ui/gallery_preview.rb +3 -0
  110. data/registry/test/components/previews/ui/scrubber_preview/default.html.erb +24 -0
  111. data/registry/test/components/previews/ui/scrubber_preview.rb +6 -0
  112. data/registry/test/components/previews/ui/selection_bar_preview/floating.html.erb +16 -0
  113. data/registry/test/components/previews/ui/selection_bar_preview/table.html.erb +26 -0
  114. data/registry/test/components/previews/ui/selection_bar_preview.rb +9 -0
  115. data/registry/test/components/previews/ui/sidebar_preview/_shell.html.erb +5 -4
  116. data/registry/test/components/previews/ui/sidebar_preview/pill_links.html.erb +52 -0
  117. data/registry/test/components/previews/ui/sidebar_preview.rb +3 -0
  118. data/registry/test/components/previews/ui/table_preview/selectable.html.erb +26 -0
  119. data/registry/test/components/previews/ui/table_preview/sortable.html.erb +20 -0
  120. data/registry/test/components/previews/ui/table_preview/sticky_header.html.erb +13 -0
  121. data/registry/test/components/previews/ui/table_preview.rb +9 -0
  122. data/registry/test/components/ui/button_test.rb +2 -2
  123. data/registry/test/components/ui/card/action_test.rb +19 -0
  124. data/registry/test/components/ui/card/content_test.rb +1 -11
  125. data/registry/test/components/ui/card/footer_test.rb +3 -2
  126. data/registry/test/components/ui/card/header_test.rb +3 -4
  127. data/registry/test/components/ui/card/title_test.rb +3 -4
  128. data/registry/test/components/ui/card_test.rb +63 -2
  129. data/registry/test/components/ui/carousel_test.rb +38 -0
  130. data/registry/test/components/ui/chart_test.rb +20 -0
  131. data/registry/test/components/ui/checkbox_test.rb +11 -2
  132. data/registry/test/components/ui/fieldset_test.rb +119 -0
  133. data/registry/test/components/ui/gallery_test.rb +40 -5
  134. data/registry/test/components/ui/link_test.rb +1 -1
  135. data/registry/test/components/ui/number_input_test.rb +1 -1
  136. data/registry/test/components/ui/radio_group_test.rb +106 -0
  137. data/registry/test/components/ui/scrubber_test.rb +43 -0
  138. data/registry/test/components/ui/select_test.rb +21 -0
  139. data/registry/test/components/ui/selection_bar_test.rb +46 -0
  140. data/registry/test/components/ui/sidebar/menu_button_test.rb +9 -0
  141. data/registry/test/components/ui/sidebar_test.rb +79 -1
  142. data/registry/test/components/ui/switch_test.rb +4 -4
  143. data/registry/test/components/ui/toggle_group_test.rb +45 -0
  144. metadata +60 -5
  145. data/registry/test/components/previews/ui/card_preview/complete.html.erb +0 -31
  146. data/registry/test/components/previews/ui/card_preview/default.html.erb +0 -7
  147. data/registry/test/components/previews/ui/card_preview/with_footer.html.erb +0 -13
  148. data/registry/test/components/previews/ui/card_preview/with_header.html.erb +0 -11
@@ -1,64 +1,134 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
- type SidebarState = 'collapsed' | 'expanded';
4
- type CollapsibleType = 'icon' | 'none';
3
+ // Connects to data-controller="ui--sidebar", on UI::Sidebar::Wrapper.
4
+ //
5
+ // On a wide screen the trigger collapses the sidebar, to its icons or out of
6
+ // sight as `collapsible:` says, and the choice goes in a cookie so the server
7
+ // draws the next page the same way. On a phone the sidebar is a drawer: the
8
+ // trigger opens it over the page, and Escape, the backdrop or a link close it.
9
+ const MOBILE = '(max-width: 767.98px)';
10
+ const YEAR = 60 * 60 * 24 * 365;
11
+ const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])';
5
12
 
6
13
  export default class extends Controller<HTMLElement> {
7
- static targets = ['sidebar', 'trigger'];
14
+ static targets = ['sidebar', 'container', 'trigger'];
8
15
 
9
16
  declare readonly hasSidebarTarget: boolean;
10
- declare readonly hasTriggerTarget: boolean;
11
17
  declare readonly sidebarTarget: HTMLElement;
18
+ declare readonly containerTarget: HTMLElement;
12
19
  declare readonly triggerTargets: HTMLElement[];
13
20
 
21
+ private media = window.matchMedia(MOBILE);
22
+ private opener: HTMLElement | null = null;
23
+
14
24
  connect() {
15
- if (!this.hasSidebarTarget) return;
25
+ this.media.addEventListener('change', this.resized);
26
+ this.element.addEventListener('keydown', this.escape);
27
+ document.addEventListener('turbo:before-cache', this.close);
28
+ this.resized();
29
+ }
16
30
 
17
- const savedState = localStorage.getItem('ui-sidebar-state') as SidebarState | null;
18
- const savedCollapsible = localStorage.getItem('ui-sidebar-collapsible') as CollapsibleType | null;
31
+ disconnect() {
32
+ this.media.removeEventListener('change', this.resized);
33
+ this.element.removeEventListener('keydown', this.escape);
34
+ document.removeEventListener('turbo:before-cache', this.close);
35
+ document.documentElement.style.removeProperty('overflow');
36
+ }
37
+
38
+ toggle(event?: Event) {
39
+ if (!this.hasSidebarTarget) return;
19
40
 
20
- if (savedState && savedCollapsible) {
21
- this.setSidebarState(savedState);
22
- this.setSidebarCollapsibleType(savedCollapsible);
41
+ if (this.mobile) {
42
+ if (this.drawerOpen) this.close();
43
+ else this.open(event?.currentTarget as HTMLElement | undefined);
44
+ return;
23
45
  }
46
+ if (this.mode === 'none') return;
24
47
 
48
+ this.setState(this.state === 'collapsed' ? 'expanded' : 'collapsed');
49
+ }
50
+
51
+ open(opener?: HTMLElement) {
52
+ this.opener = opener ?? (document.activeElement as HTMLElement | null);
53
+ this.sidebarTarget.dataset.mobile = 'open';
54
+ document.documentElement.style.overflow = 'hidden';
25
55
  this.syncTriggers();
56
+ // The current page's link, or else the first thing to focus.
57
+ const first = this.containerTarget.querySelector<HTMLElement>('a[aria-current]') ?? this.containerTarget.querySelector<HTMLElement>(FOCUSABLE);
58
+ // Hidden until the slide's first frame is drawn, and focus can't land on
59
+ // what's hidden, so it waits a frame more.
60
+ requestAnimationFrame(() => requestAnimationFrame(() => first?.focus({ preventScroll: true })));
26
61
  }
27
62
 
28
- toggle() {
29
- if (!this.hasSidebarTarget) return;
63
+ close = () => {
64
+ if (!this.hasSidebarTarget || !this.drawerOpen) return;
30
65
 
31
- if (this.sidebarState() === 'collapsed') {
32
- this.setSidebarState('expanded');
33
- this.setSidebarCollapsibleType('none');
34
- } else {
35
- this.setSidebarState('collapsed');
36
- this.setSidebarCollapsibleType('icon');
66
+ delete this.sidebarTarget.dataset.mobile;
67
+ document.documentElement.style.removeProperty('overflow');
68
+ this.syncTriggers();
69
+ if (this.containerTarget.contains(document.activeElement)) this.opener?.focus({ preventScroll: true });
70
+ this.opener = null;
71
+ };
72
+
73
+ // A link followed in the drawer closes it, so the next page isn't under it.
74
+ navigate(event: Event) {
75
+ if (this.mobile && (event.target as Element).closest('a[href]')) this.close();
76
+ }
77
+
78
+ // Opens or closes a group of links under a menu item.
79
+ toggleSub(event: Event) {
80
+ const button = event.currentTarget as HTMLElement;
81
+ const sub = document.getElementById(button.getAttribute('aria-controls') ?? '');
82
+ if (!sub) return;
83
+
84
+ const open = button.getAttribute('aria-expanded') !== 'true';
85
+ button.setAttribute('aria-expanded', String(open));
86
+ sub.hidden = !open;
87
+ }
88
+
89
+ private escape = (event: KeyboardEvent) => {
90
+ if (event.key === 'Escape' && this.drawerOpen) {
91
+ event.preventDefault();
92
+ this.close();
37
93
  }
94
+ };
95
+
96
+ // Icons alone would leave the drawer unreadable, so on a phone the sidebar
97
+ // shows in full whatever was chosen on a wide screen.
98
+ private resized = () => {
99
+ if (!this.hasSidebarTarget) return;
38
100
 
101
+ if (!this.mobile) this.close();
102
+ this.sidebarTarget.dataset.collapsible = !this.mobile && this.state === 'collapsed' ? this.mode : '';
103
+ this.syncTriggers();
104
+ };
105
+
106
+ private setState(state: 'expanded' | 'collapsed') {
107
+ this.sidebarTarget.dataset.state = state;
108
+ this.sidebarTarget.dataset.collapsible = state === 'collapsed' ? this.mode : '';
109
+ const name = this.sidebarTarget.dataset.cookie;
110
+ if (name) document.cookie = `${name}=${state}; path=/; max-age=${YEAR}; samesite=lax`;
39
111
  this.syncTriggers();
40
112
  }
41
113
 
42
- private sidebarState(): SidebarState {
43
- return (this.sidebarTarget.getAttribute('data-state') as SidebarState) || 'expanded';
114
+ private syncTriggers() {
115
+ const expanded = this.mobile ? this.drawerOpen : this.state !== 'collapsed';
116
+ this.triggerTargets.forEach((trigger) => trigger.setAttribute('aria-expanded', String(expanded)));
44
117
  }
45
118
 
46
- private setSidebarState(state: SidebarState) {
47
- localStorage.setItem('ui-sidebar-state', state);
48
- this.sidebarTarget.setAttribute('data-state', state);
119
+ private get state() {
120
+ return this.sidebarTarget.dataset.state === 'collapsed' ? 'collapsed' : 'expanded';
49
121
  }
50
122
 
51
- private setSidebarCollapsibleType(type: CollapsibleType) {
52
- localStorage.setItem('ui-sidebar-collapsible', type);
53
- this.sidebarTarget.setAttribute('data-collapsible', type);
123
+ private get mode() {
124
+ return this.sidebarTarget.dataset.collapsibleMode ?? 'icon';
54
125
  }
55
126
 
56
- private syncTriggers() {
57
- if (!this.hasTriggerTarget) return;
127
+ private get mobile() {
128
+ return this.media.matches;
129
+ }
58
130
 
59
- const expanded = this.sidebarState() !== 'collapsed';
60
- this.triggerTargets.forEach((trigger) => {
61
- trigger.setAttribute('aria-expanded', expanded ? 'true' : 'false');
62
- });
131
+ private get drawerOpen() {
132
+ return this.sidebarTarget.dataset.mobile === 'open';
63
133
  }
64
134
  }
@@ -41,7 +41,9 @@ components:
41
41
  button_to:
42
42
  description: A button that submits a one-off form, like Rails' button_to.
43
43
  card:
44
- description: A bordered container with header, content and footer.
44
+ description: A surface for one thing, with a header and action, body, footer and optional image.
45
+ carousel:
46
+ description: A row of cards that swipes and scrolls sideways, with buttons that show while there's more to see.
45
47
  chart:
46
48
  description: Line and bar charts, with a legend, tooltips and the numbers as a table, on Chart.js.
47
49
  checkbox:
@@ -62,12 +64,14 @@ components:
62
64
  description: A horizontal or vertical rule, optionally labelled.
63
65
  empty_state:
64
66
  description: What a page shows when it has nothing to list yet, with a way to add the first thing.
67
+ fieldset:
68
+ description: A group of controls under one legend, with a hint and an error message for the group.
65
69
  file_field:
66
70
  description: A drag-and-drop file picker with previews, and direct upload to storage, standalone or with a form builder.
67
71
  form_field:
68
72
  description: A label, hint and error message wired to any form control.
69
73
  gallery:
70
- description: A product's photos, with thumbnails, swiping, and a full-screen view to zoom in.
74
+ description: Photos with thumbnails, swiping, and a full-screen view to zoom in, opened from the page's own grid too.
71
75
  icon:
72
76
  description: An SVG icon from your chosen icon library, drawn inline on the server.
73
77
  image:
@@ -105,14 +109,18 @@ components:
105
109
  description: The browser's own select, styled closed; best for phones' system pickers.
106
110
  scan_input:
107
111
  description: A field for a barcode or QR scanner, submitting each code as it's scanned and keeping focus.
112
+ scrubber:
113
+ description: A rail down the side of a long list for jumping through it by date, by dragging or from the keyboard.
108
114
  select:
109
115
  description: A styled dropdown with keyboard navigation and type-ahead, posting like a native select.
116
+ selection_bar:
117
+ description: The count of rows or items chosen, a button to clear them and the actions for all of them at once.
110
118
  session_tabs:
111
119
  description: Browser-style tabs the user opens, renames, duplicates, reorders and closes.
112
120
  sheet:
113
121
  description: A panel that slides in from an edge of the screen.
114
122
  sidebar:
115
- description: A collapsible application sidebar with groups and menus.
123
+ description: An app's sidebar with groups, links that open sub-menus, and a drawer on phones, collapsing to icons.
116
124
  skeleton:
117
125
  description: A pulsing placeholder shown in a piece of content's shape while it loads.
118
126
  slider:
@@ -124,7 +132,7 @@ components:
124
132
  switch:
125
133
  description: An on/off toggle.
126
134
  table:
127
- description: A styled table with header, rows and caption.
135
+ description: A styled table with a caption, headers that sort, and rows to select.
128
136
  table_of_contents:
129
137
  description: An "On this page" list that follows the reader's scroll.
130
138
  tabs:
@@ -29,6 +29,10 @@ en:
29
29
  this_month: 'This month'
30
30
  last_month: 'Last month'
31
31
  this_year: 'This year'
32
+ carousel:
33
+ roledescription: 'carousel'
34
+ previous: 'Previous'
35
+ next: 'Next'
32
36
  chart:
33
37
  label: 'Chart'
34
38
  keyboard: 'Use the arrow keys to read each value.'
@@ -80,8 +84,18 @@ en:
80
84
  from: 'Minimum'
81
85
  to: 'Maximum'
82
86
  range_text: '%{from} – %{to}'
87
+ selection_bar:
88
+ label: 'Selection'
89
+ clear: 'Clear selection'
90
+ count:
91
+ one: '%{count} selected'
92
+ other: '%{count} selected'
83
93
  sidebar:
84
94
  toggle: 'Toggle sidebar'
95
+ toggle_sub: 'Show the links under %{name}'
96
+ table:
97
+ select_all: 'Select all rows'
98
+ select_row: 'Select %{label}'
85
99
  table_of_contents:
86
100
  label: 'On this page'
87
101
  navigation_menu:
@@ -154,6 +168,8 @@ en:
154
168
  zoom_out: 'Zoom out'
155
169
  thumbnail: 'Show image %{current}'
156
170
  position: 'Image %{current} of %{total}'
171
+ open: 'Open %{alt}'
172
+ info: 'Info'
157
173
  file_field:
158
174
  browse: 'Click to upload'
159
175
  drop: 'or drag and drop'
@@ -0,0 +1,16 @@
1
+ <!-- @license lucide-static v0.545.0 - ISC -->
2
+ <svg
3
+ class="lucide lucide-arrow-down"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ >
14
+ <path d="M12 5v14" />
15
+ <path d="m19 12-7 7-7-7" />
16
+ </svg>
@@ -0,0 +1,16 @@
1
+ <!-- @license lucide-static v0.545.0 - ISC -->
2
+ <svg
3
+ class="lucide lucide-arrow-up"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ >
14
+ <path d="m5 12 7-7 7 7" />
15
+ <path d="M12 19V5" />
16
+ </svg>
@@ -0,0 +1,17 @@
1
+ <!-- @license lucide-static v0.545.0 - ISC -->
2
+ <svg
3
+ class="lucide lucide-image"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ >
14
+ <rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
15
+ <circle cx="9" cy="9" r="2" />
16
+ <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
17
+ </svg>
@@ -0,0 +1,15 @@
1
+ <!-- @license lucide-static v0.545.0 - ISC -->
2
+ <svg
3
+ class="lucide lucide-star"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ stroke-width="2"
11
+ stroke-linecap="round"
12
+ stroke-linejoin="round"
13
+ >
14
+ <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" />
15
+ </svg>
@@ -0,0 +1,2 @@
1
+ <!-- @license @phosphor-icons/core v2.1.1 - MIT -->
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72a8,8,0,0,1,11.32-11.32L120,196.69V40a8,8,0,0,1,16,0V196.69l58.34-58.35a8,8,0,0,1,11.32,11.32Z"/></svg>
@@ -0,0 +1,2 @@
1
+ <!-- @license @phosphor-icons/core v2.1.1 - MIT -->
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z"/></svg>
@@ -0,0 +1,2 @@
1
+ <!-- @license @phosphor-icons/core v2.1.1 - MIT -->
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"/></svg>
@@ -0,0 +1,2 @@
1
+ <!-- @license @phosphor-icons/core v2.1.1 - MIT -->
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z"/></svg>
@@ -0,0 +1,18 @@
1
+ <!-- @license @tabler/icons v3.50.0 - MIT -->
2
+ <svg
3
+ xmlns="http://www.w3.org/2000/svg"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ stroke-width="2"
10
+ stroke-linecap="round"
11
+ stroke-linejoin="round"
12
+ class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-down"
13
+ >
14
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
15
+ <path d="M12 5l0 14" />
16
+ <path d="M18 13l-6 6" />
17
+ <path d="M6 13l6 6" />
18
+ </svg>
@@ -0,0 +1,18 @@
1
+ <!-- @license @tabler/icons v3.50.0 - MIT -->
2
+ <svg
3
+ xmlns="http://www.w3.org/2000/svg"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ stroke-width="2"
10
+ stroke-linecap="round"
11
+ stroke-linejoin="round"
12
+ class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-up"
13
+ >
14
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
15
+ <path d="M12 5l0 14" />
16
+ <path d="M18 11l-6 -6" />
17
+ <path d="M6 11l6 -6" />
18
+ </svg>
@@ -0,0 +1,19 @@
1
+ <!-- @license @tabler/icons v3.50.0 - MIT -->
2
+ <svg
3
+ xmlns="http://www.w3.org/2000/svg"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ stroke-width="2"
10
+ stroke-linecap="round"
11
+ stroke-linejoin="round"
12
+ class="icon icon-tabler icons-tabler-outline icon-tabler-photo"
13
+ >
14
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
15
+ <path d="M15 8h.01" />
16
+ <path d="M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12" />
17
+ <path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5" />
18
+ <path d="M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3" />
19
+ </svg>
@@ -0,0 +1,16 @@
1
+ <!-- @license @tabler/icons v3.50.0 - MIT -->
2
+ <svg
3
+ xmlns="http://www.w3.org/2000/svg"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ stroke-width="2"
10
+ stroke-linecap="round"
11
+ stroke-linejoin="round"
12
+ class="icon icon-tabler icons-tabler-outline icon-tabler-star"
13
+ >
14
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
15
+ <path d="M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873l-6.158 -3.245" />
16
+ </svg>
data/registry/icons.yml CHANGED
@@ -9,8 +9,10 @@
9
9
  align-center: { tabler: align-center, phosphor: text-align-center }
10
10
  align-left: { tabler: align-left, phosphor: text-align-left }
11
11
  align-right: { tabler: align-right, phosphor: text-align-right }
12
+ arrow-down: { tabler: arrow-down, phosphor: arrow-down }
12
13
  arrow-left: { tabler: arrow-left, phosphor: arrow-left }
13
14
  arrow-right: { tabler: arrow-right, phosphor: arrow-right }
15
+ arrow-up: { tabler: arrow-up, phosphor: arrow-up }
14
16
  badge-check: { tabler: rosette-discount-check, phosphor: seal-check }
15
17
  bar-chart-3: { tabler: chart-bar, phosphor: chart-bar }
16
18
  bell: { tabler: bell, phosphor: bell }
@@ -43,6 +45,7 @@ graduation-cap: { tabler: school, phosphor: graduation-cap }
43
45
  grip-vertical: { tabler: grip-vertical, phosphor: dots-six-vertical }
44
46
  home: { tabler: home, phosphor: house }
45
47
  inbox: { tabler: inbox, phosphor: tray }
48
+ image: { tabler: photo, phosphor: image }
46
49
  info: { tabler: info-circle, phosphor: info }
47
50
  italic: { tabler: italic, phosphor: text-italic }
48
51
  keyboard: { tabler: keyboard, phosphor: keyboard }
@@ -76,6 +79,7 @@ settings: { tabler: settings, phosphor: gear }
76
79
  shield: { tabler: shield, phosphor: shield }
77
80
  shield-check: { tabler: shield-check, phosphor: shield-check }
78
81
  store: { tabler: building-store, phosphor: storefront }
82
+ star: { tabler: star, phosphor: star }
79
83
  sun: { tabler: sun, phosphor: sun }
80
84
  sun-moon: { tabler: sun-moon, phosphor: circle-half }
81
85
  trash-2: { tabler: trash, phosphor: trash }
@@ -0,0 +1,19 @@
1
+ <%# The negative margins cancel the card's inset and the gap above the footer, so they stay right at any spacing. %>
2
+ <%= render(UI::Card.new(spacing: 6, class: "max-w-md")) do |card| %>
3
+ <% card.with_header do |header| %>
4
+ <% header.with_title { "Terms of service" } %>
5
+ <% header.with_description { "Please read these before carrying on." } %>
6
+ <% end %>
7
+ <% card.with_content do %>
8
+ <div class="-mx-(--card-spacing) -mb-(--card-spacing) max-h-40 space-y-3 overflow-y-auto border-t px-(--card-spacing) py-3 text-muted-foreground" tabindex="0">
9
+ <p>You keep everything you upload. We only use it to run the service for you.</p>
10
+ <p>You can export your data at any time, and when you close your account we delete it within 30 days.</p>
11
+ <p>We'll tell you a month ahead if these terms change, and you can leave before they do.</p>
12
+ <p>Don't use the service to break the law or to get in the way of other people using it.</p>
13
+ </div>
14
+ <% end %>
15
+ <% card.with_footer(class: "justify-end gap-2") do %>
16
+ <%= render(UI::Button.new(variant: :outline, size: :sm)) { "Decline" } %>
17
+ <%= render(UI::Button.new(size: :sm)) { "Accept" } %>
18
+ <% end %>
19
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= render(UI::Card.new(class: "max-w-sm")) do |card| %>
2
+ <% card.with_image(src: UI::CardPreview.photo("#0f766e", "#1d4ed8"), alt: "Hills under a pale sun") %>
3
+ <% card.with_header do |header| %>
4
+ <% header.with_title { "Coastal walk, Saturday" } %>
5
+ <% header.with_description { "Twelve kilometres along the cliffs, with lunch at the harbour." } %>
6
+ <% header.with_action { render(UI::Badge.new(variant: :secondary, size: :sm)) { "Featured" } } %>
7
+ <% end %>
8
+ <% card.with_footer(class: "justify-between") do %>
9
+ <span class="text-muted-foreground">18 going</span>
10
+ <%= render(UI::Button.new(size: :sm)) { "Join" } %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="grid max-w-sm gap-4">
2
+ <%= render(UI::Card.new) do |card| %>
3
+ <% card.with_content do %>
4
+ <p class="text-muted-foreground">One part: the card's padding still applies.</p>
5
+ <% end %>
6
+ <% end %>
7
+ <%= render(UI::Card.new(class: "p-8 text-center")) do %>
8
+ <p class="text-muted-foreground">No parts, just a block: a bare surface, padded however you like.</p>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,18 @@
1
+ <%= render(UI::Card.new(size: :sm, class: "max-w-xs")) do |card| %>
2
+ <% card.with_header do |header| %>
3
+ <% header.with_title { "Table 12" } %>
4
+ <% header.with_description { "Opened 19:42 by Priya" } %>
5
+ <% header.with_action { render(UI::Badge.new(variant: :secondary, size: :sm)) { "Open" } } %>
6
+ <% end %>
7
+ <% card.with_content do %>
8
+ <dl class="grid grid-cols-[1fr_auto] gap-y-1 tabular-nums">
9
+ <dt>2 × Masala dosa</dt><dd>₹360.00</dd>
10
+ <dt>1 × Filter coffee</dt><dd>₹70.00</dd>
11
+ <dt class="text-muted-foreground">GST at 5%</dt><dd class="text-muted-foreground">₹21.50</dd>
12
+ </dl>
13
+ <% end %>
14
+ <% card.with_footer(class: "justify-between") do %>
15
+ <span class="font-semibold tabular-nums">₹451.50</span>
16
+ <%= render(UI::Button.new(size: :sm)) { "Charge" } %>
17
+ <% end %>
18
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <%= render(UI::Card.new(size: size, spacing: spacing, class: "max-w-sm")) do |card| %>
2
+ <% card.with_image(src: UI::CardPreview.photo("#7c3aed", "#db2777"), alt: "An abstract landscape") if show_image %>
3
+ <% card.with_header do |header| %>
4
+ <% header.with_title { title } %>
5
+ <% header.with_description { description } %>
6
+ <% header.with_action { render(UI::Badge.new(variant: :secondary, size: :sm)) { "New" } } if show_action %>
7
+ <% end %>
8
+ <% card.with_content do %>
9
+ <p class="text-muted-foreground">Pick a repository and we'll build it on every push.</p>
10
+ <% end %>
11
+ <% if show_footer %>
12
+ <% card.with_footer(class: "justify-end gap-2") do %>
13
+ <%= render(UI::Button.new(variant: :outline, size: :sm)) { "Cancel" } %>
14
+ <%= render(UI::Button.new(size: :sm)) { "Deploy" } %>
15
+ <% end %>
16
+ <% end %>
17
+ <% end %>
@@ -1,25 +1,16 @@
1
- <div class="max-w-sm">
2
- <%= render(UI::Card.new) do |card| %>
3
- <% card.with_header do |header| %>
4
- <% header.with_title { "Account Settings" } %>
5
- <% header.with_description { "Update your account preferences." } %>
6
- <% end %>
7
- <% card.with_content do %>
8
- <div class="space-y-4">
9
- <div class="space-y-2">
10
- <%= render(UI::Label.new(for: "name")) { "Display Name" } %>
11
- <%= render(UI::Input.new(id: "name", placeholder: "Enter your name")) %>
12
- </div>
13
- <div class="space-y-2">
14
- <%= render(UI::Label.new(for: "username")) { "Username" } %>
15
- <%= render(UI::Input.new(id: "username", placeholder: "@username")) %>
16
- </div>
17
- </div>
18
- <% end %>
19
- <% card.with_footer do %>
20
- <div class="flex gap-2">
21
- <%= render(UI::Button.new(variant: :primary, size: :sm)) { "Save Changes" } %>
22
- </div>
23
- <% end %>
1
+ <%= render(UI::Card.new(class: "max-w-md")) do |card| %>
2
+ <% card.with_header(class: "border-b") do |header| %>
3
+ <% header.with_title { "Profile" } %>
4
+ <% header.with_description { "This is how others see you." } %>
24
5
  <% end %>
25
- </div>
6
+ <% card.with_content do %>
7
+ <div class="grid gap-4">
8
+ <%= render(UI::Input.new(name: "display_name", label: "Display name", value: "Maya Okafor")) %>
9
+ <%= render(UI::Input.new(name: "username", label: "Username", value: "maya", hint: "Letters and numbers only.")) %>
10
+ </div>
11
+ <% end %>
12
+ <% card.with_footer(class: "justify-between") do %>
13
+ <span class="text-muted-foreground">Last saved 2 days ago</span>
14
+ <%= render(UI::Button.new(size: :sm)) { "Save" } %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <%= render(UI::Card.new(class: "max-w-sm")) do |card| %>
2
+ <% card.with_header do |header| %>
3
+ <% header.with_title { "Sign in to your workspace" } %>
4
+ <% header.with_description { "Use your email and password." } %>
5
+ <% header.with_action do %><%= render(UI::Button.new(variant: :link, size: :sm, class: "px-0")) { "Create account" } %><% end %>
6
+ <% end %>
7
+ <% card.with_content do %>
8
+ <div class="grid gap-4">
9
+ <%= render(UI::Input.new(type: :email, name: "email", label: "Email", placeholder: "you@example.com")) %>
10
+ <div class="grid gap-2">
11
+ <div class="flex items-center justify-between">
12
+ <%= render(UI::Label.new(for: "card-password")) { "Password" } %>
13
+ <a href="#" class="text-xs text-muted-foreground underline-offset-4 hover:underline">Forgot it?</a>
14
+ </div>
15
+ <%= render(UI::Input.new(type: :password, name: "password", id: "card-password")) %>
16
+ </div>
17
+ </div>
18
+ <% end %>
19
+ <% card.with_footer(class: "flex-col gap-2") do %>
20
+ <%= render(UI::Button.new(class: "w-full")) { "Sign in" } %>
21
+ <%= render(UI::Button.new(variant: :outline, class: "w-full")) { "Continue with single sign-on" } %>
22
+ <% end %>
23
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <%= render(UI::Card.new(size: :sm, class: "max-w-xs")) do |card| %>
2
+ <% card.with_header do |header| %>
3
+ <% header.with_title { "Weekly digest" } %>
4
+ <% header.with_description { "One email, every Monday morning." } %>
5
+ <% end %>
6
+ <% card.with_content do %>
7
+ <ul class="list-disc space-y-1 ps-4 text-muted-foreground">
8
+ <li>New comments on your projects</li>
9
+ <li>Tasks due this week</li>
10
+ <li>Who joined your team</li>
11
+ </ul>
12
+ <% end %>
13
+ <% card.with_footer(class: "gap-2") do %>
14
+ <%= render(UI::Button.new(size: :sm)) { "Turn on" } %>
15
+ <%= render(UI::Button.new(variant: :ghost, size: :sm)) { "See an example" } %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <div class="grid gap-4 sm:grid-cols-2">
2
+ <% { 4 => "16px, the default", 5 => "20px", 6 => "24px", 8 => "32px" }.each do |spacing, label| %>
3
+ <%= render(UI::Card.new(spacing: spacing)) do |card| %>
4
+ <% card.with_header do |header| %>
5
+ <% header.with_title { "spacing: #{spacing}" } %>
6
+ <% header.with_description { label } %>
7
+ <% end %>
8
+ <% card.with_content do %>
9
+ <p class="text-muted-foreground">The gaps between the parts and their inset change together.</p>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
13
+ </div>