keystone_ui 0.13.0 → 0.15.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: 903dfcff87cb63fce06692a39fb26b73af673f562f28f3b3ebf72b13b5280642
4
- data.tar.gz: 7db5a26e387cc0c2b11a311c70e967ec977f5b1636c6d38bf8a42b28d5ffbd9a
3
+ metadata.gz: cdb61774853355f3b66ae9c1a7d6f4930005216827486777c19b582b3ac775f2
4
+ data.tar.gz: a815979ea629c273e43b8b7d39a20a1310908dedee967aec21b326e027784333
5
5
  SHA512:
6
- metadata.gz: 574997b044dfcbb23b6aad3e74065b041d549d1be5a8629f5c08f792720f1fda5d988340516caa581f80c1455fcc3a32080174b8056f06a41c4fa58423236cbb
7
- data.tar.gz: 30a7877baf982039cff72b9c8ad0dc879a8fdbc8362d8ec15cec9b7b48964aa8dc1786494b25e3c131e1c28a2c000054c33998011ea41b111da749e1863518f3
6
+ metadata.gz: '0975326ab4b00a0f6ce7f28ae8642e2bee4704e13509046a1c2ad820e50880ace96f0b0d0e66dfd95e29b3d7d56cff68f7e4aef1264c507b2480eb72d3b14c5d'
7
+ data.tar.gz: e06fedfeebf535bf2c17ae2dc30938878a05f3cfb918f29df694886538f2c88f97d83d5eb51e9210e4dcdc8bfdbf3b16c8daef006d0bc51f6f93815752c4268c
@@ -15,7 +15,7 @@
15
15
  <textarea name="<%= @attribute %>" rows="3" class="<%= Keystone::Ui::TextareaComponent::BASE_CLASSES %>"<% if @placeholder %> placeholder="<%= @placeholder %>"<% end %>><%= @value %></textarea>
16
16
  <% elsif select? %>
17
17
  <select name="<%= @attribute %>" class="<%= Keystone::Ui::SelectComponent::BASE_CLASSES %>">
18
- <% unless required? %><option value=""></option><% end %>
18
+ <% unless required? %><option value=""><%= blank_option_text %></option><% end %>
19
19
  <% select_options.each do |label, value| %>
20
20
  <option value="<%= value %>" <%= "selected" if @value.to_s == value.to_s %>><%= label %></option>
21
21
  <% end %>
@@ -11,7 +11,7 @@ module Keystone
11
11
  CHECKBOX_CLASSES = "ks-checkbox"
12
12
  CHECKBOX_WRAPPER_CLASSES = "flex items-center gap-2"
13
13
 
14
- def initialize(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [])
14
+ def initialize(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [], include_blank: nil)
15
15
  @attribute = attribute
16
16
  @label = label
17
17
  @type = type
@@ -24,6 +24,7 @@ module Keystone
24
24
  @value = value
25
25
  @options = options
26
26
  @errors = Array(errors)
27
+ @include_blank = include_blank.to_s
27
28
  end
28
29
 
29
30
  def label_text
@@ -66,6 +67,10 @@ module Keystone
66
67
  @options
67
68
  end
68
69
 
70
+ def blank_option_text
71
+ @include_blank
72
+ end
73
+
69
74
  def input_options
70
75
  options = { name: @attribute.to_s, class: Keystone::Ui::InputComponent::BASE_CLASSES }
71
76
  unless textarea?
@@ -3,7 +3,7 @@
3
3
  module KeystoneUi
4
4
  class ThemeChoice
5
5
  COOKIE = "keystone_theme"
6
- MODES = %w[light dark system].freeze
6
+ MODES = %w[light dark system custom].freeze
7
7
 
8
8
  def initialize(mode, supplied: nil)
9
9
  @mode = mode
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.13.0"
4
+ VERSION = "0.15.0"
5
5
  end
@@ -96,7 +96,7 @@ outer element. See Conventions before using it.
96
96
  The `<form>` wrapper. `method:` may be `:patch`/`:put`/`:delete` and is
97
97
  translated for Rails. Set `multipart: true` when the form contains a file
98
98
  upload.
99
- - `ui_form_field(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [])`
99
+ - `ui_form_field(attribute:, label: nil, type: :text, required: false, hint: nil, placeholder: nil, min: nil, max: nil, step: nil, value: nil, options: [], errors: [], include_blank: nil)`
100
100
  — a labeled field with hint and error text. This is the default way to render
101
101
  an input. `type:` `:text` `:number` `:email` `:password` `:date` `:textarea`
102
102
  `:checkbox` `:select`. `attribute:` is used verbatim as the input's `name`, so
@@ -104,7 +104,9 @@ outer element. See Conventions before using it.
104
104
  pass `label:` whenever the attribute is a nested name. `label:` defaults to the
105
105
  attribute with underscores turned to spaces and the first letter capitalized.
106
106
  `options:` is for `:select` and takes `[[label, value], ...]`; `value:` picks
107
- the selected option, and a non-required select gets a leading blank option. A
107
+ the selected option, and a non-required select gets a leading empty option,
108
+ worded by `include_blank:` (for example `"Not set yet"`) or left blank without
109
+ it. Never add your own empty choice to `options:` as well. A
108
110
  `:checkbox` renders its label beside the box, submits `"0"` when unchecked and
109
111
  `"1"` when checked, and pre-checks when `value:` is `"1"`. `errors:` is an
110
112
  array of message strings.
@@ -70,10 +70,12 @@ holds the catalog.
70
70
  Tailwind's stock `gray-*` and `zinc-*` neutrals, or fixed status colors such
71
71
  as green and amber, directly. Changing the defaults belongs to the install
72
72
  local.
73
- - **Light, dark and system themes.** Every component has dark-mode styling. The
74
- theme is chosen in this order: the user's choice stored in a cookie, then a
75
- mode another gem supplies, then light. System leaves the page to follow the
76
- operating system.
73
+ - **Light, dark, system and custom themes.** Every component has dark-mode
74
+ styling. The theme is chosen in this order: the user's choice stored in a
75
+ cookie, then a mode another gem supplies, then light. System leaves the page
76
+ to follow the operating system. Custom marks the page for a palette another
77
+ gem defines. The theme toggle does not offer it, so a page reaches it when
78
+ another gem supplies it.
77
79
  - **Tailwind classes are static strings.** Class names are never interpolated,
78
80
  so Tailwind's scanner can find them. Widths and heights that depend on data,
79
81
  such as a progress bar or a bucket's fill, are set with an inline style
@@ -20,7 +20,8 @@ built on ViewComponent; hook it in before building any screen with those helpers
20
20
  to the layout's `<html>` tag. Safe to re-run.
21
21
  - `KeystoneUi.configure` — a block yielding the configuration: `accent` and
22
22
  `surface` (palette names, `:blue` and `:zinc` unless set),
23
- `theme_mode_supplier` (a callable that supplies a light, dark or system mode),
23
+ `theme_mode_supplier` (a callable that supplies a light, dark, system or
24
+ custom mode),
24
25
  and the `tailwind_imports` and `tailwind_sources` lists (extra CSS files and
25
26
  scan paths added to the Tailwind build).
26
27
 
@@ -61,7 +62,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
61
62
  `registerControllers(application)`.
62
63
  - `app/views/layouts/application.html.erb` — adds
63
64
  `<%= keystone_theme_attributes %>` inside the `<html` tag, which writes the
64
- light or dark mode onto the page.
65
+ light, dark or custom mode onto the page.
65
66
 
66
67
  Read its output for two warnings:
67
68
 
@@ -139,10 +140,14 @@ built on ViewComponent; hook it in before building any screen with those helpers
139
140
  reads the palette choice. Keystone UI stores the names and changes no color
140
141
  from them, because colors come from the CSS custom properties in step 6.
141
142
  - `theme_mode_supplier` — a callable that receives the view and returns
142
- `"light"`, `"dark"` or `"system"`. It supplies the mode when the user has
143
- not picked one with the theme toggle, since the `keystone_theme` cookie that
144
- the toggle writes takes precedence. Any other return value, or no supplier,
145
- falls back to light.
143
+ `"light"`, `"dark"`, `"system"`, `"custom"` or `nil`. It supplies the mode
144
+ when the user has not picked one with the theme toggle, since the
145
+ `keystone_theme` cookie that the toggle writes takes precedence. Any other
146
+ return value, or no supplier, falls back to light.
147
+ - A supplied `"custom"` marks the layout's `<html>` tag
148
+ `data-theme="custom"`. The theme toggle does not offer custom, so only a
149
+ supplier sets it. Ask the developer which gem or code supplies custom and
150
+ its colors before returning it.
146
151
  - `tailwind_imports` and `tailwind_sources` — lists to append to, never
147
152
  assign. Each import becomes an `@import` line and each source becomes an
148
153
  `@source` line in `keystone_source.css` on the next boot. They are for
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.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.0
18
+ version: 0.3.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.0
25
+ version: 0.3.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: view_component
28
28
  requirement: !ruby/object:Gem::Requirement