Class: Daisy::Actions::ThemePreviewComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Actions::ThemePreviewComponent
- Defined in:
- app/components/daisy/actions/theme_preview_component.rb
Overview
The Theme Preview component displays a small preview of a DaisyUI theme’s colors. It helps users visualize the theme by showing a 2x2 grid of colored dots representing the base-content, primary, secondary, and accent colors of the theme.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Sets up the component’s CSS classes and other attributes before rendering.
-
#initialize(theme = nil, **kws, &block) ⇒ ThemePreviewComponent
constructor
Creates a new instance of the ThemePreviewComponent.
-
#setup_component ⇒ Object
Sets up the component’s CSS classes and data attributes.
-
#setup_dots ⇒ Object
Sets up the CSS classes for the theme color dots.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(theme = nil, **kws, &block) ⇒ ThemePreviewComponent
Creates a new instance of the ThemePreviewComponent.
32 33 34 35 36 |
# File 'app/components/daisy/actions/theme_preview_component.rb', line 32 def initialize(theme = nil, **kws, &block) super @theme = config_option(:theme, theme) end |
Instance Method Details
#before_render ⇒ Object
Sets up the component’s CSS classes and other attributes before rendering.
41 42 43 44 |
# File 'app/components/daisy/actions/theme_preview_component.rb', line 41 def before_render setup_component setup_dots end |
#setup_component ⇒ Object
Sets up the component’s CSS classes and data attributes.
49 50 51 52 53 54 55 56 57 |
# File 'app/components/daisy/actions/theme_preview_component.rb', line 49 def setup_component classes = [ "where:size-4 where:grid where:grid-cols-2 where:place-items-center", "where:shrink-0 where:rounded-md where:bg-base-100 where:shadow-sm" ].join(" ") add_css(:component, classes) add_html(:component, { "data-theme": @theme }) end |
#setup_dots ⇒ Object
Sets up the CSS classes for the theme color dots.
62 63 64 65 66 67 |
# File 'app/components/daisy/actions/theme_preview_component.rb', line 62 def setup_dots add_css(:dot_base, "where:bg-base-content where:size-1 where:rounded-full") add_css(:dot_primary, "where:bg-primary where:size-1 where:rounded-full") add_css(:dot_secondary, "where:bg-secondary where:size-1 where:rounded-full") add_css(:dot_accent, "where:bg-accent where:size-1 where:rounded-full") end |