Method: Coco::Button#states

Defined in:
app/components/coco/base/button/button.rb

#statesObject



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'app/components/coco/base/button/button.rb', line 160

def states
  @_states ||= begin
    states = default_states.deep_merge(@states)

    states.each do |name, props|
      if props.key?(:icon)
        if props[:icon] == false
          props.except!(:icon) # explicitly no icon
        else
          props[:icon] = render_icon(props[:icon])
        end
      elsif icon?
        props[:icon] = icon # no icon specified, use the icon for the default state
      end
    end.compact.transform_keys { _1.to_s.camelcase(:lower) }
  end
end