keystone_ui 0.9.0 → 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 +4 -4
- data/app/assets/javascripts/keystone_ui/theme_toggle_controller.js +1 -2
- data/app/components/keystone/ui/checkbox_row_component.rb +3 -3
- data/app/components/keystone/ui/theme_toggle_component.rb +1 -1
- data/app/helpers/keystone_ui_helper.rb +8 -2
- data/lib/keystone_ui/configuration.rb +5 -1
- data/lib/keystone_ui/theme_choice.rb +8 -3
- data/lib/keystone_ui/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 002fac505b8658ac84ead1730a24efc02aaf7b1ada50fca184408e95ef166a77
|
|
4
|
+
data.tar.gz: 06b2c641c7af8d6b06999a3e5d7c65fcf40bf84e85a2a9bb80bd772b89439df4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c380a81162057aa27c4305e2530c493ba69ad42dd627a74bd01bc5eaabee67fa883558e4dad53a3d7a9f245bc5ad2fb0ebaf50ac6ef50c6ca8ab061b2c9eb49b
|
|
7
|
+
data.tar.gz: 22447d5c5e4c19057112ccbae4604ccb77b1a106915639221b8dacb3eb4b4ee9449fd2e69aecf74d5c8bc2f62a7c1c73c18ac0e9ae33cf4c4714c2d772161463
|
|
@@ -10,11 +10,10 @@ export default class extends Controller {
|
|
|
10
10
|
|
|
11
11
|
if (mode === "system") {
|
|
12
12
|
delete page.documentElement.dataset.theme
|
|
13
|
-
page.cookie = `${COOKIE}=; path=/; max-age=0; samesite=lax`
|
|
14
13
|
} else {
|
|
15
14
|
page.documentElement.dataset.theme = mode
|
|
16
|
-
page.cookie = `${COOKIE}=${mode}; path=/; max-age=${ONE_YEAR}; samesite=lax`
|
|
17
15
|
}
|
|
16
|
+
page.cookie = `${COOKIE}=${mode}; path=/; max-age=${ONE_YEAR}; samesite=lax`
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
#showPressed(mode) {
|
|
@@ -4,9 +4,9 @@ module Keystone
|
|
|
4
4
|
module Ui
|
|
5
5
|
class CheckboxRowComponent < ViewComponent::Base
|
|
6
6
|
ROW_CLASSES = "flex items-start gap-3 py-3 cursor-pointer"
|
|
7
|
-
INPUT_CLASSES = "mt-0.5 size-4 shrink-0 rounded border-surface-300 text-accent-600 focus:ring-accent-500"
|
|
8
|
-
LABEL_CLASSES = "block text-sm font-medium text-surface-900"
|
|
9
|
-
HINT_CLASSES = "block mt-0.5 text-sm text-surface-500"
|
|
7
|
+
INPUT_CLASSES = "mt-0.5 size-4 shrink-0 rounded border-surface-300 text-accent-600 checked:bg-accent-600 focus:ring-accent-500"
|
|
8
|
+
LABEL_CLASSES = "block text-sm font-medium text-surface-900 dark:text-surface-100"
|
|
9
|
+
HINT_CLASSES = "block mt-0.5 text-sm text-surface-500 dark:text-surface-400"
|
|
10
10
|
|
|
11
11
|
attr_reader :name, :value, :label, :hint
|
|
12
12
|
|
|
@@ -42,11 +42,11 @@ module KeystoneUiHelper
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def ui_theme_toggle
|
|
45
|
-
render Keystone::Ui::ThemeToggleComponent.new(current:
|
|
45
|
+
render Keystone::Ui::ThemeToggleComponent.new(current: keystone_theme_choice.mode)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def keystone_theme_attributes
|
|
49
|
-
|
|
49
|
+
keystone_theme_choice.html_attributes_markup.html_safe
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def ui_copy_button(**args)
|
|
@@ -204,4 +204,10 @@ module KeystoneUiHelper
|
|
|
204
204
|
def ui_disclosure(**args, &block)
|
|
205
205
|
render Keystone::Ui::DisclosureComponent.new(**args), &block
|
|
206
206
|
end
|
|
207
|
+
|
|
208
|
+
private
|
|
209
|
+
|
|
210
|
+
def keystone_theme_choice
|
|
211
|
+
KeystoneUi::ThemeChoice.new(cookies[KeystoneUi::ThemeChoice::COOKIE], supplied: KeystoneUi.configuration.supplied_theme_mode(self))
|
|
212
|
+
end
|
|
207
213
|
end
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
class Configuration
|
|
5
|
-
attr_accessor :accent, :surface
|
|
5
|
+
attr_accessor :accent, :surface, :theme_mode_supplier
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
8
|
@accent = :blue
|
|
9
9
|
@surface = :zinc
|
|
10
10
|
end
|
|
11
|
+
|
|
12
|
+
def supplied_theme_mode(view)
|
|
13
|
+
theme_mode_supplier&.call(view)
|
|
14
|
+
end
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
def self.configuration
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
class ThemeChoice
|
|
5
5
|
COOKIE = "keystone_theme"
|
|
6
|
-
MODES = %w[light dark].freeze
|
|
6
|
+
MODES = %w[light dark system].freeze
|
|
7
7
|
|
|
8
|
-
def initialize(mode)
|
|
8
|
+
def initialize(mode, supplied: nil)
|
|
9
9
|
@mode = mode
|
|
10
|
+
@supplied = supplied
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def html_attributes
|
|
13
|
-
|
|
14
|
+
mode == "system" ? {} : { "data-theme" => mode }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def mode
|
|
18
|
+
[ @mode, @supplied ].find { |candidate| MODES.include?(candidate) } || "light"
|
|
14
19
|
end
|
|
15
20
|
|
|
16
21
|
def html_attributes_markup
|
data/lib/keystone_ui/version.rb
CHANGED