Sha256: cf28dfb3021efe9555b6dc772c0ee3bec68ba1324ac2a89eef50205df2b0cd90
Contents?: true
Size: 612 Bytes
Versions: 4
Compression:
Stored size: 612 Bytes
Contents
# frozen_string_literal: true module Components class Nav::Item < Phlex::HTML def initialize(text, to:, active_page:) @text = text @to = to @active_page = active_page end def template li do a(**link_classes, href: "/#{link}") { @text } end end def link_classes classes("pb-1 block font-medium text-stone-500", active?: "text-red-600 font-bold") end def link path == "index" ? "" : path end def path @to.name.split("::")[1..].map { _1.gsub(/(.)([A-Z])/, '\1-\2') }.map(&:downcase).join("/") end def active? @active_page.instance_of?(@to) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
phlex-0.5.3 | docs/components/nav/item.rb |
phlex-0.5.2 | docs/components/nav/item.rb |
phlex-0.5.1 | docs/components/nav/item.rb |
phlex-0.5.0 | docs/components/nav/item.rb |