Skip to content

Commit 2ef7a5c

Browse files
committed
Apply review requested changes
1 parent 78470b4 commit 2ef7a5c

22 files changed

+71
-231
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ yarn-debug.log*
4949
.yarn-integrity
5050

5151
lib/bs
52+
53+
client/app/bundles/comments/src/**/*.bs.mjs

app/views/pages/rescript.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<%= react_component "RescriptPage" %>
1+
<%= react_component "RescriptShow", prerender: false %>

client/app/bundles/comments/src/Actions/Actions.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ module Fetch = {
3232
comments: comments
3333
}
3434

35-
let fetchComments = async (): result<comments, Types.errorT> => {
36-
open Json.Decode;
35+
let fetchComments = async (): result<comments, Types.error> => {
36+
open Json.Decode
3737

3838
let response = await Fetch.get("comments.json")
3939
let jsonRes = await response->Fetch.Response.json
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
type formDisplayT = HorizontalForm | InlineForm | StackedFrom;
1+
type formDisplay = Horizontal | Inline | Stacked
22

3-
type commentFormStateT = {
3+
type commentFormState = {
44
author: string,
55
text: string,
6-
form: formDisplayT
6+
form: formDisplay
77
}
88

9-
type commentFormActionT =
9+
type commentFormAction =
1010
| SetAuthor(string)
1111
| SetText(string)
12-
| SetFormType(formDisplayT);
12+
| SetFormType(formDisplay)
1313

14-
type formDataT = {
14+
type formData = {
1515
formName: string,
16-
formType: formDisplayT
17-
};
16+
formType: formDisplay
17+
}
1818

19-
type storeCommentActionT = (string, string) => unit;
19+
type storeCommentAction = (string, string) => unit
2020

21-
type storeCommentDataT = {
21+
type storeCommentData = {
2222
author: string,
2323
text: string
2424
}
2525

26-
type errorT = NoError | FailedToSaveComment | FailedToFetchComments;
26+
type error = NoError | FailedToSaveComment | FailedToFetchComments
2727

28-
type isSavingT = Free | BusySaving;
28+
type isSaving = Free | BusySaving

client/app/bundles/comments/src/CommentForm/CommentForm.bs.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function CommentForm(props) {
4141
var match = React.useReducer(reducer, {
4242
author: "",
4343
text: "",
44-
form: /* HorizontalForm */0
44+
form: /* Horizontal */0
4545
});
4646
var dispatch = match[1];
4747
var state = match[0];
@@ -66,21 +66,21 @@ function CommentForm(props) {
6666
var forms = [
6767
{
6868
formName: "Horizontal Form",
69-
formType: /* HorizontalForm */0
69+
formType: /* Horizontal */0
7070
},
7171
{
7272
formName: "Inline Form",
73-
formType: /* InlineForm */1
73+
formType: /* Inline */1
7474
},
7575
{
7676
formName: "Stacked Form",
77-
formType: /* StackedFrom */2
77+
formType: /* Stacked */2
7878
}
7979
];
8080
var match$1 = state.form;
8181
var tmp;
8282
switch (match$1) {
83-
case /* HorizontalForm */0 :
83+
case /* Horizontal */0 :
8484
tmp = JsxRuntime.jsx(HorizontalForm.make, {
8585
author: state.author,
8686
handleAuthorChange: handleAuthorChange,
@@ -90,7 +90,7 @@ function CommentForm(props) {
9090
isSaving: isSaving
9191
});
9292
break;
93-
case /* InlineForm */1 :
93+
case /* Inline */1 :
9494
tmp = JsxRuntime.jsx(InlineForm.make, {
9595
author: state.author,
9696
handleAuthorChange: handleAuthorChange,
@@ -100,7 +100,7 @@ function CommentForm(props) {
100100
isSaving: isSaving
101101
});
102102
break;
103-
case /* StackedFrom */2 :
103+
case /* Stacked */2 :
104104
tmp = JsxRuntime.jsx(StackedFrom.make, {
105105
author: state.author,
106106
handleAuthorChange: handleAuthorChange,

client/app/bundles/comments/src/CommentForm/CommentForm.res

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
@module("./CommentForm.module.scss") external css: {..} = "default"
22

33
let reducer = (
4-
state: Types.commentFormStateT,
5-
action: Types.commentFormActionT
6-
): Types.commentFormStateT => {
4+
state: Types.commentFormState,
5+
action: Types.commentFormAction
6+
): Types.commentFormState => {
77
switch (action) {
88
| SetAuthor(author) => {...state, author}
99
| SetText(text) => {...state, text}
1010
| SetFormType(form) => {...state, form: form}
11-
};
11+
}
1212
}
1313

1414

1515
@react.component
16-
let make = (~storeComment: Types.storeCommentActionT, ~isSaving: Types.isSavingT) => {
16+
let make = (~storeComment: Types.storeCommentAction, ~isSaving: Types.isSaving) => {
1717
let (state, dispatch) = React.useReducer(
1818
reducer, {
1919
author: "",
2020
text: "",
21-
form: HorizontalForm
21+
form: Horizontal
2222
}
2323
)
2424

@@ -37,11 +37,11 @@ let make = (~storeComment: Types.storeCommentActionT, ~isSaving: Types.isSavingT
3737
storeComment(state.author, state.text)
3838
}
3939

40-
let forms: array<Types.formDataT> =
40+
let forms: array<Types.formData> =
4141
[
42-
{formName: "Horizontal Form", formType: HorizontalForm},
43-
{formName: "Inline Form", formType: InlineForm},
44-
{formName: "Stacked Form", formType: StackedFrom}
42+
{formName: "Horizontal Form", formType: Horizontal},
43+
{formName: "Inline Form", formType: Inline},
44+
{formName: "Stacked Form", formType: Stacked}
4545
]
4646

4747
<div>
@@ -65,7 +65,7 @@ let make = (~storeComment: Types.storeCommentActionT, ~isSaving: Types.isSavingT
6565
<hr />
6666
{
6767
switch state.form {
68-
| HorizontalForm
68+
| Horizontal
6969
=> <HorizontalForm
7070
author={state.author}
7171
handleAuthorChange
@@ -74,7 +74,7 @@ let make = (~storeComment: Types.storeCommentActionT, ~isSaving: Types.isSavingT
7474
handleSubmit
7575
isSaving
7676
/>
77-
| StackedFrom
77+
| Stacked
7878
=> <StackedFrom
7979
author={state.author}
8080
handleAuthorChange
@@ -83,7 +83,7 @@ let make = (~storeComment: Types.storeCommentActionT, ~isSaving: Types.isSavingT
8383
handleSubmit
8484
isSaving
8585
/>
86-
| InlineForm
86+
| Inline
8787
=> <InlineForm
8888
author={state.author}
8989
handleAuthorChange

client/app/bundles/comments/src/CommentForm/forms/HorizontalForm.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let make = (
55
~text,
66
~handleTextChange,
77
~handleSubmit,
8-
~isSaving: Types.isSavingT
8+
~isSaving: Types.isSaving
99
) => {
1010
<form className="form-horizontal" onSubmit=handleSubmit disabled={isSaving == BusySaving}>
1111
<div className="form-group">

client/app/bundles/comments/src/CommentForm/forms/InlineForm.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let make = (
55
~text,
66
~handleTextChange,
77
~handleSubmit,
8-
~isSaving: Types.isSavingT
8+
~isSaving: Types.isSaving
99
) => {
1010
<form className="form-inline" onSubmit=handleSubmit disabled={isSaving == BusySaving} >
1111
<div className="form-group">

client/app/bundles/comments/src/CommentForm/forms/StackedFrom.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let make = (
55
~text,
66
~handleTextChange,
77
~handleSubmit,
8-
~isSaving: Types.isSavingT
8+
~isSaving: Types.isSaving
99
) => {
1010
<form onSubmit=handleSubmit disabled={isSaving == BusySaving}>
1111
<div className="form-group">

client/app/bundles/comments/src/CommentList/AlertError/AlertError.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@react.component
2-
let make = (~cssTransitionGroupClassNames: CSSAnimation.CSSTransition.t, ~error: Types.errorT) => {
2+
let make = (~cssTransitionGroupClassNames: CSSAnimation.CSSTransition.t, ~error: Types.error) => {
33
let nodeRef = React.useRef(Js.Nullable.null)
44

55
switch error {
66
| FailedToSaveComment =>
77
// The 500 must correspond to the 0.5s in:
8-
// ../../RescriptPage.module.scss:9
8+
// ../../RescriptShow.module.scss:9
99
<CSSAnimation.CSSTransition
1010
key="commentFetchError"
1111
nodeRef={nodeRef}
@@ -18,7 +18,7 @@ let make = (~cssTransitionGroupClassNames: CSSAnimation.CSSTransition.t, ~error:
1818
</CSSAnimation.CSSTransition>
1919
| FailedToFetchComments =>
2020
// The 500 must correspond to the 0.5s in:
21-
// ../../RescriptPage.module.scss:9
21+
// ../../RescriptShow.module.scss:9
2222
<CSSAnimation.CSSTransition
2323
key="commentFetchError"
2424
nodeRef={nodeRef}

client/app/bundles/comments/src/CommentList/Comment/Comment.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let make = (~comment: Actions.Fetch.t, ~cssTransitionGroupClassNames) => {
77
let nodeRef = React.useRef(Js.Nullable.null)
88

99
// The 500 must correspond to the 0.5s in:
10-
// ../../RescriptPage.module.scss:9
10+
// ../../RescriptShow.module.scss:9
1111
<CSSAnimation.CSSTransition
1212
key={"component_" ++ Belt.Int.toString(comment.id) }
1313
timeout={500}

client/app/bundles/comments/src/CommentList/CommentList.bs.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import * as AlertError from "./AlertError/AlertError.bs.mjs";
55
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
66
import * as JsxRuntime from "react/jsx-runtime";
77
import * as ReactTransitionGroup from "react-transition-group";
8-
import RescriptPageModuleScss from "../RescriptPage.module.scss";
8+
import RescriptShowModuleScss from "../RescriptShow.module.scss";
99

10-
var css = RescriptPageModuleScss;
10+
var css = RescriptShowModuleScss;
1111

1212
function CommentList(props) {
1313
var cssTransitionGroupClassNames_enter = css.elementEnter;

client/app/bundles/comments/src/CommentList/CommentList.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@module("../RescriptPage.module.scss") external css: {..} = "default"
1+
@module("../RescriptShow.module.scss") external css: {..} = "default"
22

33
@react.component
4-
let make = (~comments: Actions.Fetch.comments, ~error: Types.errorT) => {
4+
let make = (~comments: Actions.Fetch.comments, ~error: Types.error) => {
55
let cssTransitionGroupClassNames: CSSAnimation.CSSTransition.t = {
66
enter: css["elementEnter"],
77
enterActive: css["elementEnterActive"],

client/app/bundles/comments/src/RescriptPage.res renamed to client/app/bundles/comments/src/ReScriptShow.res

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
type rescriptPageStateT = {
1+
type state = {
22
comments: Actions.Fetch.comments,
3-
error: Types.errorT,
4-
isSaving: Types.isSavingT
3+
error: Types.error,
4+
isSaving: Types.isSaving
55
}
66

7-
type rescriptPageActionT =
7+
type action =
88
| SetComments(Actions.Fetch.comments)
9-
| SetError(Types.errorT)
10-
| SetIsSaving(Types.isSavingT)
9+
| SetError(Types.error)
10+
| SetIsSaving(Types.isSaving)
1111

1212

1313
let reducer = (
14-
state: rescriptPageStateT,
15-
action: rescriptPageActionT
16-
): rescriptPageStateT => {
14+
state: state,
15+
action: action
16+
): state => {
1717
switch (action) {
1818
| SetComments(comments) => {...state, comments}
1919
| SetError(error) => {...state, error}
2020
| SetIsSaving(isSaving) => {...state, isSaving}
21-
};
21+
}
2222
}
2323

2424
@react.component
25-
let make = () => {
25+
let default = () => {
2626
let (state, dispatch) = React.useReducer(
2727
reducer, {
2828
comments: ([]: Actions.Fetch.comments),
@@ -53,12 +53,12 @@ let make = () => {
5353

5454
React.useEffect1((_) => {
5555
let fetchData = async () => {
56-
let comments = await Actions.Fetch.fetchComments();
56+
let comments = await Actions.Fetch.fetchComments()
5757
switch comments {
5858
| Ok(comments) => SetComments(comments)->dispatch
5959
| Error(e) => SetError(e)->dispatch
6060
}
61-
};
61+
}
6262

6363
fetchData()->ignore
6464
None
@@ -80,5 +80,3 @@ let make = () => {
8080
</div>
8181
</>
8282
}
83-
84-
let default = make

0 commit comments

Comments
 (0)