bs-css-core
42 | 43 |Statically typed DSL for writing CSS in ReasonML.
44 |This is a fork of bs-css that 45 | extracts the Css module, so that it can be used by various CSS-in-JS bindings. 46 | See bs-react-fela-examples 47 | and 48 | bs-styletron-react-examples 49 | for practical examples of usage.
50 |Installation
51 | 52 |yarn add @astrada/bs-css-core
53 |
54 | In your bsconfig.json
, include "@astrada/bs-css-core"
in the
55 | bs-dependencies
.
Usage
57 | 58 |type theme = {
61 | textColor: Css.color,
62 | basePadding: Css.length
63 | };
64 |
65 | let makeStyle = (theme) =>
66 | Css.(
67 | style([
68 | backgroundColor(white),
69 | boxShadows([boxShadow(~y=px(3), ~blur=px(5), rgba(0, 0, 0, 0.3))]),
77 | padding(theme.basePadding),
78 | fontSize(rem(1.5)),
117 | color(theme.textColor),
118 | marginBottom(px(10))
155 | ])
156 | );
157 |
158 |
159 |
160 | [@@@ocaml.ppx.context { cookies = [] }]
163 | type theme = {
164 | textColor: Css.color;
165 | basePadding: Css.length;}
166 | let makeStyle theme =
167 | let open Css in
168 | style
169 | [backgroundColor white;
170 | boxShadows [boxShadow ~y:(px 3) ~blur:(px 5) (rgba 0 0 0 0.3)];
178 | padding theme.basePadding;
179 | fontSize (rem 1.5);
218 | color theme.textColor;
219 | marginBottom (px 10)]
256 |
257 |
258 |
259 | Keyframes
262 |Define animation keyframes;
263 |let bounce =
266 | Css.(
267 | keyframes([
268 | (0, [transform(scale(0.1, 0.1)), opacity(0.0)]),
269 | (60, [transform(scale(1.2, 1.2)), opacity(1.0)]),
270 | (100, [transform(scale(1.0, 1.0)), opacity(1.0)])
271 | ])
272 | );
273 |
274 | let makeStyle = (_theme) =>
275 | Css.(
276 | style([
277 | animationName(bounce),
278 | animationDuration(2000),
279 | width(px(50)),
316 | height(px(50)),
353 | backgroundColor(rgb(255, 0, 0))
354 | ])
355 | );
356 |
357 |
358 |
359 | [@@@ocaml.ppx.context { cookies = [] }]
362 | let bounce =
363 | let open Css in
364 | keyframes
365 | [(0, [transform (scale 0.1 0.1); opacity 0.0]);
366 | (60, [transform (scale 1.2 1.2); opacity 1.0]);
367 | (100, [transform (scale 1.0 1.0); opacity 1.0])]
368 | let makeStyle _theme =
369 | let open Css in
370 | style
371 | [animationName bounce;
372 | animationDuration 2000;
373 | width (px 50);
410 | height (px 50);
447 | backgroundColor (rgb 255 0 0)]
448 |
449 |
450 |
451 | Development
454 | 455 |yarn start
456 |
457 | Where is the documentation?
458 | 459 |Documentation generated with redoc is 460 | published here.
461 |Thanks
462 | 463 |Thanks to bs-css that introduced 464 | the DSL. Thanks to bs-glamor which 465 | bs-css was forked from. Thanks to 466 | elm-css for DSL design inspiration. 467 | Thanks to @jaredly for redoc.
468 | 469 |