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

Enhance comment forms #604

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ let make = (~fetchData) => {
disabled
/>
| Stacked =>
<StackedFrom
<StackedForm
author={state.author}
handleAuthorChange
text={state.text}
Expand All @@ -146,4 +146,4 @@ let make = (~fetchData) => {
| Saving => React.null
}}
</div>
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
@react.component
let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmit, ~disabled) => {
<form className="form-horizontal flex flex-col gap-4" onSubmit=handleSubmit disabled>
<form
className="form-horizontal flex flex-col gap-4"
onSubmit=handleSubmit
disabled={disabled}
ariaLabel="Comment submission form">
<div className="flex flex-col gap-0 items-center lg:gap-4 lg:flex-row">
<label className="w-full lg:w-2/12 lg:text-end shrink-0"> {"Name"->React.string} </label>
<label htmlFor="comment_author" className="w-full lg:w-2/12 lg:text-end shrink-0">
{"Name"->React.string}
</label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded w-full"
Expand All @@ -11,10 +17,14 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_author"
onChange=handleAuthorChange
value={author}
ariaLabel="Author name"
ariaRequired=true
/>
</div>
<div className="flex flex-col gap-0 items-center lg:gap-4 lg:flex-row">
<label className="w-full lg:w-2/12 lg:text-end shrink-0"> {"Text"->React.string} </label>
<label htmlFor="comment_text" className="w-full lg:w-2/12 lg:text-end shrink-0">
{"Text"->React.string}
</label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded w-full"
Expand All @@ -23,6 +33,8 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_text"
onChange=handleTextChange
value={text}
ariaLabel="Comment text"
ariaRequired=true
/>
</div>
<div className="flex flex-col gap-0 lg:gap-4 lg:flex-row">
Expand All @@ -31,7 +43,8 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
type_="submit"
className="self-start px-3 py-1 font-semibold border-0 rounded text-sky-50 bg-sky-600 hover:bg-sky-800"
value="Post"
ariaLabel="Submit comment"
/>
</div>
</form>
}
}
ihab4real marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
<form
className="form-inline flex flex-col lg:flex-row flex-wrap gap-4"
onSubmit=handleSubmit
disabled>
disabled={disabled}
ariaLabel="Comment submission form">
<div className="flex gap-2 items-center">
<label> {"Name"->React.string} </label>
<label htmlFor="comment_author"> {"Name"->React.string} </label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded"
Expand All @@ -14,10 +15,12 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_author"
value={author}
onChange=handleAuthorChange
ariaLabel="Author name"
ariaRequired=true
/>
</div>
<div className="flex gap-2 items-center">
<label> {"Text"->React.string} </label>
<label htmlFor="comment_text"> {"Text"->React.string} </label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded"
Expand All @@ -26,15 +29,17 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_text"
onChange=handleTextChange
value={text}
ariaLabel="Comment text"
ariaRequired=true
/>
</div>
<div className="flex gap-2">
<input
type_="submit"
className="self-start px-3 py-1 font-semibold border-0 rounded text-sky-50 bg-sky-600 hover:bg-sky-800"
onSubmit=handleSubmit
value="Post"
ariaLabel="Submit comment"
/>
</div>
</form>
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
@react.component
let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmit, ~disabled) => {
<form onSubmit=handleSubmit disabled className="flex flex-col gap-4">
<form
onSubmit=handleSubmit
disabled={disabled}
className="flex flex-col gap-4"
ariaLabel="Comment submission form">
<div className="flex flex-col gap-0">
<label className="w-full"> {"Name"->React.string} </label>
<label htmlFor="comment_author" className="w-full"> {"Name"->React.string} </label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded w-full"
Expand All @@ -11,10 +15,12 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_author"
onChange=handleAuthorChange
value={author}
ariaLabel="Author name"
ariaRequired=true
/>
</div>
<div className="flex flex-col gap-0">
<label className="w-full"> {"Name"->React.string} </label>
<label htmlFor="comment_text" className="w-full"> {"Text"->React.string} </label>
<input
type_="text"
className="px-3 py-1 leading-4 border border-gray-300 rounded w-full"
Expand All @@ -23,15 +29,17 @@ let make = (~author, ~handleAuthorChange, ~text, ~handleTextChange, ~handleSubmi
id="comment_text"
onChange=handleTextChange
value={text}
ariaLabel="Comment text"
ariaRequired=true
/>
</div>
<div className="flex flex-col gap-0">
<input
type_="submit"
className="self-start px-3 py-1 font-semibold border-0 rounded text-sky-50 bg-sky-600 hover:bg-sky-800"
onSubmit=handleSubmit
value="Post"
ariaLabel="Submit comment"
/>
</div>
</form>
}
}
Loading