-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes the icons simple to customize and allows us to deprecate behavior that deals with the internals of the asset pipeline
- Loading branch information
Showing
10 changed files
with
103 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module Icons | ||
class LegacyIconComponent < ::ViewComponent::Base | ||
extend Deprecation | ||
|
||
def initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img', additional_options: {}) | ||
@name = name | ||
Deprecation.warn(self, "Calling the LegacyIconComponent with \"#{name}\" is deprecated. Instead create a component for this icon.") | ||
@classes = classes | ||
@aria_hidden = aria_hidden | ||
@icon = Blacklight::Icon.new(name, classes: classes, label: label, role: role, additional_options: additional_options) | ||
end | ||
|
||
def call | ||
tag.span(svg.html_safe, # rubocop:disable Rails/OutputSafety | ||
class: "blacklight-icons blacklight-icon-#{@name} #{@classes}".strip, | ||
'aria-hidden': (true if @aria_hidden)) | ||
end | ||
|
||
def svg | ||
Rails.cache.fetch([:blacklight_icon_svg, @name]) do | ||
@icon.svg | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module Icons | ||
# This is the list icon for the search button. | ||
# You can override the default svg by setting: | ||
# Blackligh::Icons::ListComponent.svg = '<svg>your SVG here</svg>' | ||
class ListComponent < ::ViewComponent::Base | ||
def call | ||
svg.html_safe # rubocop:disable Rails/OutputSafety | ||
end | ||
|
||
class_attribute :svg, default: <<~SVG | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true" width="24" height="24" viewBox="0 0 24 24"> | ||
<path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/><path d="M0 0h24v24H0z" fill="none"/></svg> | ||
</svg> | ||
SVG | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module Icons | ||
# This is the magnifing glass icon for the search button. | ||
# You can override the default svg by setting: | ||
# Blackligh::Icons::SearchComponent.svg = '<svg>your SVG here</svg>' | ||
class SearchComponent < ::ViewComponent::Base | ||
def call | ||
svg.html_safe # rubocop:disable Rails/OutputSafety | ||
end | ||
|
||
class_attribute :svg, default: <<~SVG | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true" width="24" height="24" viewBox="0 0 24 24"> | ||
<path fill="none" d="M0 0h24v24H0V0z"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/> | ||
</svg> | ||
SVG | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters