-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98f0200
commit ba3007b
Showing
21 changed files
with
343 additions
and
419 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
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 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,35 +1,11 @@ | ||
let component = ReasonReact.statelessComponent("App"); | ||
|
||
module Styles = { | ||
open Css; | ||
|
||
let page = | ||
style([ | ||
display(flexBox), | ||
flexDirection(column), | ||
position(absolute), | ||
top(px(0)), | ||
bottom(px(0)), | ||
left(px(0)), | ||
right(px(0)), | ||
padding(px(20)), | ||
]); | ||
|
||
let side = | ||
style([ | ||
display(flexBox), | ||
flexDirection(column), | ||
alignItems(center), | ||
flexBasis(pct(50.)), | ||
firstChild([justifyContent(flexEnd)]), | ||
]); | ||
}; | ||
|
||
let make = _children => { | ||
...component, | ||
render: _self => | ||
<div className=Styles.page> | ||
<section className=Styles.side> <Logo /> </section> | ||
<section className=Styles.side> <Messages /> </section> | ||
</div>, | ||
}; | ||
[@react.component] | ||
let make = () => | ||
<div className=AppStyles.page> | ||
<svg | ||
viewBox="0 0 1000 1000" | ||
height="1000" | ||
width="1000" | ||
style={ReactDOMRe.Style.make(~border="1px solid blue", ())}> | ||
<Circles /> | ||
</svg> | ||
</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,15 @@ | ||
open Css; | ||
|
||
let page = | ||
style([ | ||
display(flexBox), | ||
flexDirection(column), | ||
alignItems(center), | ||
justifyContent(center), | ||
position(absolute), | ||
top(px(0)), | ||
bottom(px(0)), | ||
left(px(0)), | ||
right(px(0)), | ||
padding(px(20)), | ||
]); |
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,58 @@ | ||
open ReasonUrql; | ||
open Hooks; | ||
|
||
module SubscribeRandomInt = [%graphql | ||
{| | ||
subscription subscribeNumbers { | ||
newNumber @bsDecoder(fn: "string_of_int") | ||
} | ||
|} | ||
]; | ||
|
||
let handler = (~prevSubscriptions, ~subscription) => { | ||
switch (prevSubscriptions) { | ||
| Some(subs) => Array.append(subs, [|subscription|]) | ||
| None => [|subscription|] | ||
}; | ||
}; | ||
|
||
[@bs.scope "Math"] [@bs.val] external random: unit => float = "random"; | ||
[@bs.scope "Math"] [@bs.val] external floor: float => int = "floor"; | ||
[@bs.send] external toString: (int, int) => string = "toString"; | ||
|
||
let getRandomInt = (max: int) => { | ||
floor(random() *. float_of_int(max)); | ||
}; | ||
|
||
let getRandomHex = () => { | ||
let encode = random() *. float_of_int(16777215) |> floor; | ||
let hex = encode->toString(16); | ||
{j|#$hex|j}; | ||
}; | ||
|
||
[@react.component] | ||
let make = () => { | ||
let {response} = | ||
useSubscriptionWithHandler(~request=SubscribeRandomInt.make(), ~handler); | ||
|
||
switch (response) { | ||
| Fetching => <text> "Loading"->React.string </text> | ||
| Data(d) => | ||
Array.mapi( | ||
(index, datum) => | ||
<circle | ||
cx={ | ||
datum##newNumber; | ||
} | ||
cy={index === 0 ? datum##newNumber : d[index - 1]##newNumber} | ||
stroke={getRandomHex()} | ||
fill="none" | ||
r={getRandomInt(30) |> string_of_int} | ||
/>, | ||
d, | ||
) | ||
|> React.array | ||
| Error(_e) => <text> "Error"->React.string </text> | ||
| NotFound => <text> "Not Found"->React.string </text> | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.