Module: KozenetUi::ComponentHelper
- Includes:
- IconHelper
- Defined in:
- app/helpers/kozenet_ui/component_helper.rb
Overview
Helper methods for rendering Kozenet UI components in views
Constant Summary collapse
- KOZENET_UI_STYLESHEETS =
[ "kozenet_ui/tokens", "kozenet_ui/fonts", "kozenet_ui/base", "kozenet_ui/components/button", "kozenet_ui/components/header", "kozenet_ui/components/avatar", "kozenet_ui/components/badge", "kozenet_ui/components/utilities" ].freeze
Instance Method Summary collapse
- #kozenet_ui_config_tag ⇒ Object
-
#kozenet_ui_head_tags(stylesheets: true, javascript: true) ⇒ Object
Include runtime tags once in the application layout.
-
#kozenet_ui_javascript_tag ⇒ Object
Include theme JavaScript.
-
#kozenet_ui_stylesheet_tag ⇒ Object
Include theme styles in layout.
-
#kozenet_ui_theme_variables_tag ⇒ Object
Inject inline theme variables (CSP-compliant).
-
#kz_avatar(**options, &block) ⇒ Object
Render a Kozenet UI avatar.
-
#kz_badge(**options, &block) ⇒ Object
Render a Kozenet UI badge.
-
#kz_button(**options, &block) ⇒ Object
Render a Kozenet UI button.
-
#kz_header(**options, &block) ⇒ Object
Render a Kozenet UI header.
Methods included from IconHelper
Instance Method Details
#kozenet_ui_config_tag ⇒ Object
65 66 67 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 65 def kozenet_ui_config_tag tag. name: "kozenet-ui-stimulus-prefix", content: KozenetUi.configuration.stimulus_prefix end |
#kozenet_ui_head_tags(stylesheets: true, javascript: true) ⇒ Object
Include runtime tags once in the application layout.
Stylesheets are loaded directly so Propshaft/Sprockets can emit digested asset URLs in production. Apps can pass stylesheets: false when bundling Kozenet UI CSS with their own build pipeline.
55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 55 def (stylesheets: true, javascript: true) = [] << kozenet_ui_stylesheet_tag if stylesheets << kozenet_ui_config_tag << kozenet_ui_theme_variables_tag << kozenet_ui_javascript_tag if javascript safe_join(, "\n") end |
#kozenet_ui_javascript_tag ⇒ Object
Include theme JavaScript
46 47 48 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 46 def kozenet_ui_javascript_tag javascript_include_tag "kozenet_ui/index", type: "module", "data-turbo-track": "reload" end |
#kozenet_ui_stylesheet_tag ⇒ Object
Include theme styles in layout
41 42 43 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 41 def kozenet_ui_stylesheet_tag stylesheet_link_tag(*KOZENET_UI_STYLESHEETS, "data-turbo-track": "reload") end |
#kozenet_ui_theme_variables_tag ⇒ Object
Inject inline theme variables (CSP-compliant)
70 71 72 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 70 def kozenet_ui_theme_variables_tag content_tag(:style, build_theme_css, nonce: content_security_policy_nonce) end |
#kz_avatar(**options, &block) ⇒ Object
Render a Kozenet UI avatar
36 37 38 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 36 def kz_avatar(**, &block) render(KozenetUi::AvatarComponent.new(**), &block) end |
#kz_badge(**options, &block) ⇒ Object
Render a Kozenet UI badge
31 32 33 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 31 def kz_badge(**, &block) render(KozenetUi::BadgeComponent.new(**), &block) end |
#kz_button(**options, &block) ⇒ Object
Render a Kozenet UI button
21 22 23 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 21 def (**, &block) render(KozenetUi::ButtonComponent.new(**), &block) end |
#kz_header(**options, &block) ⇒ Object
Render a Kozenet UI header
26 27 28 |
# File 'app/helpers/kozenet_ui/component_helper.rb', line 26 def kz_header(**, &block) render(KozenetUi::HeaderComponent.new(**), &block) end |