keystone_ui 0.9.1 → 0.11.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/assets/tailwind/keystone_ui_engine/{engine.css → grid_safelist.css} +0 -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 +8 -1
- data/lib/keystone_ui/engine.rb +1 -1
- data/lib/keystone_ui/source_css.rb +8 -7
- data/lib/keystone_ui/theme_choice.rb +8 -3
- data/lib/keystone_ui/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 779c5876ab225f8e81effa23a748805e832b8521081de86b1a64759f81876190
|
|
4
|
+
data.tar.gz: 62adc4c320cef40f09b1c0ca677e45a03cf9af3e46e7ac87e7854d9cea4b917b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e2111385ae219156f7ddebc22ffbc064fe804a36ba7699b1828e368fc75b19e133fdedd3c95cab3f270262d7d7f86744972c66b6e7433bf19505a9a1365e6fe
|
|
7
|
+
data.tar.gz: ab7ea01f423446831a0e88a0b51185741d6099dbb49a655d37f955aa3bc0201b82c2d878e12ed1fb2cfb37948e035c399d288f5e49b4c16e102a7b4ee8943648
|
|
@@ -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) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* Keystone UI components — tells Tailwind to scan for classes in component files */
|
|
2
|
-
@source "../../components/**/*.{erb,rb}";
|
|
3
|
-
|
|
4
1
|
/* Safelist: grid-cols classes built from static constants in GridComponent.
|
|
5
2
|
Belt-and-suspenders — ensures these classes survive JIT purging even if
|
|
6
3
|
the scanner misses the Ruby hash literals. */
|
|
@@ -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,11 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
class Configuration
|
|
5
|
-
attr_accessor :accent, :surface
|
|
5
|
+
attr_accessor :accent, :surface, :theme_mode_supplier
|
|
6
|
+
attr_reader :tailwind_imports, :tailwind_sources
|
|
6
7
|
|
|
7
8
|
def initialize
|
|
8
9
|
@accent = :blue
|
|
9
10
|
@surface = :zinc
|
|
11
|
+
@tailwind_imports = []
|
|
12
|
+
@tailwind_sources = []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def supplied_theme_mode(view)
|
|
16
|
+
theme_mode_supplier&.call(view)
|
|
10
17
|
end
|
|
11
18
|
end
|
|
12
19
|
|
data/lib/keystone_ui/engine.rb
CHANGED
|
@@ -29,7 +29,7 @@ module KeystoneUi
|
|
|
29
29
|
keystone_import = '@import "./keystone_source.css";'
|
|
30
30
|
next unless css_path.read.include?(keystone_import)
|
|
31
31
|
|
|
32
|
-
tailwind_dir.join("keystone_source.css").write(KeystoneUi::SourceCss.new(root).to_s)
|
|
32
|
+
tailwind_dir.join("keystone_source.css").write(KeystoneUi::SourceCss.new(root, imports: KeystoneUi.configuration.tailwind_imports, sources: KeystoneUi.configuration.tailwind_sources).to_s)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -5,8 +5,10 @@ require "keystone_ui/styles"
|
|
|
5
5
|
|
|
6
6
|
module KeystoneUi
|
|
7
7
|
class SourceCss
|
|
8
|
-
def initialize(root)
|
|
8
|
+
def initialize(root, imports: [], sources: [])
|
|
9
9
|
@root = Pathname.new(root)
|
|
10
|
+
@imports = imports
|
|
11
|
+
@sources = sources
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def to_s
|
|
@@ -15,16 +17,15 @@ module KeystoneUi
|
|
|
15
17
|
|
|
16
18
|
private
|
|
17
19
|
|
|
18
|
-
def styles_entry
|
|
19
|
-
KeystoneUi::Styles::Engine.root.join("app/assets/tailwind/keystone_ui_styles/engine.css")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
20
|
def lines
|
|
23
21
|
[
|
|
24
|
-
%(@import "#{
|
|
22
|
+
%(@import "#{KeystoneUi::Styles.tailwind_file}";),
|
|
25
23
|
%(@source "#{@root}/app/components/**/*.{erb,rb}";),
|
|
26
24
|
%(@import "#{@root}/app/assets/tailwind/keystone_ui_engine/nav.css";),
|
|
27
|
-
%(@import "#{@root}/app/assets/tailwind/keystone_ui_engine/color_picker.css";)
|
|
25
|
+
%(@import "#{@root}/app/assets/tailwind/keystone_ui_engine/color_picker.css";),
|
|
26
|
+
%(@import "#{@root}/app/assets/tailwind/keystone_ui_engine/grid_safelist.css";),
|
|
27
|
+
*@imports.map { |import| %(@import "#{import}";) },
|
|
28
|
+
*@sources.map { |source| %(@source "#{source}";) }
|
|
28
29
|
]
|
|
29
30
|
end
|
|
30
31
|
end
|
|
@@ -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
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.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.1.
|
|
19
|
+
version: 0.1.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.1.
|
|
26
|
+
version: 0.1.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: view_component
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -70,7 +70,7 @@ files:
|
|
|
70
70
|
- app/assets/javascripts/keystone_ui/tab_switcher_controller.js
|
|
71
71
|
- app/assets/javascripts/keystone_ui/theme_toggle_controller.js
|
|
72
72
|
- app/assets/tailwind/keystone_ui_engine/color_picker.css
|
|
73
|
-
- app/assets/tailwind/keystone_ui_engine/
|
|
73
|
+
- app/assets/tailwind/keystone_ui_engine/grid_safelist.css
|
|
74
74
|
- app/assets/tailwind/keystone_ui_engine/nav.css
|
|
75
75
|
- app/components/keystone/ui/accordion_component.html.erb
|
|
76
76
|
- app/components/keystone/ui/accordion_component.rb
|