Class: LightningUiKit::SeparatorComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::SeparatorComponent
- Defined in:
- app/components/lightning_ui_kit/separator_component.rb
Constant Summary collapse
- ORIENTATIONS =
%i[horizontal vertical].freeze
Instance Method Summary collapse
- #aria_attributes ⇒ Object
- #classes ⇒ Object
- #data ⇒ Object
-
#initialize(orientation: :horizontal, decorative: true, **options) ⇒ SeparatorComponent
constructor
A new instance of SeparatorComponent.
Constructor Details
#initialize(orientation: :horizontal, decorative: true, **options) ⇒ SeparatorComponent
Returns a new instance of SeparatorComponent.
4 5 6 7 8 |
# File 'app/components/lightning_ui_kit/separator_component.rb', line 4 def initialize(orientation: :horizontal, decorative: true, **) @orientation = ORIENTATIONS.include?(orientation) ? orientation : :horizontal @decorative = decorative @options = end |
Instance Method Details
#aria_attributes ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/components/lightning_ui_kit/separator_component.rb', line 25 def aria_attributes if @decorative {role: "none"} else {role: "separator", "aria-orientation": @orientation.to_s} end end |
#classes ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/lightning_ui_kit/separator_component.rb', line 10 def classes orientation_classes = if @orientation == :vertical "lui:h-full lui:w-px" else "lui:h-px lui:w-full" end merge_classes([ "lui:shrink-0 lui:bg-border", orientation_classes, @options[:class] ].compact.join(" ")) end |
#data ⇒ Object
33 34 35 |
# File 'app/components/lightning_ui_kit/separator_component.rb', line 33 def data @options[:data] || {} end |