Class: RailsuiIcon::Icon
- Inherits:
-
Object
- Object
- RailsuiIcon::Icon
- Defined in:
- lib/railsui_icon/icon.rb
Constant Summary collapse
- VALID_VARIANTS =
%i[solid outline mini micro].freeze
Instance Attribute Summary collapse
-
#custom_path ⇒ Object
readonly
Returns the value of attribute custom_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, variant: RailsuiIcon.configuration.default_variant, options: {}, custom_path: nil) ⇒ Icon
constructor
A new instance of Icon.
- #render ⇒ Object
Constructor Details
#initialize(name:, variant: RailsuiIcon.configuration.default_variant, options: {}, custom_path: nil) ⇒ Icon
Returns a new instance of Icon.
9 10 11 12 13 14 |
# File 'lib/railsui_icon/icon.rb', line 9 def initialize(name:, variant: RailsuiIcon.configuration.default_variant, options: {}, custom_path: nil) @name = name @variant = validate_variant(variant) @options = @custom_path = custom_path end |
Instance Attribute Details
#custom_path ⇒ Object (readonly)
Returns the value of attribute custom_path.
7 8 9 |
# File 'lib/railsui_icon/icon.rb', line 7 def custom_path @custom_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/railsui_icon/icon.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/railsui_icon/icon.rb', line 7 def @options end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
7 8 9 |
# File 'lib/railsui_icon/icon.rb', line 7 def variant @variant end |
Class Method Details
.render(**kwargs) ⇒ Object
154 155 156 |
# File 'lib/railsui_icon/icon.rb', line 154 def render(**kwargs) new(**kwargs).render end |
Instance Method Details
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/railsui_icon/icon.rb', line 16 def render if custom_path render_custom_path(custom_path) else render_standard_icon end rescue StandardError => e Rails.logger.error "Failed to render icon: #{e.}" warning end |