Sha256: 6e0c50f25946b50c3a88303ec7f476eb3190d9253a4640b1220480b7669539d0
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true module Yattho module Beta # Use `BaseButton` to render an unstyled `<button>` tag that can be customized. class BaseButton < Yattho::Component status :beta DEFAULT_TAG = :button TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze DEFAULT_TYPE = :button TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze # @example Block # <%= render(Yattho::Beta::BaseButton.new(block: :true)) { "Block" } %> # <%= render(Yattho::Beta::BaseButton.new(block: :true, scheme: :primary)) { "Primary block" } %> # # @param tag [Symbol] <%= one_of(Yattho::Beta::BaseButton::TAG_OPTIONS) %> # @param type [Symbol] <%= one_of(Yattho::Beta::BaseButton::TYPE_OPTIONS) %> # @param block [Boolean] Whether button is full-width with `display: block`. # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> def initialize( tag: DEFAULT_TAG, type: DEFAULT_TYPE, block: false, **system_arguments ) @system_arguments = system_arguments @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG) if @system_arguments[:tag] == :button @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE) end @system_arguments[:classes] = class_names( system_arguments[:classes], "btn-block" => block ) end def call render(Yattho::BaseComponent.new(**@system_arguments)) { content } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yattho_view_components-0.1.1 | app/components/yattho/beta/base_button.rb |
yattho_view_components-0.0.1 | app/components/yattho/beta/base_button.rb |