baldur 0.1.7 → 0.2.3
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/Gemfile +1 -1
- data/README.md +78 -376
- data/TODO.md +53 -5
- data/app/assets/javascripts/baldur/controllers/confirmation_controller.js +23 -0
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
- data/app/assets/stylesheets/baldur/application/components/confirmation.css +11 -0
- data/app/assets/stylesheets/baldur/application/components/sidebar.css +234 -0
- data/app/assets/stylesheets/baldur.css +1 -0
- data/app/assets/tailwind/baldur/engine.css +2 -2
- data/app/helpers/baldur/marketing_helper.rb +71 -69
- data/app/helpers/baldur/optional/auth_page_helper.rb +4 -2
- data/app/helpers/baldur/optional/google_auth_helper.rb +2 -2
- data/app/helpers/baldur/optional/panel_secondary_helper.rb +3 -2
- data/app/helpers/baldur/ui_helper.rb +159 -121
- data/app/helpers/baldur/ui_helper_feedback.rb +38 -36
- data/app/helpers/baldur/ui_helper_forms.rb +81 -76
- data/app/helpers/baldur/ui_helper_sidebar.rb +6 -5
- data/app/helpers/baldur/ui_helper_unavailable.rb +17 -15
- data/app/views/baldur/components/_confirmation_modal.html.erb +99 -0
- data/app/views/baldur/components/_modal_host.html.erb +10 -0
- data/app/views/baldur/components/_sidebar.html.erb +30 -30
- data/app/views/baldur/components/_theme_toggle.html.erb +23 -0
- data/app/views/baldur/optional/_auth_page.html.erb +6 -0
- data/baldur.gemspec +23 -23
- data/config/importmap.rb +2 -2
- data/lib/baldur/configuration.rb +6 -6
- data/lib/baldur/engine.rb +3 -3
- data/lib/baldur/version.rb +1 -1
- data/lib/baldur.rb +5 -5
- data/lib/generators/baldur/install/install_generator.rb +20 -19
- data/lib/generators/baldur/install/templates/baldur_initializer.rb +7 -7
- data/lib/generators/baldur/install/templates/theme.css +32 -6
- data/lib/generators/baldur/install_google_auth/install_google_auth_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_right/install_panel_right_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb +3 -3
- data/script/verify_host_install +59 -31
- data/test/confirmation_modal_helper_test.rb +241 -0
- data/test/csp_rendering_test.rb +21 -21
- data/test/engine_css_test.rb +36 -0
- data/test/fixtures/shared/_brand_lockup.html.erb +1 -0
- data/test/gemspec_test.rb +7 -5
- data/test/install_generator_test.rb +25 -21
- data/test/install_panel_secondary_generator_test.rb +12 -9
- data/test/marketing_helper_test.rb +7 -7
- data/test/run_all.rb +1 -1
- data/test/sidebar_helper_test.rb +16 -16
- data/test/test_helper.rb +14 -14
- data/test/theme_toggle_helper_test.rb +119 -0
- data/test/tmp/install_generator/app/assets/stylesheets/theme.css +32 -6
- data/test/tmp/install_generator/app/javascript/controllers/confirmation_controller.js +1 -0
- data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
- metadata +20 -8
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require_relative '../app/helpers/baldur/optional/auth_page_helper'
|
|
3
|
+
|
|
4
|
+
require 'action_controller'
|
|
5
|
+
|
|
6
|
+
class BaldurThemeToggleHelperTest < Minitest::Test
|
|
7
|
+
class TestController < ActionController::Base
|
|
8
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
9
|
+
helper Baldur::UiHelper
|
|
10
|
+
helper Baldur::RenderHelper
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_ui_theme_toggle_renders_switch_markup
|
|
14
|
+
html = TestController.render(
|
|
15
|
+
inline: '<%= ui_theme_toggle %>',
|
|
16
|
+
formats: [:html]
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
assert_includes html, 'class="switch theme-toggle"'
|
|
20
|
+
assert_includes html, 'data-theme-target="toggle"'
|
|
21
|
+
assert_includes html, 'data-theme-toggle'
|
|
22
|
+
assert_includes html, 'aria-label="Toggle theme"'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_ui_theme_toggle_renders_compact_button
|
|
26
|
+
html = TestController.render(
|
|
27
|
+
inline: '<%= ui_theme_toggle %>',
|
|
28
|
+
formats: [:html]
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
assert_includes html, 'data-action="click->theme#toggle"'
|
|
32
|
+
assert_includes html, 'theme-toggle__compact'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_ui_theme_toggle_custom_aria_label
|
|
36
|
+
html = TestController.render(
|
|
37
|
+
inline: '<%= ui_theme_toggle(aria_label: "Switch appearance") %>',
|
|
38
|
+
formats: [:html]
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
assert_includes html, 'aria-label="Switch appearance"'
|
|
42
|
+
refute_includes html, 'aria-label="Toggle theme"'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_ui_theme_toggle_custom_classes
|
|
46
|
+
html = TestController.render(
|
|
47
|
+
inline: '<%= ui_theme_toggle(classes: "my-extra") %>',
|
|
48
|
+
formats: [:html]
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
assert_includes html, 'my-extra'
|
|
52
|
+
assert_includes html, 'switch theme-toggle'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_ui_theme_toggle_renders_sun_and_moon_icons
|
|
56
|
+
html = TestController.render(
|
|
57
|
+
inline: '<%= ui_theme_toggle %>',
|
|
58
|
+
formats: [:html]
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
assert_includes html, 'switch__icon--sun'
|
|
62
|
+
assert_includes html, 'switch__icon--moon'
|
|
63
|
+
assert_includes html, 'theme-toggle__compact-icon--sun'
|
|
64
|
+
assert_includes html, 'theme-toggle__compact-icon--moon'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
class BaldurAuthPageTopRailTest < Minitest::Test
|
|
69
|
+
FIXTURE_VIEWS = File.expand_path('fixtures', __dir__)
|
|
70
|
+
|
|
71
|
+
class TestController < ActionController::Base
|
|
72
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
73
|
+
append_view_path FIXTURE_VIEWS
|
|
74
|
+
helper Baldur::UiHelper
|
|
75
|
+
helper Baldur::Optional::AuthPageHelper
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_auth_page_without_top_rail_omits_element
|
|
79
|
+
html = TestController.render(
|
|
80
|
+
inline: <<~ERB,
|
|
81
|
+
<%= ui_auth_page(title: "Sign in", description: nil) do %>
|
|
82
|
+
<p>Form here</p>
|
|
83
|
+
<% end %>
|
|
84
|
+
ERB
|
|
85
|
+
formats: [:html]
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
refute_includes html, 'auth-page__top-rail'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_auth_page_with_top_rail_renders_slot
|
|
92
|
+
html = TestController.render(
|
|
93
|
+
inline: <<~ERB,
|
|
94
|
+
<%= ui_auth_page(title: "Sign in", description: nil, top_rail: "<span>Version 1.0</span>".html_safe) do %>
|
|
95
|
+
<p>Form here</p>
|
|
96
|
+
<% end %>
|
|
97
|
+
ERB
|
|
98
|
+
formats: [:html]
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
assert_includes html, 'auth-page__top-rail'
|
|
102
|
+
assert_includes html, 'Version 1.0'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_auth_page_top_rail_with_theme_toggle
|
|
106
|
+
html = TestController.render(
|
|
107
|
+
inline: <<~ERB,
|
|
108
|
+
<%= ui_auth_page(title: "Sign in", description: nil, top_rail: ui_theme_toggle) do %>
|
|
109
|
+
<p>Form here</p>
|
|
110
|
+
<% end %>
|
|
111
|
+
ERB
|
|
112
|
+
formats: [:html]
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
assert_includes html, 'auth-page__top-rail'
|
|
116
|
+
assert_includes html, 'data-theme-target="toggle"'
|
|
117
|
+
assert_includes html, 'data-action="click->theme#toggle"'
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Host theme overrides.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* ── Brand inputs ─────────────────────────────────────────
|
|
5
|
+
* Override the four base palette tokens to rebrand. Baldur
|
|
6
|
+
* derives all semantic and role tokens from these inputs;
|
|
7
|
+
* do NOT override the semantic outputs directly.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* --_primary-base primary actions / CTA
|
|
10
|
+
* --_secondary-base sidebar, nav, subdued surfaces
|
|
11
|
+
* --_accent-base highlights, badges, tags
|
|
12
|
+
* --_neutral-base surfaces, text, borders
|
|
13
|
+
*
|
|
14
|
+
* Values are oklch(). To pick a color, convert to oklch and
|
|
15
|
+
* paste the three channels (L C H) — no parens needed:
|
|
16
|
+
*
|
|
17
|
+
* --_primary-base: oklch(0.68 0.16 27);
|
|
18
|
+
*
|
|
19
|
+
* ── Semantic tokens ──────────────────────────────────────
|
|
20
|
+
* Baldur owns all --color-* semantic tokens (e.g. --color-primary,
|
|
21
|
+
* --color-surface, --color-on-surface). They adapt between
|
|
22
|
+
* light/dark automatically. Do not override them here.
|
|
23
|
+
*
|
|
24
|
+
* ── Font mapping ─────────────────────────────────────────
|
|
25
|
+
* Load web fonts in fonts.css, then map the loaded families
|
|
26
|
+
* to the tokens below. Baldur uses --font-body as the default
|
|
27
|
+
* family for body, heading, and UI text unless overridden.
|
|
28
|
+
*
|
|
29
|
+
* --font-body body copy
|
|
30
|
+
* --font-heading headings (falls back to --font-body)
|
|
31
|
+
* --font-ui buttons, labels, form text (falls back to --font-body)
|
|
32
|
+
*
|
|
33
|
+
* ── Example ──────────────────────────────────────────────
|
|
10
34
|
* :root {
|
|
11
35
|
* --_primary-base: oklch(0.68 0.16 27);
|
|
12
36
|
* --_secondary-base: oklch(0.30 0.04 195);
|
|
@@ -15,6 +39,8 @@
|
|
|
15
39
|
* --font-body: "Geist", "Inter", "Segoe UI", "Helvetica Neue", Arial, system-ui, -apple-system, sans-serif;
|
|
16
40
|
* --font-heading: var(--font-body);
|
|
17
41
|
* --font-ui: var(--font-body);
|
|
42
|
+
* --font-family: var(--font-body);
|
|
43
|
+
* --font-sans: var(--font-body);
|
|
18
44
|
* }
|
|
19
45
|
*/
|
|
20
46
|
|
|
@@ -24,4 +50,4 @@
|
|
|
24
50
|
--font-ui: var(--font-body);
|
|
25
51
|
--font-family: var(--font-body);
|
|
26
52
|
--font-sans: var(--font-body);
|
|
27
|
-
}
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "baldur/controllers/confirmation_controller"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'baldur'
|
|
2
2
|
|
|
3
3
|
Baldur.configure do |config|
|
|
4
|
-
config.unavailable_fallback_message =
|
|
5
|
-
config.theme_storage_key =
|
|
4
|
+
config.unavailable_fallback_message = 'Missing metric or raw data required to compute this value.'
|
|
5
|
+
config.theme_storage_key = 'baldur.theme'
|
|
6
6
|
config.marketing_brand = {
|
|
7
|
-
name:
|
|
8
|
-
wordmark:
|
|
9
|
-
logo_src:
|
|
10
|
-
logo_alt:
|
|
7
|
+
name: 'Your Brand',
|
|
8
|
+
wordmark: 'Your Brand',
|
|
9
|
+
logo_src: '/icon.png',
|
|
10
|
+
logo_alt: 'Your Brand logo'
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
# Supply host-specific lookups when using unavailable dependency helpers.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: baldur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Varun Murkar
|
|
@@ -43,30 +43,31 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
46
|
+
version: 7.0.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 7.0.0
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: tailwindcss-rails
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 4.
|
|
60
|
+
version: 4.3.0
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 4.
|
|
68
|
-
description: Baldur
|
|
69
|
-
Stimulus
|
|
67
|
+
version: 4.3.0
|
|
68
|
+
description: Baldur helps Rails teams ship polished UI faster with install generators,
|
|
69
|
+
reusable ui_* helpers, Tailwind components, and Stimulus wiring for apps using Propshaft,
|
|
70
|
+
importmap-rails, stimulus-rails, and tailwindcss-rails.
|
|
70
71
|
executables: []
|
|
71
72
|
extensions: []
|
|
72
73
|
extra_rdoc_files: []
|
|
@@ -78,6 +79,7 @@ files:
|
|
|
78
79
|
- TODO.md
|
|
79
80
|
- app/assets/javascripts/baldur/controllers/accordion_controller.js
|
|
80
81
|
- app/assets/javascripts/baldur/controllers/alert_controller.js
|
|
82
|
+
- app/assets/javascripts/baldur/controllers/confirmation_controller.js
|
|
81
83
|
- app/assets/javascripts/baldur/controllers/date_field_controller.js
|
|
82
84
|
- app/assets/javascripts/baldur/controllers/details_menu_controller.js
|
|
83
85
|
- app/assets/javascripts/baldur/controllers/form_submit_controller.js
|
|
@@ -111,6 +113,7 @@ files:
|
|
|
111
113
|
- app/assets/stylesheets/baldur/application/components/card.css
|
|
112
114
|
- app/assets/stylesheets/baldur/application/components/chart.css
|
|
113
115
|
- app/assets/stylesheets/baldur/application/components/chip.css
|
|
116
|
+
- app/assets/stylesheets/baldur/application/components/confirmation.css
|
|
114
117
|
- app/assets/stylesheets/baldur/application/components/dialog.css
|
|
115
118
|
- app/assets/stylesheets/baldur/application/components/forms.css
|
|
116
119
|
- app/assets/stylesheets/baldur/application/components/layout.css
|
|
@@ -157,12 +160,14 @@ files:
|
|
|
157
160
|
- app/views/baldur/components/_card.html.erb
|
|
158
161
|
- app/views/baldur/components/_chart_card.html.erb
|
|
159
162
|
- app/views/baldur/components/_checkbox.html.erb
|
|
163
|
+
- app/views/baldur/components/_confirmation_modal.html.erb
|
|
160
164
|
- app/views/baldur/components/_date_field.html.erb
|
|
161
165
|
- app/views/baldur/components/_google_sign_in_button.html.erb
|
|
162
166
|
- app/views/baldur/components/_kebab_menu.html.erb
|
|
163
167
|
- app/views/baldur/components/_kpi.html.erb
|
|
164
168
|
- app/views/baldur/components/_menu_select.html.erb
|
|
165
169
|
- app/views/baldur/components/_modal.html.erb
|
|
170
|
+
- app/views/baldur/components/_modal_host.html.erb
|
|
166
171
|
- app/views/baldur/components/_pagination.html.erb
|
|
167
172
|
- app/views/baldur/components/_segmented_buttons.html.erb
|
|
168
173
|
- app/views/baldur/components/_settings_nav.html.erb
|
|
@@ -174,6 +179,7 @@ files:
|
|
|
174
179
|
- app/views/baldur/components/_table_card.html.erb
|
|
175
180
|
- app/views/baldur/components/_table_footer.html.erb
|
|
176
181
|
- app/views/baldur/components/_text_field.html.erb
|
|
182
|
+
- app/views/baldur/components/_theme_toggle.html.erb
|
|
177
183
|
- app/views/baldur/components/_tooltip.html.erb
|
|
178
184
|
- app/views/baldur/marketing/_cta_banner.html.erb
|
|
179
185
|
- app/views/baldur/marketing/_faq_section.html.erb
|
|
@@ -202,7 +208,10 @@ files:
|
|
|
202
208
|
- lib/generators/baldur/install_panel_right/install_panel_right_generator.rb
|
|
203
209
|
- lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb
|
|
204
210
|
- script/verify_host_install
|
|
211
|
+
- test/confirmation_modal_helper_test.rb
|
|
205
212
|
- test/csp_rendering_test.rb
|
|
213
|
+
- test/engine_css_test.rb
|
|
214
|
+
- test/fixtures/shared/_brand_lockup.html.erb
|
|
206
215
|
- test/gemspec_test.rb
|
|
207
216
|
- test/install_generator_test.rb
|
|
208
217
|
- test/install_panel_secondary_generator_test.rb
|
|
@@ -210,11 +219,13 @@ files:
|
|
|
210
219
|
- test/run_all.rb
|
|
211
220
|
- test/sidebar_helper_test.rb
|
|
212
221
|
- test/test_helper.rb
|
|
222
|
+
- test/theme_toggle_helper_test.rb
|
|
213
223
|
- test/tmp/install_generator/app/assets/stylesheets/fonts.css
|
|
214
224
|
- test/tmp/install_generator/app/assets/stylesheets/theme.css
|
|
215
225
|
- test/tmp/install_generator/app/assets/tailwind/application.css
|
|
216
226
|
- test/tmp/install_generator/app/helpers/ui_helper.rb
|
|
217
227
|
- test/tmp/install_generator/app/javascript/controllers/accordion_controller.js
|
|
228
|
+
- test/tmp/install_generator/app/javascript/controllers/confirmation_controller.js
|
|
218
229
|
- test/tmp/install_generator/app/javascript/controllers/date_field_controller.js
|
|
219
230
|
- test/tmp/install_generator/app/javascript/controllers/details_menu_controller.js
|
|
220
231
|
- test/tmp/install_generator/app/javascript/controllers/form_submit_controller.js
|
|
@@ -264,5 +275,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
264
275
|
requirements: []
|
|
265
276
|
rubygems_version: 4.0.6
|
|
266
277
|
specification_version: 4
|
|
267
|
-
summary:
|
|
278
|
+
summary: Batteries-included Rails UI engine for the importmap, Stimulus, Tailwind
|
|
279
|
+
stack
|
|
268
280
|
test_files: []
|