Module: Emjay::Styles
- Defined in:
- lib/emjay/helpers/styles.rb
Class Method Summary collapse
-
.build_from_components(breakpoint, components_head_style, head_style) ⇒ Object
Builds <style> tag from component head styles and head style functions.
-
.build_from_tags(breakpoint, styles) ⇒ Object
Builds <style> tag from user-provided style strings/procs.
Class Method Details
.build_from_components(breakpoint, components_head_style, head_style) ⇒ Object
Builds <style> tag from component head styles and head style functions. Port of styles.js buildStyleFromComponents
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/emjay/helpers/styles.rb', line 7 def self.build_from_components(breakpoint, components_head_style, head_style) head_styles = head_style.values all = components_head_style + head_styles return "" if all.empty? css = all.map { |style_fn| style_fn.call(breakpoint) }.join("\n") <<~HTML.chomp <style type="text/css">#{css} </style> HTML end |
.build_from_tags(breakpoint, styles) ⇒ Object
Builds <style> tag from user-provided style strings/procs. Port of styles.js buildStyleFromTags
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/emjay/helpers/styles.rb', line 23 def self.(breakpoint, styles) return "" if styles.empty? css = styles.map { |style| style.respond_to?(:call) ? style.call(breakpoint) : style }.join("\n") <<~HTML.chomp <style type="text/css">#{css} </style> HTML end |