Sha256: 7f72c77e49a8c2fe3010c84c144320105e8c20844391bd6a8836feb4c522b401
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
# frozen_string_literal: true module Optics module Sidebar class Component < ApplicationViewComponent VARIANTS = %w[drawer compact rail] renders_one :brand, 'Brand' renders_many :sidebar_contents, 'SidebarContent' accepts :responsive, default: false accepts :variant, default: 'drawer' def call content_tag( :nav, class: classes ) do capture do concat brand sidebar_contents.each do |content| concat content end end end end def classes class_names( 'sidebar', variant_class, @attributes[:class], 'sidebar--responsive': responsive ).join(' ') end def variant_class "sidebar--#{variant}" end class Brand < ApplicationViewComponent accepts :url accepts :image_source def call link_to(url, class: 'sidebar__brand') do image_tag(image_source) end end end class SidebarContent < ApplicationViewComponent renders_many :buttons, Optics::Button::Component accepts :position, default: 'center' def call concat( content_tag( :div, class: classes ) do buttons.each do |button| concat button end end ) end def classes class_names( 'sidebar__content', position_class, ).join(' ') end def position_class "sidebar__content--#{position}" end end class LinksComponent < ApplicationViewComponent accepts :image_source accepts :url def call link_to(url, class: 'sidebar__brand') do image_tag(image_source) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
optics_view_components-0.1.7 | app/components/optics/sidebar/component.rb |