Class: Glyphs::Icon
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Glyphs::Icon
- Defined in:
- lib/glyphs/icon.rb
Overview
Base icon component. Prefer the library-specific subclasses (LucideIcon, HeroIcon, ...); the generic form requires an explicit library:
Icon(:house, library: :lucide)
Direct Known Subclasses
AnimatedIcon, BoxIcon, FeatherIcon, FlagIcon, HeroIcon, HugeIcon, LinearIcon, LucideIcon, PhosphorIcon, RadixIcon, SidekickIcon, TablerIcon, WeatherIcon
Constant Summary collapse
- LIBRARY =
nil
Instance Method Summary collapse
-
#initialize(name, variant: nil, library: self.class::LIBRARY, **attributes) ⇒ Icon
constructor
A new instance of Icon.
- #view_template ⇒ Object
Constructor Details
#initialize(name, variant: nil, library: self.class::LIBRARY, **attributes) ⇒ Icon
Returns a new instance of Icon.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/glyphs/icon.rb', line 11 def initialize(name, variant: nil, library: self.class::LIBRARY, **attributes) if library.nil? raise ArgumentError, "library is required — use a library component (LucideIcon, HeroIcon, ...) or pass library:" end @name = name.to_s.tr("_", "-") @library = library.to_sym @variant = variant&.to_sym @attributes = attributes super() end |
Instance Method Details
#view_template ⇒ Object
25 26 27 |
# File 'lib/glyphs/icon.rb', line 25 def view_template raw safe(svg_markup) end |