lib/playbook/kit_base.rb in playbook_ui-13.20.0.pre.alpha.PLAY12572402 vs lib/playbook/kit_base.rb in playbook_ui-13.20.0.pre.alpha.play1247htmloptions2403
- old
+ new
@@ -65,12 +65,30 @@
include Playbook::Bottom
prop :id
prop :data, type: Playbook::Props::HashProp, default: {}
prop :aria, type: Playbook::Props::HashProp, default: {}
+ prop :html_options, type: Playbook::Props::HashProp, default: {}
prop :children, type: Playbook::Props::Proc
def object
self
+ end
+
+ def combined_html_options
+ default_html_options.merge(html_options.deep_merge(data_attributes))
+ end
+
+ private
+
+ def default_html_options
+ {}
+ end
+
+ def data_attributes
+ {
+ data: data,
+ aria: aria,
+ }.transform_keys { |key| key.to_s.gsub("_", "-") }
end
end
end