/
example_styles.py
45 lines (31 loc) · 1.09 KB
/
example_styles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from zoolander import *
sheet = Stylesheet()
with sheet.definitions as rule:
# Zoolander's semantics map directly to CSS, nothing new here.
rule("body",
font_face="Helvetica, sans-serif",
line_height=2)
rule("h1",
font_size=em(3),
font_weight=bold)
# Since this is pure Python code, we can use all of Python's control
# structures, simplest of which are variables and arithmetic operators.
side_panel_bg_color = Hex("AACCCC")
spacing = em(2)
rule("#side-panel",
margin=spacing/2,
padding=spacing+1,
background_color=side_panel_bg_color)
# Use dictionaries to mix in sets of properties to multiple rules.
toolbar_mixin = dict(background_color=Hex("556677"),
float="left",
margin=em(1))
rule("#toolbar li",
color=Hex("005599"),
font_style=italic,
**toolbar_mixin)
rule("#toolbar img",
border=(px(1), "solid", Hex("000000")),
**toolbar_mixin)
if __name__ == "__main__":
print sheet.render()