Sha256: 8d42596843a75958c6b8739f2ef7ea3810a99724db316421760d6380ba07d8ad
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module Ariadne # Add a general description of component here # Add additional usage considerations or best practices that may aid the user to use the component correctly. # @accessibility Add any accessibility considerations class FlexComponent < Ariadne::Component DEFAULT_TAG = :div TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = "flex" VALID_TYPES = [:row, :column, :row_reverse, :column_reverse].freeze # @example Default # # <%= render(Ariadne::FlexComponent.new(type: :column)) { "Example" } %> # # @param tag [Symbol, String] The rendered tag name. # @param type [Symbol] <%= one_of(Ariadne::FlexComponent::VALID_TYPES) %> # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> def initialize(tag: DEFAULT_TAG, type:, classes: "", attributes: {}) @tag = check_incoming_tag(DEFAULT_TAG, tag) @type = fetch_or_raise(VALID_TYPES, type) flex_class = case @type when :row "flex-row" when :column "flex-col" when :row_reverse "flex-row-reverse" when :column_reverse "flex-col-reverse" end @classes = class_names( DEFAULT_CLASSES, classes, flex_class ) @attributes = attributes end def call render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ariadne_view_components-0.0.6 | app/components/ariadne/flex_component.rb |
ariadne_view_components-0.0.5 | app/components/ariadne/flex_component.rb |