keystone_ui 0.57.0 → 0.59.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 +4 -4
- data/app/components/keystone/ui/form_field_component.html.erb +2 -2
- data/app/components/keystone/ui/hero_component.rb +9 -3
- data/app/components/keystone/ui/mobile_action_component.rb +23 -0
- data/app/components/keystone/ui/mobile_header_component.rb +3 -3
- data/app/components/keystone/ui/navbar_component.html.erb +1 -1
- data/app/components/keystone/ui/navbar_component.rb +12 -4
- data/app/components/keystone/ui/page_header_component.html.erb +4 -0
- data/app/helpers/keystone_ui_helper.rb +4 -0
- data/lib/keystone_ui/safelist.rb +2 -1
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +37 -12
- data/the_local/interface.yml +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa286726a479f478774e33da15f8ec93767df8e20227a6280e3835e575740333
|
|
4
|
+
data.tar.gz: f1e259b398cca001b2174f90ebfe5ed0a9810ea7a9fc5f965d8c7c8abf55eb58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6ae5646277a7ddac4b926f709efaac74f4f3097c83cbb07ac8d24ac7a468e31086ba91327eef2da4b9fcaedfb384b8c64f4c22f663343294c3051481ec013e2
|
|
7
|
+
data.tar.gz: f27bd1e717b7e0604480eec0d8500f18dfcbcac1dbe4ca8489fe468c0b1e33c1cde6aa807b8fbd6a71513afe2c3cc4ec4d50e73da9135d02eea0623fa28b3199
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<% if checkbox? %>
|
|
9
9
|
<div class="<%= CHECKBOX_WRAPPER_CLASSES %>">
|
|
10
10
|
<input type="hidden" name="<%= @attribute %>" value="0">
|
|
11
|
-
<input type="checkbox" name="<%= @attribute %>" value="1" class="<%= CHECKBOX_CLASSES %>"<%= " checked" if @value.to_s == "1" %>>
|
|
12
|
-
<
|
|
11
|
+
<input type="checkbox" name="<%= @attribute %>" id="<%= field_id %>" value="1" class="<%= CHECKBOX_CLASSES %>"<%= " checked" if @value.to_s == "1" %>>
|
|
12
|
+
<label for="<%= field_id %>" class="text-sm text-gray-700 dark:text-gray-300"><%= label_text %></label>
|
|
13
13
|
</div>
|
|
14
14
|
<% elsif textarea? %>
|
|
15
15
|
<textarea name="<%= @attribute %>" id="<%= field_id %>" rows="3" class="<%= Keystone::Ui::TextareaComponent::BASE_CLASSES %>"<% if @placeholder %> placeholder="<%= @placeholder %>"<% end %>><%= @value %></textarea>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
module Keystone
|
|
4
4
|
module Ui
|
|
5
5
|
class HeroComponent < ViewComponent::Base
|
|
6
|
-
WRAPPER_CLASSES = "ks-hero relative
|
|
6
|
+
WRAPPER_CLASSES = "ks-hero relative"
|
|
7
|
+
SCREEN_HEIGHT_CLASSES = "min-h-screen"
|
|
7
8
|
INNER_CLASSES = "ks-hero-inner mx-auto max-w-6xl"
|
|
8
9
|
|
|
9
10
|
CONTENT_COLUMN_CLASSES = "ks-hero-content flex flex-col"
|
|
@@ -21,15 +22,20 @@ module Keystone
|
|
|
21
22
|
|
|
22
23
|
attr_reader :title, :subtitle, :badge
|
|
23
24
|
|
|
24
|
-
def initialize(title:, subtitle: nil, badge: nil, layout: :split)
|
|
25
|
+
def initialize(title:, subtitle: nil, badge: nil, layout: :split, height: :screen)
|
|
26
|
+
raise ArgumentError, "a hero's height is :screen or :content, got #{height.inspect}" unless %i[screen content].include?(height)
|
|
27
|
+
|
|
25
28
|
@title = title
|
|
26
29
|
@subtitle = subtitle
|
|
27
30
|
@badge = badge
|
|
28
31
|
@layout = layout
|
|
32
|
+
@height = height
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def classes
|
|
32
|
-
WRAPPER_CLASSES
|
|
36
|
+
return WRAPPER_CLASSES if @height == :content
|
|
37
|
+
|
|
38
|
+
"#{WRAPPER_CLASSES} #{SCREEN_HEIGHT_CLASSES}"
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
def inner_classes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Keystone
|
|
4
|
+
module Ui
|
|
5
|
+
class MobileActionComponent < ViewComponent::Base
|
|
6
|
+
PLUS_ICON = <<~SVG.freeze
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
|
|
8
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
|
9
|
+
</svg>
|
|
10
|
+
SVG
|
|
11
|
+
|
|
12
|
+
LINK_CLASSES = "ks-action-menu-button sm:hidden hotwire-native:hidden print:hidden"
|
|
13
|
+
|
|
14
|
+
def render?
|
|
15
|
+
content_for?(:mobile_action_url)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def call
|
|
19
|
+
link_to(PLUS_ICON.html_safe, content_for(:mobile_action_url), class: LINK_CLASSES, aria: { label: content_for(:mobile_action_label) })
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -15,10 +15,10 @@ module Keystone
|
|
|
15
15
|
</svg>
|
|
16
16
|
SVG
|
|
17
17
|
|
|
18
|
-
WRAPPER_CLASSES = "lg:hidden print:hidden"
|
|
18
|
+
WRAPPER_CLASSES = "flex items-center lg:hidden print:hidden"
|
|
19
19
|
BACK_LINK_CLASSES = "ks-mobile-header-back"
|
|
20
|
-
TITLE_CLASSES = "ks-mobile-header-title
|
|
21
|
-
SUBTITLE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate
|
|
20
|
+
TITLE_CLASSES = "ks-mobile-header-title flex-[1_1_6rem] min-w-0 self-center lg:hidden truncate"
|
|
21
|
+
SUBTITLE_CLASSES = "ks-mobile-header-subtitle block text-xs truncate"
|
|
22
22
|
DROPDOWN_CLASSES = "ks-action-menu hidden absolute right-0 z-50 w-48 origin-top-right"
|
|
23
23
|
|
|
24
24
|
# Renders the left-side and title of the mobile header.
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
module Keystone
|
|
4
4
|
module Ui
|
|
5
5
|
class NavbarComponent < ViewComponent::Base
|
|
6
|
-
NAV_BASE = "top-nav print:hidden"
|
|
6
|
+
NAV_BASE = "top-nav print:hidden max-lg:has-[.ks-mobile-header-title]:flex-wrap"
|
|
7
7
|
NAV_STICKY = "sticky top-0 z-40"
|
|
8
|
-
MOBILE_LEFT_CLASSES = "lg:hidden flex items-center"
|
|
8
|
+
MOBILE_LEFT_CLASSES = "lg:hidden flex items-center max-lg:has-[.ks-mobile-header-title]:contents"
|
|
9
9
|
LOGO_CLASSES = "logo"
|
|
10
|
+
LOGO_MOBILE_HIDDEN_CLASSES = "hidden lg:flex"
|
|
10
11
|
MOBILE_CENTER_CLASSES = "ks-navbar-title absolute left-1/2 -translate-x-1/2 lg:hidden truncate max-w-[60%]"
|
|
11
12
|
DESKTOP_LINKS_CLASSES = "nav-container hidden lg:flex"
|
|
12
|
-
MOBILE_RIGHT_CLASSES = "nav-user-controls ml-auto"
|
|
13
|
+
MOBILE_RIGHT_CLASSES = "nav-user-controls ml-auto max-lg:in-[.top-nav:has(.ks-mobile-header-title)]:flex-wrap max-lg:in-[.top-nav:has(.ks-mobile-header-title)]:justify-end"
|
|
13
14
|
|
|
14
15
|
renders_one :logo
|
|
15
16
|
renders_one :desktop_links
|
|
@@ -18,8 +19,9 @@ module Keystone
|
|
|
18
19
|
renders_one :mobile_center
|
|
19
20
|
renders_one :mobile_right
|
|
20
21
|
|
|
21
|
-
def initialize(sticky: true)
|
|
22
|
+
def initialize(sticky: true, hide_logo_on_mobile: false)
|
|
22
23
|
@sticky = sticky
|
|
24
|
+
@hide_logo_on_mobile = hide_logo_on_mobile
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def nav_classes
|
|
@@ -27,6 +29,12 @@ module Keystone
|
|
|
27
29
|
classes << NAV_STICKY if @sticky
|
|
28
30
|
classes.join(" ")
|
|
29
31
|
end
|
|
32
|
+
|
|
33
|
+
def logo_classes
|
|
34
|
+
classes = [ LOGO_CLASSES ]
|
|
35
|
+
classes << LOGO_MOBILE_HIDDEN_CLASSES if @hide_logo_on_mobile
|
|
36
|
+
classes.join(" ")
|
|
37
|
+
end
|
|
30
38
|
end
|
|
31
39
|
end
|
|
32
40
|
end
|
|
@@ -13,5 +13,9 @@
|
|
|
13
13
|
<div class="<%= ACTIONS_CLASSES %>">
|
|
14
14
|
<%= @action_block.call %>
|
|
15
15
|
</div>
|
|
16
|
+
<% elsif action_url %>
|
|
17
|
+
<div class="<%= ACTIONS_CLASSES %>">
|
|
18
|
+
<%= render Keystone::Ui::ButtonComponent.new(label: action_label, href: action_url) %>
|
|
19
|
+
</div>
|
|
16
20
|
<% end %>
|
|
17
21
|
</div>
|
|
@@ -141,6 +141,10 @@ module KeystoneUiHelper
|
|
|
141
141
|
render Keystone::Ui::MobileActionsComponent.new(**args), &block
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
def ui_mobile_action
|
|
145
|
+
render Keystone::Ui::MobileActionComponent.new
|
|
146
|
+
end
|
|
147
|
+
|
|
144
148
|
def ui_navbar(**args, &block)
|
|
145
149
|
render Keystone::Ui::NavbarComponent.new(**args), &block
|
|
146
150
|
end
|
data/lib/keystone_ui/safelist.rb
CHANGED
|
@@ -47,6 +47,7 @@ module Keystone
|
|
|
47
47
|
Keystone::Ui::SettingsLinkComponent,
|
|
48
48
|
Keystone::Ui::FormPageComponent,
|
|
49
49
|
Keystone::Ui::MobileActionsComponent,
|
|
50
|
+
Keystone::Ui::MobileActionComponent,
|
|
50
51
|
Keystone::Ui::MobileHeaderComponent,
|
|
51
52
|
Keystone::Ui::ShowPageComponent,
|
|
52
53
|
Keystone::Ui::OptionCardComponent,
|
|
@@ -76,7 +77,7 @@ module Keystone
|
|
|
76
77
|
].freeze
|
|
77
78
|
|
|
78
79
|
# Constants that hold non-CSS values (e.g. HTML input type maps)
|
|
79
|
-
SKIP_CONSTANTS = %i[TYPE_MAP ELLIPSIS_ICON BACK_ICON CARET_ICON CLOSE_ICON COPY_ICON SORT_ASC_ICON SORT_DESC_ICON SORT_NEUTRAL_ICON COLUMNS_ICON UPLOAD_ICON].freeze
|
|
80
|
+
SKIP_CONSTANTS = %i[TYPE_MAP ELLIPSIS_ICON BACK_ICON CARET_ICON CLOSE_ICON COPY_ICON SORT_ASC_ICON SORT_DESC_ICON SORT_NEUTRAL_ICON COLUMNS_ICON UPLOAD_ICON PLUS_ICON].freeze
|
|
80
81
|
|
|
81
82
|
# Classes used in Ruby methods or ERB templates, not in frozen constants.
|
|
82
83
|
# These cannot be auto-extracted and must be listed manually.
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -40,8 +40,9 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
40
40
|
- `ui_nav_dropdown` — a navbar dropdown menu.
|
|
41
41
|
- `ui_bottom_nav` — the mobile bottom tab bar.
|
|
42
42
|
- `ui_bottom_nav_item` — one tab in the bottom tab bar.
|
|
43
|
-
- `ui_mobile_header` — a mobile back arrow and
|
|
43
|
+
- `ui_mobile_header` — a mobile back arrow and a title beside it.
|
|
44
44
|
- `ui_mobile_actions` — an ellipsis menu of actions shown only below `lg:`.
|
|
45
|
+
- `ui_mobile_action` — a plus icon link to the action a screen's page header publishes, for the phone top bar.
|
|
45
46
|
- `ui_action_menu` — an ellipsis menu of actions shown at every screen size.
|
|
46
47
|
- `ui_action_menu_item` — one action in an action menu, as a link or a button sending a method.
|
|
47
48
|
- `ui_settings_link` — a full-width settings row with a chevron.
|
|
@@ -166,9 +167,11 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
166
167
|
directly, since those pass `trail: []`.
|
|
167
168
|
- `ui_page_header(title:, subtitle: nil, action_url: nil, action_label: "Add new", class: nil)`
|
|
168
169
|
takes a block yielding the header and is hidden below `sm:`. Call
|
|
169
|
-
`header.action { ... }` in the block to place a control on its right
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
`header.action { ... }` in the block to place a control on its right.
|
|
171
|
+
`action_url:` declares the screen's main action. It publishes that URL and
|
|
172
|
+
label for `ui_mobile_action` to pick up, and with no `action` block the
|
|
173
|
+
header draws them as a button. An `action` block is drawn alone when both
|
|
174
|
+
are given.
|
|
172
175
|
- `ui_breadcrumbs(trail:, current: nil)` renders `trail:` as links separated
|
|
173
176
|
by `›`, then `current:` unlinked and marked as the current page, shown
|
|
174
177
|
only from `lg:` up. On a form or detail screen pass `trail:` to the shell
|
|
@@ -241,6 +244,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
241
244
|
`mobile_center`, `mobile_right`. Desktop slots are hidden below `lg:` and
|
|
242
245
|
mobile slots from `lg:` up. `desktop_right` renders only when
|
|
243
246
|
`desktop_links` is also filled.
|
|
247
|
+
- `ui_navbar(hide_logo_on_mobile: true)` hides the `logo` slot below `lg:`
|
|
248
|
+
and keeps it from `lg:` up, for a page that shows its own title in
|
|
249
|
+
`ui_mobile_header`. It defaults to `false`, which keeps the logo at every
|
|
250
|
+
width.
|
|
244
251
|
- `ui_nav_item(label:, href:, active: false)` is one desktop link.
|
|
245
252
|
`ui_nav_dropdown(title:, area:, active: false)` takes a block holding the
|
|
246
253
|
menu links.
|
|
@@ -250,7 +257,21 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
250
257
|
Hotwire Native web view.
|
|
251
258
|
- `ui_mobile_header(title:, back_url:, subtitle: nil)` is hidden from `lg:`
|
|
252
259
|
up and goes in the navbar's `mobile_left` slot. `back_url:` must be
|
|
253
|
-
passed, and `nil` renders the title with no back arrow.
|
|
260
|
+
passed, and `nil` renders the title with no back arrow. The title and
|
|
261
|
+
subtitle sit between the arrow and the right-side controls, start at the
|
|
262
|
+
left, and end in an ellipsis when too long. In `ui_navbar`, controls that
|
|
263
|
+
leave less than 6rem for the title move to a second row under it. In a
|
|
264
|
+
hand-written top bar, make the header a direct child of the bar's flex
|
|
265
|
+
row, and add `max-lg:has-[.ks-mobile-header-title]:flex-wrap` to the bar if
|
|
266
|
+
its controls can fill its width.
|
|
267
|
+
- `ui_mobile_action` takes no keywords and no block, and goes in the top
|
|
268
|
+
bar's right side, such as the navbar's `mobile_right` slot. It draws a plus
|
|
269
|
+
icon linking to the `action_url:` a screen gives `ui_page_header`, named
|
|
270
|
+
with its `action_label:`, and draws nothing when the screen gives none. It
|
|
271
|
+
is hidden from `sm:` up, where the page header shows the action, and inside
|
|
272
|
+
a Hotwire Native web view, so give native users another way to reach the
|
|
273
|
+
action, such as `ui_mobile_actions`. The layout must also write the
|
|
274
|
+
`hotwire-native` class on `<html>` and declare that Tailwind variant.
|
|
254
275
|
- `ui_settings_link(label:, href:)` renders one settings row.
|
|
255
276
|
- `ui_theme_toggle` takes no keywords and no block. Its buttons switch the
|
|
256
277
|
theme at once and store the choice in the `keystone_theme` cookie for a
|
|
@@ -290,9 +311,10 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
290
311
|
`:email` `:password` `:date` `:datetime` and is ignored by the other types. Its list
|
|
291
312
|
is identified by `attribute:`, so two fields with suggestions on one
|
|
292
313
|
screen need different `attribute:` values.
|
|
293
|
-
- The field's label is tied to its input, textarea
|
|
294
|
-
`id` built from `attribute:`, so tapping the label focuses the
|
|
295
|
-
|
|
314
|
+
- The field's label is tied to its input, textarea, select or checkbox
|
|
315
|
+
through an `id` built from `attribute:`, so tapping the label focuses the
|
|
316
|
+
input, or ticks and unticks the checkbox, and a screen reader reads the
|
|
317
|
+
label. `"player[email]"` gets the id
|
|
296
318
|
`player-email`, so two fields on one screen need different `attribute:`
|
|
297
319
|
values.
|
|
298
320
|
- `required: true` marks the label with an asterisk and, on a `:text`
|
|
@@ -590,10 +612,13 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
590
612
|
|
|
591
613
|
13. Build marketing sections.
|
|
592
614
|
|
|
593
|
-
- `ui_hero(title:, subtitle: nil, badge: nil, layout: :split
|
|
594
|
-
block holding the call-to-action buttons and
|
|
595
|
-
its `aside` slot can hold an image or panel.
|
|
596
|
-
`:centered`.
|
|
615
|
+
- `ui_hero(title:, subtitle: nil, badge: nil, layout: :split,
|
|
616
|
+
height: :screen)` takes a block holding the call-to-action buttons and
|
|
617
|
+
yields the component, so its `aside` slot can hold an image or panel.
|
|
618
|
+
`layout:` is `:split` or `:centered`. `height: :screen` keeps the hero at
|
|
619
|
+
least the full screen height, and `height: :content` draws it only as
|
|
620
|
+
tall as its content and its padding, for a page with more sections
|
|
621
|
+
after it.
|
|
597
622
|
- `ui_cta_banner(title:, subtitle: nil)` takes a block holding the
|
|
598
623
|
buttons.
|
|
599
624
|
- `ui_feature_grid(title:, features:, subtitle: nil)` — `features:` is
|
data/the_local/interface.yml
CHANGED
|
@@ -37,6 +37,7 @@ develop:
|
|
|
37
37
|
- ui_breadcrumbs
|
|
38
38
|
- ui_mobile_header
|
|
39
39
|
- ui_mobile_actions
|
|
40
|
+
- ui_mobile_action
|
|
40
41
|
- ui_action_menu
|
|
41
42
|
- ui_action_menu_item
|
|
42
43
|
- ui_navbar
|
|
@@ -133,6 +134,7 @@ sources:
|
|
|
133
134
|
- app/components/keystone/ui/input_component.rb
|
|
134
135
|
- app/components/keystone/ui/line_chart_component.rb
|
|
135
136
|
- app/components/keystone/ui/mobile_actions_component.rb
|
|
137
|
+
- app/components/keystone/ui/mobile_action_component.rb
|
|
136
138
|
- app/components/keystone/ui/action_menu_component.rb
|
|
137
139
|
- app/components/keystone/ui/action_menu_item_component.rb
|
|
138
140
|
- app/components/keystone/ui/mobile_header_component.rb
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: keystone_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.59.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -153,6 +153,7 @@ files:
|
|
|
153
153
|
- app/components/keystone/ui/input_component.rb
|
|
154
154
|
- app/components/keystone/ui/line_chart_component.html.erb
|
|
155
155
|
- app/components/keystone/ui/line_chart_component.rb
|
|
156
|
+
- app/components/keystone/ui/mobile_action_component.rb
|
|
156
157
|
- app/components/keystone/ui/mobile_actions_component.html.erb
|
|
157
158
|
- app/components/keystone/ui/mobile_actions_component.rb
|
|
158
159
|
- app/components/keystone/ui/mobile_header_component.html.erb
|