Sha256: 7720cb605e643595ba66a9a817312497aefa57416b1ede11e69f4cb9b9ea1617
Contents?: true
Size: 1.46 KB
Versions: 122
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module Ariadne # Adds a flex container to the page. class FlexComponent < Ariadne::Component DEFAULT_TAG = :div TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = "ariadne-flex" VALID_TYPES = [:row, :column, :row_reverse, :column_reverse].freeze # The sub-items(s) to render renders_many :items, lambda { |static_content = nil, &block| next static_content if static_content.present? view_context.capture { block&.call } } # @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 "ariadne-flex-row" when :column "ariadne-flex-col" when :row_reverse "ariadne-flex-row-reverse" when :column_reverse "ariadne-flex-col-reverse" end @classes = merge_class_names( DEFAULT_CLASSES, classes, flex_class, ) @attributes = attributes end def render? items? end end end
Version data entries
122 entries across 122 versions & 1 rubygems
Version | Path |
---|---|
ariadne_view_components-0.0.35-arm64-darwin | app/components/ariadne/flex_component.rb |
ariadne_view_components-0.0.35-aarch64-linux | app/components/ariadne/flex_component.rb |