Tailwind classes in OCaml
1type font_family = [ `Sans | `Serif | `Mono ]
2type font_size = [ `Xs | `Sm | `Base | `Lg | `Xl | `Xl2 | `Xl3 | `Xl4 | `Xl5 | `Xl6 | `Xl7 | `Xl8 | `Xl9 ]
3type font_weight = [ `Thin | `Extralight | `Light | `Normal | `Medium | `Semibold | `Bold | `Extrabold | `Black ]
4type font_style = [ `Italic | `Not_italic ]
5type letter_spacing = [ `Tighter | `Tight | `Normal | `Wide | `Wider | `Widest ]
6type line_height = [ `None | `Tight | `Snug | `Normal | `Relaxed | `Loose | `Rem of float ]
7type text_align = [ `Left | `Center | `Right | `Justify | `Start | `End ]
8type text_decoration = [ `Underline | `Overline | `Line_through | `No_underline ]
9type text_transform = [ `Uppercase | `Lowercase | `Capitalize | `Normal_case ]
10
11type t = [
12 | `Font_family of font_family
13 | `Font_size of font_size
14 | `Font_weight of font_weight
15 | `Font_style of font_style
16 | `Letter_spacing of letter_spacing
17 | `Line_height of line_height
18 | `Text_align of text_align
19 | `Text_decoration of text_decoration
20 | `Text_transform of text_transform
21 | `Text_color of Color.t
22]
23
24let to_class = function
25 | `Font_family `Sans -> Css.make "font-sans"
26 | `Font_family `Serif -> Css.make "font-serif"
27 | `Font_family `Mono -> Css.make "font-mono"
28 | `Font_size `Xs -> Css.make "text-xs"
29 | `Font_size `Sm -> Css.make "text-sm"
30 | `Font_size `Base -> Css.make "text-base"
31 | `Font_size `Lg -> Css.make "text-lg"
32 | `Font_size `Xl -> Css.make "text-xl"
33 | `Font_size `Xl2 -> Css.make "text-2xl"
34 | `Font_size `Xl3 -> Css.make "text-3xl"
35 | `Font_size `Xl4 -> Css.make "text-4xl"
36 | `Font_size `Xl5 -> Css.make "text-5xl"
37 | `Font_size `Xl6 -> Css.make "text-6xl"
38 | `Font_size `Xl7 -> Css.make "text-7xl"
39 | `Font_size `Xl8 -> Css.make "text-8xl"
40 | `Font_size `Xl9 -> Css.make "text-9xl"
41 | `Font_weight `Thin -> Css.make "font-thin"
42 | `Font_weight `Extralight -> Css.make "font-extralight"
43 | `Font_weight `Light -> Css.make "font-light"
44 | `Font_weight `Normal -> Css.make "font-normal"
45 | `Font_weight `Medium -> Css.make "font-medium"
46 | `Font_weight `Semibold -> Css.make "font-semibold"
47 | `Font_weight `Bold -> Css.make "font-bold"
48 | `Font_weight `Extrabold -> Css.make "font-extrabold"
49 | `Font_weight `Black -> Css.make "font-black"
50 | `Font_style `Italic -> Css.make "italic"
51 | `Font_style `Not_italic -> Css.make "not-italic"
52 | `Letter_spacing `Tighter -> Css.make "tracking-tighter"
53 | `Letter_spacing `Tight -> Css.make "tracking-tight"
54 | `Letter_spacing `Normal -> Css.make "tracking-normal"
55 | `Letter_spacing `Wide -> Css.make "tracking-wide"
56 | `Letter_spacing `Wider -> Css.make "tracking-wider"
57 | `Letter_spacing `Widest -> Css.make "tracking-widest"
58 | `Line_height `None -> Css.make "leading-none"
59 | `Line_height `Tight -> Css.make "leading-tight"
60 | `Line_height `Snug -> Css.make "leading-snug"
61 | `Line_height `Normal -> Css.make "leading-normal"
62 | `Line_height `Relaxed -> Css.make "leading-relaxed"
63 | `Line_height `Loose -> Css.make "leading-loose"
64 | `Line_height (`Rem f) -> Css.make (Printf.sprintf "leading-[%.1frem]" f)
65 | `Text_align `Left -> Css.make "text-left"
66 | `Text_align `Center -> Css.make "text-center"
67 | `Text_align `Right -> Css.make "text-right"
68 | `Text_align `Justify -> Css.make "text-justify"
69 | `Text_align `Start -> Css.make "text-start"
70 | `Text_align `End -> Css.make "text-end"
71 | `Text_decoration `Underline -> Css.make "underline"
72 | `Text_decoration `Overline -> Css.make "overline"
73 | `Text_decoration `Line_through -> Css.make "line-through"
74 | `Text_decoration `No_underline -> Css.make "no-underline"
75 | `Text_transform `Uppercase -> Css.make "uppercase"
76 | `Text_transform `Lowercase -> Css.make "lowercase"
77 | `Text_transform `Capitalize -> Css.make "capitalize"
78 | `Text_transform `Normal_case -> Css.make "normal-case"
79 | `Text_color color -> Color.text color
80
81let font_family ff = `Font_family ff
82let font_size fs = `Font_size fs
83let font_weight fw = `Font_weight fw
84let font_style fs = `Font_style fs
85let letter_spacing ls = `Letter_spacing ls
86let line_height lh = `Line_height lh
87let text_align ta = `Text_align ta
88let text_decoration td = `Text_decoration td
89let text_transform tt = `Text_transform tt
90let text_color c = `Text_color c
91
92let text_xs = Css.make "text-xs"
93let text_sm = Css.make "text-sm"
94let text_base = Css.make "text-base"
95let text_lg = Css.make "text-lg"
96let text_xl = Css.make "text-xl"
97let font_bold = Css.make "font-bold"
98let font_normal = Css.make "font-normal"
99let italic = Css.make "italic"
100let underline = Css.make "underline"
101let uppercase = Css.make "uppercase"
102let lowercase = Css.make "lowercase"
103let capitalize = Css.make "capitalize"