Skip to content

Instantly share code, notes, and snippets.

@fponticelli
Last active March 13, 2016 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fponticelli/5da78e480645a958148d to your computer and use it in GitHub Desktop.
Save fponticelli/5da78e480645a958148d to your computer and use it in GitHub Desktop.
brainstorm on typed component styling
import doom.Html.*;
class Button extends doom.html.Component<ButtonPropps> {
override function render() {
return button([
"class" => props.status,
"click" => props.trigger
], children);
}
}
typedef ButtonProps = {
status : ButtonStatus,
trigger : Void -> Void
}
class ButtonStyles = {
public static var styles = Styles.create({
control : {
border : "1px solid black",
borderRadius : "4px",
fontSize: "14px",
padding: "2px 4px"
}
});
public static var status = Styles.oneOf("ButtonStatus", {
normal : {
composes : styles.control
},
disabled : {
composes : status.normal,
color: "#ccc"
},
error : {
composes : status.normal,
color: "#f60"
},
loading : {
color: "#06f"
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment