Class: DaisyUI::Button
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DaisyUI::Button
- Defined in:
- app/components/daisy_ui/actions/button.rb
Overview
Button component implementing DaisyUI’s button styles
Constant Summary collapse
- COLORS =
Available button colors from DaisyUI
{ primary: 'btn-primary', secondary: 'btn-secondary', accent: 'btn-accent', neutral: 'btn-neutral', ghost: 'btn-ghost', link: 'btn-link', info: 'btn-info', success: 'btn-success', warning: 'btn-warning', error: 'btn-error' }.freeze
- SIZES =
Available button sizes from DaisyUI
{ xl: 'btn-xl', lg: 'btn-lg', md: 'btn-md', sm: 'btn-sm', xs: 'btn-xs' }.freeze
- VARIANTS =
Available button variants from DaisyUI
{ outline: 'btn-outline', soft: 'btn-soft', dash: 'btn-dash', ghost: 'btn-ghost', link: 'btn-link' }.freeze
- SHAPES =
Available button shape modifiers
{ wide: 'btn-wide', block: 'btn-block', circle: 'btn-circle', square: 'btn-square' }.freeze
- BUTTON_TYPES =
Valid HTML button types
%w[button submit reset].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tag_type: :button, text: nil, color: nil, size: nil, variant: nil, shape: nil, disabled: false, href: nil, type: nil, method: nil, target: nil, rel: nil, loading: false, active: false, icon_start: nil, icon_end: nil, **system_arguments) ⇒ Button
constructor
A new instance of Button.
Constructor Details
#initialize(tag_type: :button, text: nil, color: nil, size: nil, variant: nil, shape: nil, disabled: false, href: nil, type: nil, method: nil, target: nil, rel: nil, loading: false, active: false, icon_start: nil, icon_end: nil, **system_arguments) ⇒ Button
Returns a new instance of Button.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'app/components/daisy_ui/actions/button.rb', line 157 def initialize( # rubocop:disable Metrics/ParameterLists tag_type: :button, text: nil, color: nil, size: nil, variant: nil, shape: nil, disabled: false, href: nil, type: nil, method: nil, target: nil, rel: nil, loading: false, active: false, icon_start: nil, icon_end: nil, **system_arguments ) @tag_type = tag_type @color = build_argument(color, COLORS, 'color') @size = build_argument(size, SIZES, 'size') @variant = build_argument(variant, VARIANTS, 'variant') @shape = build_argument(shape, SHAPES, 'shape') @disabled = disabled @href = href @method = method @target = target @rel = rel @loading = loading @active = active @type = type @text = text with_start_icon { icon_start } if icon_start with_end_icon { icon_end } if icon_end super(**system_arguments) end |
Instance Method Details
#call ⇒ Object
196 197 198 |
# File 'app/components/daisy_ui/actions/button.rb', line 196 def call tag.send(@tag_type, **full_arguments) { } end |