Class: Spark::Component::Base
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Spark::Component::Base
show all
- Includes:
- Spark::Component
- Defined in:
- app/components/spark/component/base.rb
Direct Known Subclasses
Embed::WistiaMedia, Badge, Banner, Blankslate, Block, Button, Button::Group, Spark::Card, Spark::Checklist, Spark::Checklist::Container, Spark::Checklist::Item, Spark::Checklist::Trigger, Embed::WistiaMedia, Grid, Grid::Column, Input::Base, Input::Label, MediaBlock, Nav::Group, Nav::Item, Nav::Sidebar, Nav::Tabs, Nav::Toggle, Nav::Tree, Page, Placeholder, StickyPanel, Table, Table::Cell, Table::Object, Table::Row, Tooltip, TrialNotice, WidgetCard
Instance Method Summary
collapse
Instance Method Details
#selector(root, sub = nil, val: nil) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/components/spark/component/base.rb', line 6
def selector(root, sub = nil, val: nil)
sub = sub.to_s.dasherize if sub
val ||= case root
when :data, :aria then
tag_attrs[root][sub]
else
tag_attrs[root]
end
%([#{[root, sub].compact.join('-').dasherize}="#{val}"])
end
|
#to_s ⇒ Object
22
23
24
|
# File 'app/components/spark/component/base.rb', line 22
def to_s
self.yield
end
|
#unique_id(prefix = :id) ⇒ Object
18
19
20
|
# File 'app/components/spark/component/base.rb', line 18
def unique_id(prefix = :id)
"#{prefix}-#{SecureRandom.hex(10)}"
end
|