Class: KozenetUi::Configuration
- Inherits:
-
Object
- Object
- KozenetUi::Configuration
- Defined in:
- lib/kozenet_ui/configuration.rb
Overview
Configuration for Kozenet UI gem
Constant Summary collapse
- DEFAULT_COMPONENT_DEFAULTS =
{ header: { sticky: true, blur: true } }.freeze
Instance Attribute Summary collapse
-
#component_defaults ⇒ Object
readonly
Returns the value of attribute component_defaults.
-
#default_size ⇒ Object
Returns the value of attribute default_size.
-
#default_variant ⇒ Object
Returns the value of attribute default_variant.
-
#palette ⇒ Object
Returns the value of attribute palette.
-
#stimulus_prefix ⇒ Object
Returns the value of attribute stimulus_prefix.
-
#theme ⇒ Object
Returns the value of attribute theme.
Instance Method Summary collapse
-
#component(name, defaults = nil, **options) ⇒ Object
Configure global defaults for a component.
- #component_defaults_for(name) ⇒ Object
-
#customize_colors(colors = {}) ⇒ Object
Allow custom color overrides including gradients.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 |
# File 'lib/kozenet_ui/configuration.rb', line 16 def initialize @palette = Theme::Palette.new @default_variant = :primary @default_size = :md @theme = :system @stimulus_prefix = "kz" @component_defaults = DEFAULT_COMPONENT_DEFAULTS.transform_values(&:dup) end |
Instance Attribute Details
#component_defaults ⇒ Object (readonly)
Returns the value of attribute component_defaults.
14 15 16 |
# File 'lib/kozenet_ui/configuration.rb', line 14 def component_defaults @component_defaults end |
#default_size ⇒ Object
Returns the value of attribute default_size.
13 14 15 |
# File 'lib/kozenet_ui/configuration.rb', line 13 def default_size @default_size end |
#default_variant ⇒ Object
Returns the value of attribute default_variant.
13 14 15 |
# File 'lib/kozenet_ui/configuration.rb', line 13 def default_variant @default_variant end |
#palette ⇒ Object
Returns the value of attribute palette.
13 14 15 |
# File 'lib/kozenet_ui/configuration.rb', line 13 def palette @palette end |
#stimulus_prefix ⇒ Object
Returns the value of attribute stimulus_prefix.
14 15 16 |
# File 'lib/kozenet_ui/configuration.rb', line 14 def stimulus_prefix @stimulus_prefix end |
#theme ⇒ Object
Returns the value of attribute theme.
13 14 15 |
# File 'lib/kozenet_ui/configuration.rb', line 13 def theme @theme end |
Instance Method Details
#component(name, defaults = nil, **options) ⇒ Object
Configure global defaults for a component.
Per-render component options still take priority:
config.component :header, sticky: false
kz_header(sticky: true) # overrides the global default
35 36 37 38 39 |
# File 'lib/kozenet_ui/configuration.rb', line 35 def component(name, defaults = nil, **) key = name.to_sym values = symbolize_keys((defaults || {}).merge()) @component_defaults[key] = component_defaults_for(key).merge(values) end |
#component_defaults_for(name) ⇒ Object
41 42 43 |
# File 'lib/kozenet_ui/configuration.rb', line 41 def component_defaults_for(name) @component_defaults.fetch(name.to_sym, {}).dup end |