Module: Mint::CSS
- Defined in:
- lib/mint/css.rb
Instance Method Summary collapse
- #container ⇒ Object
- #format(key, value) ⇒ Object
-
#mappings ⇒ Object
Maps a “DSL” onto actual CSS.
- #parse(style) ⇒ Object
Instance Method Details
#container ⇒ Object
3 4 5 |
# File 'lib/mint/css.rb', line 3 def container 'container' end |
#format(key, value) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/mint/css.rb', line 46 def format(key, value) selector = mappings[Helpers.symbolize key] if selector.include? '%' selector % value else "#{selector || key}: #{value}" end end |
#mappings ⇒ Object
Maps a “DSL” onto actual CSS. This is not yet implemented, but the plan is to translate this …
Font: Helvetica Margin: 1 in Line spacing: 1.25
… into something like:
#container {
font: (value specified and cleaned up)
padding-left: (value specified and cleaned up)
...
p { line-height: (value specified and cleaned up) }
}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mint/css.rb', line 23 def mappings { font: 'font', color: 'color', top_margin: 'padding-top', bottom_margin: 'padding-bottom', left_margin: 'padding-left', right_margin: 'padding-right', top: 'padding-top', bottom: 'padding-bottom', left: 'padding-left', right: 'padding-right', height: 'height', width: 'width', line_spacing: 'p { line-height: %s }', bullet: 'bullet-shape', indentation: 'text-indent', after_paragraph: 'margin-bottom', before_paragraph: 'margin-top', smart_typography: 'optimizeLegibility' } end |
#parse(style) ⇒ Object
56 57 58 59 |
# File 'lib/mint/css.rb', line 56 def parse(style) css = style.map {|k,v| format(k, v) }.join("\n ") "##{container} {\n #{css.strip}\n}" end |