-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation: Add documentation for creating a custom component #118
Comments
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); |
Thanks @idkjs for looking at this! Hmm, as long as Looking at the code above - |
I created a branch that compiles for me that might be helpful: I showed two ways of including a module:
Hope that helps! |
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' |
Logo is unbound whether I do I redownloaded repo, |
Ah when using |
Is anyone working on a PR for this? |
Got away from me. Do we still need this? I will do it, if so. |
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
|
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.The text was updated successfully, but these errors were encountered: