baldur 0.2.0 → 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/TODO.md +7 -1
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -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 +151 -138
- 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/_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 +19 -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 +34 -34
- 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/config/initializers/baldur.rb +7 -7
- metadata +5 -1
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require_relative '../lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator'
|
|
3
3
|
|
|
4
4
|
class BaldurInstallPanelSecondaryGeneratorTest < Rails::Generators::TestCase
|
|
5
5
|
tests Baldur::Generators::InstallPanelSecondaryGenerator
|
|
6
|
-
destination File.expand_path(
|
|
6
|
+
destination File.expand_path('tmp/install_panel_secondary_generator', __dir__)
|
|
7
7
|
setup :prepare_destination
|
|
8
8
|
|
|
9
9
|
setup do
|
|
10
|
-
FileUtils.mkdir_p File.join(destination_root,
|
|
11
|
-
File.write(File.join(destination_root,
|
|
10
|
+
FileUtils.mkdir_p File.join(destination_root, 'app/assets/tailwind')
|
|
11
|
+
File.write(File.join(destination_root, 'app/assets/tailwind/application.css'),
|
|
12
|
+
"@import \"tailwindcss\";\n@import \"../builds/tailwind/baldur.css\";\n")
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
test
|
|
15
|
+
test 'adds helper and controller without touching the tailwind contract' do
|
|
15
16
|
run_generator
|
|
16
17
|
|
|
17
|
-
assert_file
|
|
18
|
-
assert_file
|
|
19
|
-
|
|
18
|
+
assert_file 'app/helpers/panel_secondary_helper.rb', /include Baldur::Optional::PanelSecondaryHelper/
|
|
19
|
+
assert_file 'app/javascript/controllers/panel_secondary_controller.js',
|
|
20
|
+
%r{export \{ default \} from "baldur/controllers/panel_secondary_controller"}
|
|
21
|
+
assert_equal "@import \"tailwindcss\";\n@import \"../builds/tailwind/baldur.css\";\n",
|
|
22
|
+
File.read(File.join(destination_root, 'app/assets/tailwind/application.css'))
|
|
20
23
|
end
|
|
21
24
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
3
|
class BaldurMarketingHelperTest < Minitest::Test
|
|
4
4
|
HelperHost = Struct.new(:config) do
|
|
@@ -15,17 +15,17 @@ class BaldurMarketingHelperTest < Minitest::Test
|
|
|
15
15
|
|
|
16
16
|
def test_uses_configured_brand_without_host_helper_fallback
|
|
17
17
|
Baldur.config.marketing_brand = {
|
|
18
|
-
name:
|
|
19
|
-
wordmark:
|
|
20
|
-
logo_src:
|
|
18
|
+
name: 'Standalone',
|
|
19
|
+
wordmark: 'Standalone UI',
|
|
20
|
+
logo_src: '/standalone-logo.svg'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
helper = HelperHost.new(Baldur.config)
|
|
24
24
|
resolved = helper.send(:ui_marketing_configured_brand)
|
|
25
25
|
|
|
26
|
-
assert_equal
|
|
27
|
-
assert_equal
|
|
28
|
-
assert_equal
|
|
26
|
+
assert_equal 'Standalone', resolved[:name]
|
|
27
|
+
assert_equal 'Standalone UI', resolved[:wordmark]
|
|
28
|
+
assert_equal '/standalone-logo.svg', resolved[:logo_src]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def test_returns_empty_brand_hash_when_no_brand_is_configured
|
data/test/run_all.rb
CHANGED
data/test/sidebar_helper_test.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'action_controller'
|
|
4
4
|
|
|
5
5
|
class BaldurSidebarHelperTest < Minitest::Test
|
|
6
6
|
class TestController < ActionController::Base
|
|
7
|
-
append_view_path File.expand_path(
|
|
7
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
8
8
|
helper Baldur::UiHelper
|
|
9
9
|
helper Baldur::UiHelperSidebar
|
|
10
10
|
end
|
|
@@ -12,10 +12,10 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
12
12
|
def setup
|
|
13
13
|
@original_brand = Baldur.config.marketing_brand
|
|
14
14
|
Baldur.config.marketing_brand = {
|
|
15
|
-
name:
|
|
16
|
-
wordmark:
|
|
17
|
-
logo_src:
|
|
18
|
-
logo_alt:
|
|
15
|
+
name: 'Acme',
|
|
16
|
+
wordmark: 'Acme Ops',
|
|
17
|
+
logo_src: '/acme.svg',
|
|
18
|
+
logo_alt: 'Acme logo'
|
|
19
19
|
}
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -33,16 +33,16 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
33
33
|
secondary_label: "Admin"
|
|
34
34
|
) %>
|
|
35
35
|
ERB
|
|
36
|
-
formats: [
|
|
36
|
+
formats: [:html]
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
assert_includes html, 'data-controller="sidebar"'
|
|
40
40
|
assert_includes html, 'data-controller="mobile-sidebar"'
|
|
41
|
-
assert_includes html,
|
|
41
|
+
assert_includes html, 'Acme Ops'
|
|
42
42
|
assert_includes html, 'href="/dashboard"'
|
|
43
43
|
assert_includes html, 'href="/settings"'
|
|
44
44
|
assert_includes html, 'aria-current="page"'
|
|
45
|
-
assert_includes html,
|
|
45
|
+
assert_includes html, 'Admin'
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def test_sidebar_renders_slot_content_and_mobile_fallbacks
|
|
@@ -57,13 +57,13 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
57
57
|
<% end %>
|
|
58
58
|
<% end %>
|
|
59
59
|
ERB
|
|
60
|
-
formats: [
|
|
60
|
+
formats: [:html]
|
|
61
61
|
)
|
|
62
62
|
|
|
63
|
-
assert_includes html,
|
|
64
|
-
assert_includes html,
|
|
65
|
-
assert_includes html,
|
|
66
|
-
assert_operator html.scan(
|
|
67
|
-
assert_operator html.scan(
|
|
63
|
+
assert_includes html, 'Tenant Switcher'
|
|
64
|
+
assert_includes html, 'user-menu'
|
|
65
|
+
assert_includes html, 'Sign out'
|
|
66
|
+
assert_operator html.scan('Tenant Switcher').size, :>=, 2
|
|
67
|
+
assert_operator html.scan('Sign out').size, :>=, 2
|
|
68
68
|
end
|
|
69
69
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
ENV[
|
|
1
|
+
ENV['MT_NO_PLUGINS'] = '1'
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require 'rails/generators/test_case'
|
|
6
|
+
require 'rails'
|
|
7
|
+
require 'lucide-rails'
|
|
8
8
|
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
13
|
-
require_relative
|
|
14
|
-
require_relative
|
|
15
|
-
require_relative
|
|
16
|
-
require_relative
|
|
9
|
+
require_relative '../lib/baldur'
|
|
10
|
+
require_relative '../app/helpers/baldur/render_helper'
|
|
11
|
+
require_relative '../app/helpers/baldur/ui_helper_feedback'
|
|
12
|
+
require_relative '../app/helpers/baldur/ui_helper_unavailable'
|
|
13
|
+
require_relative '../app/helpers/baldur/ui_helper_forms'
|
|
14
|
+
require_relative '../app/helpers/baldur/marketing_helper'
|
|
15
|
+
require_relative '../app/helpers/baldur/ui_helper_sidebar'
|
|
16
|
+
require_relative '../app/helpers/baldur/ui_helper'
|
|
@@ -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
|
+
}
|
|
@@ -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.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Varun Murkar
|
|
@@ -179,6 +179,7 @@ files:
|
|
|
179
179
|
- app/views/baldur/components/_table_card.html.erb
|
|
180
180
|
- app/views/baldur/components/_table_footer.html.erb
|
|
181
181
|
- app/views/baldur/components/_text_field.html.erb
|
|
182
|
+
- app/views/baldur/components/_theme_toggle.html.erb
|
|
182
183
|
- app/views/baldur/components/_tooltip.html.erb
|
|
183
184
|
- app/views/baldur/marketing/_cta_banner.html.erb
|
|
184
185
|
- app/views/baldur/marketing/_faq_section.html.erb
|
|
@@ -209,6 +210,8 @@ files:
|
|
|
209
210
|
- script/verify_host_install
|
|
210
211
|
- test/confirmation_modal_helper_test.rb
|
|
211
212
|
- test/csp_rendering_test.rb
|
|
213
|
+
- test/engine_css_test.rb
|
|
214
|
+
- test/fixtures/shared/_brand_lockup.html.erb
|
|
212
215
|
- test/gemspec_test.rb
|
|
213
216
|
- test/install_generator_test.rb
|
|
214
217
|
- test/install_panel_secondary_generator_test.rb
|
|
@@ -216,6 +219,7 @@ files:
|
|
|
216
219
|
- test/run_all.rb
|
|
217
220
|
- test/sidebar_helper_test.rb
|
|
218
221
|
- test/test_helper.rb
|
|
222
|
+
- test/theme_toggle_helper_test.rb
|
|
219
223
|
- test/tmp/install_generator/app/assets/stylesheets/fonts.css
|
|
220
224
|
- test/tmp/install_generator/app/assets/stylesheets/theme.css
|
|
221
225
|
- test/tmp/install_generator/app/assets/tailwind/application.css
|