All Projects â†’ reasonml-community â†’ Bs Glamor

reasonml-community / Bs Glamor

BuckleScript bindings for glamor

Programming Languages

ocaml
1615 projects

Labels

Projects that are alternatives of or similar to Bs Glamor

Rollup Plugin Bucklescript
rollup plugin for using bucklescript
Stars: ✭ 23 (-72.29%)
Mutual labels:  reasonml
Bsdoc
📚 Documentation Generator for BuckleScript
Stars: ✭ 43 (-48.19%)
Mutual labels:  reasonml
Reenv
dotenv-cli implementation in native ReasonML providing near-instant startup times
Stars: ✭ 65 (-21.69%)
Mutual labels:  reasonml
Reason Libvim
Reason API for libvim
Stars: ✭ 20 (-75.9%)
Mutual labels:  reasonml
Reason From The Very Beginning
Ocaml From The Very Beginning solved with Reason instead of Ocaml
Stars: ✭ 36 (-56.63%)
Mutual labels:  reasonml
Recontainers
[DEPRECATED] ReasonReact utilitary high order components
Stars: ✭ 54 (-34.94%)
Mutual labels:  reasonml
Cra Template Rescript Lukin
🐪 Lukin CRA and ReScript Template
Stars: ✭ 18 (-78.31%)
Mutual labels:  reasonml
Rescript React Update
useReducer with updates and side effects!
Stars: ✭ 79 (-4.82%)
Mutual labels:  reasonml
Pragma
Pragma is a self-hosted, open-source, personal note taking app.
Stars: ✭ 39 (-53.01%)
Mutual labels:  reasonml
One Punch Fitness
A "One Punch Man"-inspired workout app!
Stars: ✭ 64 (-22.89%)
Mutual labels:  reasonml
Bs React Intl Extractor
Extracts messages for localization from Reason source files.
Stars: ✭ 27 (-67.47%)
Mutual labels:  reasonml
Revery
⚡ Native, high-performance, cross-platform desktop apps - built with Reason!
Stars: ✭ 7,812 (+9312.05%)
Mutual labels:  reasonml
Gitlab Search
Command line tool to search for contents in GitLab repositories
Stars: ✭ 60 (-27.71%)
Mutual labels:  reasonml
Revery Playground
Live, interactive playground for Revery examples
Stars: ✭ 14 (-83.13%)
Mutual labels:  reasonml
Restyled
Styled Components concept for Reason React, only works with bs-react-native for now
Stars: ✭ 68 (-18.07%)
Mutual labels:  reasonml
Reasonbizcharts
ReasonML binding for BizCharts https://bizcharts.net/products/bizCharts/demo
Stars: ✭ 23 (-72.29%)
Mutual labels:  reasonml
Reason App Shell Starter Kit
A simple App Shell starter kit that you can use to get started building your PWA with ReasonML & ReasonReact.
Stars: ✭ 49 (-40.96%)
Mutual labels:  reasonml
Introduce Reason Example
An example app made with Create React App which introduces a Reason component
Stars: ✭ 82 (-1.2%)
Mutual labels:  reasonml
Revery Terminal
Barebones terminal emulator built with ReasonML + Revery + libvterm
Stars: ✭ 76 (-8.43%)
Mutual labels:  reasonml
Cactus
🌵A composable static site generator
Stars: ✭ 63 (-24.1%)
Mutual labels:  reasonml

bs-glamor – BuckleScript bindings for glamor

The API is still experimental. Only a few functions from glamor such as css and global are exposed; other functions such as renderStatic are not supported yet.

Installation

npm install --save bs-glamor

In your bsconfig.json, include "bs-glamor" in the bs-dependencies.

Usage

The following examples (in Reason syntax) assume that Glamor is included in the namespace:

open Glamor;
  • Simple styling:

    css([
        color("red"),
        border("1px solid black")
    ])
    
  • Styling with selectors (@media, :hover, &, etc.):

    css([
        color("red"),
        Selector("@media (min-width: 300px)", [
            color("green")
        ])
    ])
    
  • Selectors can be nested:

    css([
        color("red"),
        Selector("@media (min-width: 300px)", [
            color("green"),
            Selector("& .foo", [
                color("blue")
            ])
        ])
    ])
    

You can isolate inclusion of the Glamor namespace in the following way:

Glamor.(css([color("red")]))

The result of the css function can be assigned to a class name, e.g. in JSX:

<div className=(css([color("red")])) />

You can also combine stylings with a class names. For example, if you want to use some classes from third-party libraries (e.g. Bootstrap), or just to add a class name for testing purposes along with glamor styles:

<div className=("btn " ^ css([color("red")])) />

Merging CSS rules

You can merge CSS rules using merge:

let text_primary = css([color("indigo")]);
let small = css([fontSize("10px")]);

<p className=(merge([text_primary, small])) />

glamor will make sure that rules are merged in the correct order, managing nesting and precedence for you.

Global CSS

You can define global CSS rules with global:

Glamor.(global("body", [margin("0px")]));
Glamor.(global("h1, h2, h3", [color("palegoldenrod")]));

Keyframes

Define animation keyframes:

let bounce = Glamor.keyframes([
  ("0%", [transform("scale(0.1)"), opacity("0")]),
  ("60%", [transform("scale(1.2)"), opacity("1")]),
  ("100%", [transform("scale(1)")])
]);
let styles = css([
    animationName(bounce),
    animationDuration("2s"),
    width("50px"),
    height("50px"),
    backgroundColor("red")
]);

<div className=styles>bounce!</div>

Example

See reason-react-tictactoe for a live example.

Development

npm run start

Tests

There are some simplistic tests using bs-jest.

npm run test

Thanks

Thanks to reason-react-example, reason-react, and bs-jest for inspiration how to create a Reason library, and of course, thanks to glamor.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].