-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert project to reason-react v0.7.0 and JSX 3 syntax
- Simplify components - Switch to Parcel - Switch to bs-css for styling
- Loading branch information
Showing
64 changed files
with
5,809 additions
and
5,859 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
node_modules | ||
|
||
# Build | ||
src/**/*.js | ||
.cache | ||
dist | ||
lib | ||
.bsb.lock | ||
.merlin | ||
**/*.bs.js | ||
|
||
# Logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,84 @@ | ||
let component = ReasonReact.statelessComponent("App"); | ||
module Styles = { | ||
open Css; | ||
|
||
let className: string = | ||
Styles.make( | ||
~alignItems="center", | ||
~display="flex", | ||
~flexDirection="column", | ||
() | ||
) |> Styles.className; | ||
let buttons = | ||
style([ | ||
display(`flex), | ||
selector( | ||
"&:last-of-type", | ||
[ | ||
selector( | ||
"& :first-of-type", | ||
[ | ||
flexBasis(pct(50.)), | ||
paddingLeft(em(0.9)), | ||
textAlign(`left), | ||
], | ||
), | ||
], | ||
), | ||
]); | ||
|
||
let make = (~state as { Store.operations }, ~dispatch, _children) => { | ||
let output = Operation.getInput(operations); | ||
let calculator = | ||
style([ | ||
background(hex("838383")), | ||
borderRadius(px(5)), | ||
overflow(hidden), | ||
width(em(14.)), | ||
]); | ||
|
||
{ | ||
...component, | ||
render: _self => | ||
<main className> | ||
<Hero /> | ||
<Calculator> | ||
<Display output /> | ||
<Buttons dispatch /> | ||
</Calculator> | ||
</main> | ||
}; | ||
let container = | ||
style([alignItems(`center), display(`flex), flexDirection(`column)]); | ||
|
||
let display = | ||
style([ | ||
alignItems(center), | ||
color(hex("fafafa")), | ||
display(`flex), | ||
fontSize(em(1.5)), | ||
height(em(2.5)), | ||
justifyContent(flexEnd), | ||
padding2(~v=zero, ~h=em(1.)), | ||
]); | ||
}; | ||
|
||
[@react.component] | ||
let make = () => { | ||
let display = Store.useDisplay(); | ||
|
||
<div className=Styles.container> | ||
<Hero /> | ||
<div className=Styles.calculator> | ||
<div className=Styles.display> display->React.string </div> | ||
<div className=Styles.buttons> | ||
<Button action=Clear text="C" /> | ||
<Button action=PosNeg text={js|+/\u2212|js} /> | ||
<Button action=Percent text="%" /> | ||
<Button action=Divide text={js|\u00f7|js} /> | ||
</div> | ||
<div className=Styles.buttons> | ||
<Button action="7"->Input text="7" /> | ||
<Button action="8"->Input text="8" /> | ||
<Button action="9"->Input text="9" /> | ||
<Button action=Multiply text={js|\u00d7|js} /> | ||
</div> | ||
<div className=Styles.buttons> | ||
<Button action="4"->Input text="4" /> | ||
<Button action="5"->Input text="5" /> | ||
<Button action="6"->Input text="6" /> | ||
<Button action=Subtract text={js|\u2212|js} /> | ||
</div> | ||
<div className=Styles.buttons> | ||
<Button action="1"->Input text="1" /> | ||
<Button action="2"->Input text="2" /> | ||
<Button action="3"->Input text="3" /> | ||
<Button action=Add text="+" /> | ||
</div> | ||
<div className=Styles.buttons> | ||
<Button action="0"->Input text="0" /> | ||
<Button action="."->Input text="." /> | ||
<Button action=Equals text="=" /> | ||
</div> | ||
</div> | ||
</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module Styles = { | ||
open Css; | ||
|
||
let container = | ||
merge([ | ||
style([ | ||
borderWidth(zero), | ||
borderRadius(zero), | ||
color(hex("fafafa")), | ||
cursor(`pointer), | ||
display(inlineBlock), | ||
flexBasis(pct(25.)), | ||
fontSize(em(1.5)), | ||
lineHeight(`abs(2.)), | ||
outlineStyle(none), | ||
transitions([ | ||
transition( | ||
~duration=300, | ||
~timingFunction=easeOut, | ||
"background-color", | ||
), | ||
transition(~duration=300, ~timingFunction=easeOut, "color"), | ||
]), | ||
hover([backgroundColor(hex("fafafa"))]), | ||
]), | ||
]); | ||
|
||
let variant = colorCode => | ||
style([ | ||
backgroundColor(hex(colorCode)), | ||
hover([color(hex(colorCode))]), | ||
]); | ||
|
||
let blue = variant("6d71ff"); | ||
let green = variant("3bf3a9"); | ||
let orange = variant("ff8754"); | ||
}; | ||
|
||
[@react.component] | ||
let make = (~action: Store.action, ~text) => { | ||
let color = | ||
switch (action) { | ||
| Clear | ||
| Percent | ||
| PosNeg => Styles.green | ||
| Add | ||
| Divide | ||
| Equals | ||
| Multiply | ||
| Subtract => Styles.orange | ||
| _ => Styles.blue | ||
}; | ||
|
||
let addOperation = Store.useAddOperation(); | ||
let onClick = React.useCallback(_ => addOperation(action)); | ||
|
||
<button className={Css.merge([Styles.container, color])} onClick> | ||
text->React.string | ||
</button>; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.