Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVG and custom content options to NavList's leading visual slot #1422

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/components/primer/alpha/action_list/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@ class Item < Primer::Component
# for layout options.
renders_one :description

# An icon or avatar that will render to the left of the label.
# An icon, avatar, SVG, or custom content that will render to the left of the label.
#
# To render an icon, call the `with_leading_visual_icon` method, which accepts the arguments accepted by <%= link_to_component(Primer::OcticonComponent) %>.
#
# To render an avatar, call the `with_leading_visual_avatar` method, which accepts the arguments accepted by <%= link_to_component(Primer::Beta::Avatar) %>.
#
# To render an SVG, call the `with_leading_visual_svg` method.
#
# To render custom content, call the `with_leading_visual_content` method and pass a block that returns a string.
renders_one :leading_visual, types: {
icon: Primer::OcticonComponent,
avatar: ->(**kwargs) { Primer::Beta::Avatar.new(**{ **kwargs, size: 16 }) }
avatar: ->(**kwargs) { Primer::Beta::Avatar.new(**{ **kwargs, size: 16 }) },
svg: lambda { |**system_arguments|
Primer::BaseComponent.new(tag: :svg, **system_arguments)
},
content: lambda { |**system_arguments|
Primer::BaseComponent.new(tag: :span, **system_arguments)
}
}

# Used internally.
Expand Down