Skip to content
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

add input component and example #205

Merged
merged 20 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Examples.re
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ let state: state = {
{name: "Box Shadow", render: _ => Boxshadow.render()},
{name: "Focus", render: _ => Focus.render()},
{name: "Stopwatch", render: _ => Stopwatch.render()},
{name: "Input", render: w => InputExample.render(w)},
],
selectedExample: "Animation",
};

let noop = () => ();

let getRenderFunctionSelector: (state, Window.t) => React.syntheticElement =
(s: state) => {
(s: state) =>
List.filter(x => String.equal(x.name, s.selectedExample), state.examples)
|> List.hd
|> (a => a.render);
};

module ExampleButton = {
let component = React.component("ExampleButton");
Expand Down
70 changes: 70 additions & 0 deletions examples/InputExample.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
open Revery.UI;
open Revery.Core;
open Revery.UI.Components;

let containerStyle =
Style.make(
~position=LayoutTypes.Absolute,
~top=0,
~bottom=0,
~left=0,
~right=0,
~alignItems=LayoutTypes.AlignCenter,
~justifyContent=LayoutTypes.JustifyCenter,
~flexDirection=LayoutTypes.Column,
~backgroundColor=Colors.white,
(),
);

module Example = {
type inputFields = {
first: string,
second: string,
};
let textStyles =
Style.make(
~fontSize=30,
~fontFamily="Roboto-Regular.ttf",
~color=Colors.black,
~marginBottom=30,
(),
);
let component = React.component("Example");

let make = window =>
component(slots => {
let ({first, second}, setValue, _slots: React.Hooks.empty) =
React.Hooks.state({first: "", second: ""}, slots);
let customShadow =
Style.BoxShadow.make(
~xOffset=-5.,
~yOffset=2.,
~color=Colors.black,
~blurRadius=20.,
(),
);

<View style=containerStyle>
<Input
window
placeholder="Insert text here"
onChange={(~value) => setValue({first: value, second})}
/>
<Input
backgroundColor=Colors.paleVioletRed
color=Colors.white
margin=20
boxShadow=customShadow
window
placeholder="custom input"
placeholderColor=Colors.plum
onChange={(~value) => setValue({first, second: value})}
/>
</View>;
});

let createElement = (~window, ~children as _, ()) =>
React.element(make(window));
};

let render = window => <Example window />;
12 changes: 6 additions & 6 deletions src/Revery.re
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module Geometry = Revery_Geometry;
module Math = Revery_Math;
module Shaders = Revery_Shaders;
module UI = {
include Revery_UI;
include Revery_UI;

/*
Include Components such that consumers access it via:
Revery.UI.Components
*/
module Components = Revery_UI_Components;
/*
Include Components such that consumers access it via:
Revery.UI.Components
*/
module Components = Revery_UI_Components;
};
module App = Core.App;
module Window = Core.Window;
Expand Down
3 changes: 1 addition & 2 deletions src/UI_Components/Button.re
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let createElement =
~disabled=false,
~fontFamily="Roboto-Regular.ttf",
(),
) => {
) =>
React.element(
make(
~title,
Expand All @@ -76,4 +76,3 @@ let createElement =
(),
),
);
};
Loading