Skip to content

Instantly share code, notes, and snippets.

@phated
Created October 5, 2018 22:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phated/860489201b34e78212388bd9aaf1f4de to your computer and use it in GitHub Desktop.
Save phated/860489201b34e78212388bd9aaf1f4de to your computer and use it in GitHub Desktop.
Experimenting with a Reason API for Emotion
open BsReactNative;
[@bs.deriving abstract]
type style = {
[@bs.optional]
color: string,
[@bs.optional]
fontSize: float,
[@bs.optional]
margin: float,
[@bs.optional]
fontWeight: string,
[@bs.optional]
flex: float,
};
module type TextComponent = {include Text.TextComponent;};
module type Styled = {let style: style;};
module Text = (Styled: Styled) : TextComponent => {
[@bs.module "@emotion/native"] [@bs.scope "default"]
external component: style => ReasonReact.reactClass = "Text";
include Text.CreateComponent({
let view = component(Styled.style);
});
};
include Emotion.Text({
let style =
Emotion.style(
~color=Colors.white,
~fontSize=20.0,
~margin=8.0,
~fontWeight="700",
~flex=1.0,
(),
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment