side_menu_component: add icon
This commit is contained in:
parent
62662c99c0
commit
2fb33336d1
2 changed files with 8 additions and 3 deletions
|
@ -2,10 +2,11 @@ class Dsfr::SidemenuComponent < ApplicationComponent
|
|||
renders_many :links, "LinkComponent"
|
||||
|
||||
class LinkComponent < ApplicationComponent
|
||||
attr_reader :name, :url
|
||||
def initialize(name:, url:)
|
||||
attr_reader :name, :url, :icon
|
||||
def initialize(name:, url:, icon: nil)
|
||||
@name = name
|
||||
@url = url
|
||||
@icon = icon
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,4 +6,8 @@
|
|||
%ul.fr-sidemenu__list
|
||||
- links.each do |link|
|
||||
%li{ class: "fr-sidemenu__item fr-sidemenu__item#{active?(link.url) ? '--active' : ''}" }
|
||||
= link_to link.name, link.url, class: 'fr-sidemenu__link', 'aria-current': active?(link.url) ? 'page' : nil, target: "_self"
|
||||
= link_to link.url, class: 'fr-sidemenu__link ', 'aria-current': active?(link.url) ? 'page' : nil, target: "_self" do
|
||||
- capture do
|
||||
- if link.icon.present?
|
||||
%span{ class: link.icon }
|
||||
= link.name
|
||||
|
|
Loading…
Reference in a new issue