Skip to content

Commit 718033e

Browse files
committed
Remove Util.ReactStuff and simplify other Util usages
1 parent 561b0f9 commit 718033e

40 files changed

+656
-694
lines changed

common/Util.js

Lines changed: 1 addition & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Util.res

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,9 @@ module Debounce = {
3939
}
4040
}
4141
}
42-
module ReactStuff = {
43-
let s = React.string
44-
let ate = React.array
4542

46-
module Unsafe = {
47-
external elementAsString: React.element => string = "%identity"
48-
}
49-
module Style = ReactDOM.Style
50-
51-
@bs.module("react")
52-
external lazy_: (unit => Js.Promise.t<'a>) => 'a = "lazy"
53-
54-
module Suspense = {
55-
@bs.module("react") @react.component
56-
external make: (~children: React.element) => React.element = "Suspense"
57-
}
43+
module Unsafe = {
44+
external elementAsString: React.element => string = "%identity"
5845
}
5946

6047
module String = {

components/AnsiPre.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/AnsiPre.res

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This file was automatically converted to ReScript from 'AnsiPre.re'
22
// Check the output and make sure to delete the original file
3-
open Util.ReactStuff
43
open Ansi
54

65
type colorTarget =
@@ -39,7 +38,7 @@ let renderSgrString = (~key: string, sgrStr: SgrString.t): React.element => {
3938
}
4039
)
4140

42-
<span key className> {content->s} </span>
41+
<span key className> {React.string(content)} </span>
4342
}
4443

4544
@react.component
@@ -50,5 +49,5 @@ let make = (~className=?, ~children: string) => {
5049
})
5150

5251
// Note: pre is essential here, otherwise whitespace and newlines are not respected
53-
<pre ?className> {spans->ate} </pre>
52+
<pre ?className> {React.array(spans)} </pre>
5453
}

components/CodeExample.js

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/CodeExample.res

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
open Util.ReactStuff
2-
31
let langShortname = (lang: string) =>
42
switch lang {
53
| "ocaml" => "ml"
@@ -17,7 +15,7 @@ let make = (~highlightedLines=[], ~code: string, ~showLabel=true, ~lang="text")
1715
let label = if showLabel {
1816
let label = langShortname(lang)
1917
<div className="flex self-end font-sans mb-4 text-sm font-bold text-night-light px-4">
20-
{Js.String2.toUpperCase(label)->s}
18+
{Js.String2.toUpperCase(label)->React.string}
2119
</div>
2220
} else {
2321
<div className="mt-4" />
@@ -85,7 +83,7 @@ module Toggle = {
8583
(" flex-none px-4 inline-block p-2 bg-gray-10 rounded-tl rounded-tr " ++
8684
activeClass)}
8785
onClick>
88-
{label->s}
86+
{React.string(label)}
8987
</span>
9088
})
9189

@@ -97,8 +95,8 @@ module Toggle = {
9795
<div className="flex w-full flex-col rounded-none text-night-dark">
9896
<div
9997
className="flex w-full overflow-auto scrolling-touch font-sans bg-transparent text-sm text-gray-60-tr">
100-
<div className="flex"> {tabElements->ate} </div>
101-
<div className="flex-1 border-b border-gray-20"> {j`\\u00A0`->s} </div>
98+
<div className="flex"> {React.array(tabElements)} </div>
99+
<div className="flex-1 border-b border-gray-20"> {React.string(j`\\u00A0`)} </div>
102100
</div>
103101
<div
104102
className="px-4 text-base pb-4 pt-4 overflow-x-auto bg-snow-light border-snow-dark xs:rounded-b border border-t-0">

components/Icon.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/Icon.res

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
open Util.ReactStuff
2-
31
module Github = {
42
@react.component
53
let make = (~className: string) =>
@@ -124,7 +122,7 @@ module Table = {
124122
<svg className={"stroke-current " ++ className} width="25" height="23">
125123
<defs>
126124
<style>
127-
{".prefix__a,.prefix__b,.prefix__d{fill:none}.prefix__a,.prefix__b{stroke-width:1.5px}.prefix__c{stroke:none}"->s}
125+
{React.string(".prefix__a,.prefix__b,.prefix__d{fill:none}.prefix__a,.prefix__b{stroke-width:1.5px}.prefix__c{stroke:none}")}
128126
</style>
129127
</defs>
130128
<g className="prefix__a">

components/Image.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/Image.res

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
open Util.ReactStuff
2-
31
// This component is representing a embedded image, mainly used for markdown content
42

53
@react.component
@@ -15,7 +13,7 @@ let default = (~src: string, ~withShadow=false, ~caption: option<string>=?) => {
1513
</a>
1614
{switch caption {
1715
| None => React.null
18-
| Some(caption) => <div className="mt-4 text-14 text-night-light md:ml-16"> {caption->s} </div>
16+
| Some(caption) => <div className="mt-4 text-14 text-night-light md:ml-16"> {React.string(caption)} </div>
1917
}}
2018
</div>
2119
}

0 commit comments

Comments
 (0)