Sha256: a696b128ea1be1eb154ea89a90b5f4e09705cdb8eab297a6590e22d4cfbd54bf
Contents?: true
Size: 1.12 KB
Versions: 17
Compression:
Stored size: 1.12 KB
Contents
module Coco module App module Blocks module SidebarNav class Item < Coco::Component include Concerns::Extendable include Concerns::AcceptsOptions tag_attr :href component_name :app_sidebar_nav_item accepts_option :active, from: [true, false] accepts_option :emphasise, from: [true, false] renders_one :icon renders_one :menu before_render do if @icon && !icon? with_icon { coco_icon(@icon, size: :full) } end if link? && get_option_value(:active).nil? set_option_value(:active, helpers.current_page?(tag_attr(:href))) end end attr_reader :label def initialize(label:, icon: nil, **) @label = label @icon = icon end def link? tag_attr?(:href) && !menu? end def item_tag link? ? :a : :button end def menu_id "#{tag_attr(:id)}-menu" if tag_attr?(:id) end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems