-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pipe last instead of pipe first and remove Belt usage (#39)
- Loading branch information
Showing
5 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
module App = { | ||
// This sample forces an import of Belt.*, so that CI builds can ensure that | ||
// Melange has been installed correctly for JS bundlers to be able to find it. | ||
let style = | ||
ReactDOM.Style.make(~fontSize="1.5em", ~display="flex", ~gap="0.5em", ()); | ||
|
||
[@react.component] | ||
let make = () => | ||
["Hello " ++ World.name ++ "!", "This is React!"] | ||
->Belt.List.map(greeting => <h1 key={greeting}> greeting->React.string </h1>) | ||
->Belt.List.toArray | ||
->React.array; | ||
<div> | ||
<h1> {React.string("melange-opam-template")} </h1> | ||
{["Hello " ++ World.name ++ "!", "This is ReasonReact!"] | ||
|> List.map(text => | ||
<div key=text style> | ||
{React.string(text)} | ||
<button | ||
onClick={_ => text |> Speech.makeUtterance |> Speech.speak}> | ||
{React.string("speak")} | ||
</button> | ||
</div> | ||
) | ||
|> Array.of_list | ||
|> React.array} | ||
</div>; | ||
}; | ||
|
||
switch (ReactDOM.querySelector("#root")) { | ||
| Some(element) => | ||
let root = ReactDOM.Client.createRoot(element); | ||
ReactDOM.Client.render(root, <App />); | ||
| None => | ||
Js.Console.error("Failed to start React: couldn't find the #root element") | ||
}; | ||
let () = | ||
switch (ReactDOM.querySelector("#root")) { | ||
| None => | ||
Js.Console.error("Failed to start React: couldn't find the #root element") | ||
| Some(element) => | ||
let root = ReactDOM.Client.createRoot(element); | ||
ReactDOM.Client.render(root, <App />); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* Simplest possible bindings for speech synthesis API */ | ||
|
||
type utterance; | ||
|
||
[@mel.new] | ||
external makeUtterance: string => utterance = "SpeechSynthesisUtterance"; | ||
|
||
external speak: utterance => unit = "speechSynthesis.speak"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.