Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upDocumentation: Add documentation for creating a custom component #118
Comments
bryphe
added
help wanted
good first issue
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
idkjs
commented
Jan 4, 2019
|
Starting from the oldest "help wanted/good first issue" item. So to demonstrate a custom component, I removed module Logo from open Revery.Math;
open Revery.UI;
module Logo = (
val component((render, ~children, ()) =>
render(
() => {
let (opacity, setOpacity) = useState(1.0);
let onMouseDown = _ => setOpacity(0.5);
let onMouseUp = _ => setOpacity(1.0);
let rotation =
useAnimation(
Animated.floatValue(0.),
{
toValue: 6.28,
duration: Seconds(8.),
delay: Seconds(1.0),
repeat: true,
easing: Animated.linear,
},
);
let rotationY =
useAnimation(
Animated.floatValue(0.),
{
toValue: 6.28,
duration: Seconds(4.),
delay: Seconds(0.5),
repeat: true,
easing: Animated.linear,
},
);
<view onMouseDown onMouseUp>
<image
src="outrun-logo.png"
style={Style.make(
~width=512,
~height=256,
~opacity,
~transform=[
RotateY(Angle.from_radians(rotationY)),
RotateX(Angle.from_radians(rotation)),
],
(),
)}
/>
</view>;
},
~children,
)
)
);I then call it in Hello.re like so: module Logo1 = Logo.Logo;
let init = app => {
let win = App.createWindow(app, "Welcome to Revery!");
let render = () =>
<view
style={Style.make(
~position=LayoutTypes.Absolute,
~justifyContent=LayoutTypes.JustifyCenter,
~alignItems=LayoutTypes.AlignCenter,
~bottom=0,
~top=0,
~left=0,
~right=0,
(),
)}>
<Logo1 />
<Logo />
<view
ref={r => print_endline("View internal id:" ++ string_of_int(r#getInternalId()))}
style={Style.make(~flexDirection=Row, ~alignItems=AlignFlexEnd, ())}>
<AnimatedText delay=0.0 textContent="Welcome" />
<AnimatedText delay=0.5 textContent="to" />
<AnimatedText delay=1. textContent="Revery" />
</view>
<SimpleButton />
</view>;
UI.start(win, render);
};
App.start(init);
|
This comment has been minimized.
This comment has been minimized.
|
Thanks @idkjs for looking at this! Hmm, as long as Looking at the code above - |
This comment has been minimized.
This comment has been minimized.
|
I created a branch that compiles for me that might be helpful: I showed two ways of including a module:
Hope that helps! |
This comment has been minimized.
This comment has been minimized.
idkjs
commented
Jan 5, 2019
|
No Joy. I cp'd your example into the project on local machine. These are the files:https://gist.github.com/idkjs/266d19f2286cdfdf026d58714fef3b76. I get the same error on Logo.Logo. Feels like a set up thing. Incidentally, what is the equivalent of Of note, Clock.re, line 8(let ui = UI.create(w);) is not compiling though i didn' |
This comment has been minimized.
This comment has been minimized.
idkjs
commented
Jan 5, 2019
•
|
Logo is unbound whether I do I redownloaded repo, |
This comment has been minimized.
This comment has been minimized.
|
Ah when using |
This comment has been minimized.
This comment has been minimized.
albertorestifo
commented
Feb 13, 2019
|
Is anyone working on a PR for this? |
This comment has been minimized.
This comment has been minimized.
idkjs
commented
Feb 14, 2019
|
Got away from me. Do we still need this? I will do it, if so. |
This comment has been minimized.
This comment has been minimized.
|
Hey @albertorestifo @idkjs ! Thanks for your help with this. I don't think anyone has started this yet - just don't want you to both duplicate the work Note that the syntax has changed a bit (we just updated to the latest brisk) - a good example of lots of custom components are in the Calculator example, if that helps: Line 8 in b6048e2 |


bryphe commentedDec 19, 2018
We currently support custom components (with hooks even!) - some examples in the code:
https://github.com/bryphe/revery/blob/711a90a0b19af2f39dd984cb1570a1231e745365/examples/Bin.re#L50
https://github.com/bryphe/revery/blob/711a90a0b19af2f39dd984cb1570a1231e745365/examples/Bin.re#L6
However, our documentation just says
TODO. We should put a simple example there and detail the 'anatomy' of a custom component, so that it is more accessible.