Skip to content

Commit df17924

Browse files
committed
update version; refactor main API
1 parent 4adaff7 commit df17924

File tree

4 files changed

+48
-38
lines changed

4 files changed

+48
-38
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"author": "",
1616
"license": "MIT",
1717
"devDependencies": {
18-
"bs-platform": "^2.1.0",
18+
"bs-platform": "^3.1.5",
1919
"prettier": "^1.10.2"
2020
},
2121
"dependencies": {
22-
"reason-react": "^0.3.0"
22+
"reason-react": "^0.4.2"
2323
},
2424
"peerDependencies": {
2525
"@storybook/addon-actions": "^3.2.17",

src/knobs.re

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,57 @@
11
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
2-
external withKnobs : Main.decorator =
3-
"";
2+
external withKnobs : Main.decorator = "";
43

54
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
6-
external extText : (string, Js.null_undefined(string)) => string =
7-
"text";
5+
external extText : (string, Js.null_undefined(string)) => string = "text";
86

97
let text = (~label: string, ~defaultValue: option(string)=?, ()) =>
10-
extText(label, Js.Nullable.from_opt(defaultValue));
8+
extText(label, Js.Nullable.fromOption(defaultValue));
119

1210
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
13-
external extBoolean : (string, Js.boolean) => Js.boolean =
14-
"boolean";
11+
external extBoolean : (string, bool) => bool = "boolean";
1512

16-
let boolean = (~label: string, ~defaultValue=Js.false_, ()) =>
17-
Js.to_bool(extBoolean(label, defaultValue));
13+
let boolean = (~label: string, ~defaultValue=false, ()) =>
14+
extBoolean(label, defaultValue);
1815

1916
type jsRangeConfig = {
2017
.
21-
"range": Js.boolean, "min": float, "max": float, "step": float
18+
"range": bool,
19+
"min": float,
20+
"max": float,
21+
"step": float,
2222
};
2323

2424
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
25-
external extNumber : (string, float, Js.null_undefined(jsRangeConfig)) => float =
25+
external extNumber :
26+
(string, float, Js.null_undefined(jsRangeConfig)) => float =
2627
"number";
2728

2829
type rangeConfig = {
2930
min: float,
3031
max: float,
31-
step: float
32+
step: float,
3233
};
3334

3435
let number =
3536
(
3637
~label: string,
3738
~defaultValue=0.,
3839
~rangeConfiguration: option(rangeConfig)=?,
39-
()
40+
(),
4041
)
4142
: float =>
42-
switch rangeConfiguration {
43+
switch (rangeConfiguration) {
4344
| None => extNumber(label, defaultValue, Js.Nullable.undefined)
4445
| Some(c) =>
45-
let config = {
46-
"range": Js.true_,
47-
"min": c.min,
48-
"max": c.max,
49-
"step": c.step
50-
};
51-
extNumber(label, defaultValue, Js.Nullable.return(config))
46+
let config = {"range": true, "min": c.min, "max": c.max, "step": c.step};
47+
extNumber(label, defaultValue, Js.Nullable.return(config));
5248
};
5349

5450
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
55-
external extColor : (string, Js.null_undefined(string)) => string =
56-
"color";
51+
external extColor : (string, Js.null_undefined(string)) => string = "color";
5752

5853
let color = (~label: string, ~defaultValue: option(string)=?, ()) =>
59-
extColor(label, Js.Nullable.from_opt(defaultValue));
54+
extColor(label, Js.Nullable.fromOption(defaultValue));
6055

6156
type selectConfig('a) = 'a;
6257

@@ -70,19 +65,20 @@ let select =
7065
~label: string,
7166
~options: selectConfig('a),
7267
~defaultValue: option(string)=?,
73-
()
68+
(),
7469
) =>
75-
extSelect(label, options, Js.Nullable.from_opt(defaultValue));
70+
extSelect(label, options, Js.Nullable.fromOption(defaultValue));
7671

7772
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
78-
external extDate : (string, Js.null_undefined(Js_date.t)) => string =
79-
"date";
73+
external extDate : (string, Js.null_undefined(Js_date.t)) => string = "date";
8074

8175
let date = (~label: string, ~defaultValue: option(Js_date.t)=?, ()) =>
82-
extDate(label, Js.Nullable.from_opt(defaultValue));
76+
extDate(label, Js.Nullable.fromOption(defaultValue));
77+
78+
type button;
8379

8480
[@bs.val] [@bs.module "@storybook/addon-knobs/react"]
85-
external extButton : (string, ReactEventRe.Mouse.t => unit) => unit =
81+
external extButton : (string, ReactEventRe.Mouse.t => unit) => button =
8682
"button";
8783

8884
let button = (~label: string, ~handler: ReactEventRe.Mouse.t => unit, ()) =>

src/story.re

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
type section;
2+
3+
type webpackModule;
4+
5+
type chapter = unit => ReasonReact.reactElement;
6+
7+
type decorator = chapter => ReasonReact.reactElement;
8+
9+
[@bs.val] [@bs.module "@storybook/react"]
10+
external storiesOf : (string, webpackModule) => section = "";
11+
12+
[@bs.send] external add : (section, string, chapter) => section = "";
13+
14+
[@bs.send] external addDecorator : (section, decorator) => section = "";

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ asap@~2.0.3:
66
version "2.0.6"
77
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
88

9-
bs-platform@^2.1.0:
10-
version "2.2.2"
11-
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-2.2.2.tgz#95ff37719771bbf310e8376fedd1148865c0da19"
9+
bs-platform@^3.1.5:
10+
version "3.1.5"
11+
resolved "https://registry.yarnpkg.com/bs-platform/-/bs-platform-3.1.5.tgz#fb34ee4702bc9163848d5537096c4f31ebaeed40"
1212

1313
core-js@^1.0.0:
1414
version "1.2.7"
@@ -104,9 +104,9 @@ prop-types@^15.6.0:
104104
object-assign "^4.1.1"
105105
prop-types "^15.6.0"
106106

107-
reason-react@^0.3.0:
108-
version "0.3.2"
109-
resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.3.2.tgz#14574b619bd9bf2b6057d681867a5dfa69f2360f"
107+
reason-react@^0.4.2:
108+
version "0.4.2"
109+
resolved "https://registry.yarnpkg.com/reason-react/-/reason-react-0.4.2.tgz#690d34e3e91a2585cdc5f58384b6c8ff653c32c1"
110110
dependencies:
111111
react ">=15.0.0 || >=16.0.0"
112112
react-dom ">=15.0.0 || >=16.0.0"

0 commit comments

Comments
 (0)