Makes use Antd components
This commit is contained in:
parent
6c6f1e151c
commit
95585fb43d
|
@ -1,4 +1,5 @@
|
||||||
open BsReform;
|
open BsReform;
|
||||||
|
open Antd.Grid;
|
||||||
|
|
||||||
module FormConfig = [%lenses
|
module FormConfig = [%lenses
|
||||||
type state = {
|
type state = {
|
||||||
|
@ -40,10 +41,20 @@ module FieldString = {
|
||||||
|
|
||||||
module Styles = {
|
module Styles = {
|
||||||
open Css;
|
open Css;
|
||||||
let row =
|
let rows =
|
||||||
style([display(`flex), selector("div > div", [flex(`num(1.))])]);
|
style([
|
||||||
|
selector(
|
||||||
|
">.ant-col:first-child",
|
||||||
|
[paddingLeft(em(0.25)), paddingRight(em(0.125))],
|
||||||
|
),
|
||||||
|
selector(
|
||||||
|
">.ant-col:last-child",
|
||||||
|
[paddingLeft(em(0.125)), paddingRight(em(0.25))],
|
||||||
|
),
|
||||||
|
]);
|
||||||
let form = style([backgroundColor(hex("eee")), padding(em(1.))]);
|
let form = style([backgroundColor(hex("eee")), padding(em(1.))]);
|
||||||
let spacer = style([marginTop(em(3.))]);
|
let dist = style([padding(em(1.))]);
|
||||||
|
let spacer = style([marginTop(em(1.))]);
|
||||||
};
|
};
|
||||||
|
|
||||||
module FieldFloat = {
|
module FieldFloat = {
|
||||||
|
@ -64,6 +75,26 @@ module FieldFloat = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module DemoDist = {
|
||||||
|
[@react.component]
|
||||||
|
let make = (~guesstimatorString, ~domain, ~unit) => {
|
||||||
|
<Antd.Card title={"Distribution" |> E.ste}>
|
||||||
|
<div className=Styles.spacer />
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
{DistPlusIngredients.make(~guesstimatorString, ~domain, ~unit, ())
|
||||||
|
|> DistPlusIngredients.toDistPlus(
|
||||||
|
~sampleCount=10000,
|
||||||
|
~outputXYPoints=2000,
|
||||||
|
~truncateTo=Some(1000),
|
||||||
|
)
|
||||||
|
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Antd.Card>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
[@react.component]
|
[@react.component]
|
||||||
let make = () => {
|
let make = () => {
|
||||||
let reform =
|
let reform =
|
||||||
|
@ -134,29 +165,36 @@ let make = () => {
|
||||||
|
|
||||||
let guesstimatorString = reform.state.values.guesstimatorString;
|
let guesstimatorString = reform.state.values.guesstimatorString;
|
||||||
|
|
||||||
|
let demoDist =
|
||||||
|
React.useMemo1(
|
||||||
|
() => {<DemoDist guesstimatorString domain unit />},
|
||||||
|
[|
|
||||||
|
reform.state.values.guesstimatorString,
|
||||||
|
reform.state.values.domainType,
|
||||||
|
reform.state.values.xPoint,
|
||||||
|
reform.state.values.xPoint2,
|
||||||
|
reform.state.values.xPoint2,
|
||||||
|
reform.state.values.excludingProbabilityMass,
|
||||||
|
reform.state.values.excludingProbabilityMass2,
|
||||||
|
reform.state.values.unitType,
|
||||||
|
reform.state.values.zero |> E.M.format(E.M.format_standard),
|
||||||
|
reform.state.values.unit,
|
||||||
|
|],
|
||||||
|
);
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className=Styles.spacer />
|
<div className=Styles.spacer />
|
||||||
<div>
|
demoDist
|
||||||
<div>
|
|
||||||
{DistPlusIngredients.make(~guesstimatorString, ~domain, ~unit, ())
|
|
||||||
|> DistPlusIngredients.toDistPlus(
|
|
||||||
~sampleCount=10000,
|
|
||||||
~outputXYPoints=2000,
|
|
||||||
~truncateTo=Some(1000),
|
|
||||||
)
|
|
||||||
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className=Styles.spacer />
|
<div className=Styles.spacer />
|
||||||
<div className=Styles.form>
|
<Antd.Card title={"Distribution Form" |> E.ste}>
|
||||||
<Form.Provider value=reform>
|
<Form.Provider value=reform>
|
||||||
<Antd.Form onSubmit>
|
<Antd.Form onSubmit>
|
||||||
<FieldString
|
<FieldString
|
||||||
field=FormConfig.GuesstimatorString
|
field=FormConfig.GuesstimatorString
|
||||||
label="Guesstimator String"
|
label="Guesstimator String"
|
||||||
/>
|
/>
|
||||||
<div className=Styles.row>
|
<Row _type=`flex>
|
||||||
<div>
|
<Col span=4>
|
||||||
<Form.Field
|
<Form.Field
|
||||||
field=FormConfig.DomainType
|
field=FormConfig.DomainType
|
||||||
render={({handleChange, value}) =>
|
render={({handleChange, value}) =>
|
||||||
|
@ -178,28 +216,36 @@ let make = () => {
|
||||||
</Antd.Form.Item>
|
</Antd.Form.Item>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
<Col span=10>
|
||||||
|
<Row _type=`flex className=Styles.rows>
|
||||||
|
<Col span=12>
|
||||||
<FieldString field=FormConfig.XPoint label="X-point" />
|
<FieldString field=FormConfig.XPoint label="X-point" />
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
<Col span=12>
|
||||||
<FieldString
|
<FieldString
|
||||||
field=FormConfig.ExcludingProbabilityMass
|
field=FormConfig.ExcludingProbabilityMass
|
||||||
label="Excluding Probability Mass"
|
label="Excluding Probability Mass"
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
</Row>
|
||||||
|
</Col>
|
||||||
|
<Col span=10>
|
||||||
|
<Row _type=`flex className=Styles.rows>
|
||||||
|
<Col span=12>
|
||||||
<FieldString field=FormConfig.XPoint2 label="X-point (2)" />
|
<FieldString field=FormConfig.XPoint2 label="X-point (2)" />
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
<Col span=12>
|
||||||
<FieldString
|
<FieldString
|
||||||
field=FormConfig.ExcludingProbabilityMass2
|
field=FormConfig.ExcludingProbabilityMass2
|
||||||
label="Excluding Probability Mass (2)"
|
label="Excluding Probability Mass (2)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
</div>
|
</Row>
|
||||||
<div className=Styles.row>
|
</Col>
|
||||||
<div>
|
</Row>
|
||||||
|
<Row _type=`flex>
|
||||||
|
<Col span=4>
|
||||||
<Form.Field
|
<Form.Field
|
||||||
field=FormConfig.UnitType
|
field=FormConfig.UnitType
|
||||||
render={({handleChange, value}) =>
|
render={({handleChange, value}) =>
|
||||||
|
@ -215,8 +261,10 @@ let make = () => {
|
||||||
</Antd.Form.Item>
|
</Antd.Form.Item>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
<Col span=10>
|
||||||
|
<Row _type=`flex className=Styles.rows>
|
||||||
|
<Col span=12>
|
||||||
<Form.Field
|
<Form.Field
|
||||||
field=FormConfig.Zero
|
field=FormConfig.Zero
|
||||||
render={({handleChange, value}) =>
|
render={({handleChange, value}) =>
|
||||||
|
@ -231,48 +279,19 @@ let make = () => {
|
||||||
</Antd.Form.Item>
|
</Antd.Form.Item>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
<div>
|
<Col span=12>
|
||||||
<Form.Field
|
<FieldString
|
||||||
field=FormConfig.Unit
|
field=FormConfig.ExcludingProbabilityMass
|
||||||
render={({handleChange, value}) =>
|
label="Excluding Probability Mass"
|
||||||
<Antd.Form.Item label={"Unit" |> E.ste}>
|
|
||||||
<Antd.Select value onChange={e => e |> handleChange}>
|
|
||||||
<Antd.Select.Option value="days">
|
|
||||||
{"days" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="hours">
|
|
||||||
{"hours" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="milliseconds">
|
|
||||||
{"milliseconds" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="minutes">
|
|
||||||
{"minutes" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="months">
|
|
||||||
{"months" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="quarters">
|
|
||||||
{"quarters" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="seconds">
|
|
||||||
{"seconds" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="weeks">
|
|
||||||
{"weeks" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
<Antd.Select.Option value="years">
|
|
||||||
{"years" |> E.ste}
|
|
||||||
</Antd.Select.Option>
|
|
||||||
</Antd.Select>
|
|
||||||
</Antd.Form.Item>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</Col>
|
||||||
</div>
|
</Row>
|
||||||
|
</Col>
|
||||||
|
<Col span=10 />
|
||||||
|
</Row>
|
||||||
</Antd.Form>
|
</Antd.Form>
|
||||||
</Form.Provider>
|
</Form.Provider>
|
||||||
</div>
|
</Antd.Card>
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user