Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a374acc
Emit js
denis-ok Oct 13, 2025
69743a2
Boilerplate for the new api
denis-ok Oct 13, 2025
74f31cb
Add NewEntity module
denis-ok Oct 13, 2025
3c9b72a
Start using actual module paths
denis-ok Oct 13, 2025
eb80369
Move demo names
denis-ok Oct 13, 2025
2fe8a73
Switch to array
denis-ok Oct 13, 2025
de1d823
Move new code
denis-ok Oct 13, 2025
fd0eed1
Recursive type
denis-ok Oct 13, 2025
212725b
Construct filepaths
denis-ok Oct 13, 2025
049edc8
Slugify
denis-ok Oct 13, 2025
1dbed3f
Save templates
denis-ok Oct 13, 2025
20ed787
Remove code related to prop demos
denis-ok Oct 13, 2025
103726b
Cleanup code related to right sidebar
denis-ok Oct 13, 2025
8200a1a
Boilerplate for the new ui
denis-ok Oct 13, 2025
485bba3
setup esbuild
denis-ok Oct 13, 2025
35afa70
Fix script injection into html template
denis-ok Oct 13, 2025
ae7b4d1
Improve names, tweak paths
denis-ok Oct 14, 2025
efcac6c
Update url building
denis-ok Oct 14, 2025
e24e7a8
Fix iframe url
denis-ok Oct 14, 2025
ec55b76
Fix iframe url
denis-ok Oct 14, 2025
582fa93
Generate a separate htmls for the main app
denis-ok Oct 14, 2025
fa53120
Better names
denis-ok Oct 14, 2025
a58ba5b
Add hot reload script
denis-ok Oct 14, 2025
ba57b44
Fix app crashing because of missing hook
denis-ok Oct 14, 2025
c801b83
Pass mode outside
denis-ok Oct 14, 2025
1c7fd52
Allow passing demo html
denis-ok Oct 14, 2025
0375827
Remove comment
denis-ok Oct 14, 2025
26eb7d9
Rename modules
denis-ok Oct 15, 2025
75b598a
Add new binary with node loader
denis-ok Oct 15, 2025
9c9aabb
Pass output dir outside
denis-ok Oct 15, 2025
826ddf6
Take output dir from env
denis-ok Oct 15, 2025
5311eec
Support custom port
denis-ok Oct 15, 2025
608c405
Remove redundant logic for iframe key
denis-ok Oct 15, 2025
eb27638
Support some custom config
denis-ok Oct 15, 2025
70bc08c
Support overriding publicPath
denis-ok Oct 15, 2025
2286cbf
Support overriding minify
denis-ok Oct 15, 2025
fe9c48c
Pass mode as env
denis-ok Oct 15, 2025
e0f31f6
Log custom config path
denis-ok Oct 15, 2025
99d9209
Async import custom config
denis-ok Oct 15, 2025
a4670a6
Read default field
denis-ok Oct 15, 2025
90564f9
Put everything into one dir
denis-ok Oct 15, 2025
9ddc1d7
Log custom config
denis-ok Oct 16, 2025
e066220
Handle publicPath in ui component
denis-ok Oct 16, 2025
92d8529
Fix double publicPath addition
denis-ok Nov 7, 2025
d769102
Use a proper html template
denis-ok Nov 9, 2025
dde9948
Minimal polyfill
denis-ok Nov 9, 2025
7a60f7d
Demos use own html template
denis-ok Nov 9, 2025
3e0f541
Add missing polyfill.js
denis-ok Nov 9, 2025
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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ build-example-ok:
.PHONY: build-example
build-example: ## Builds the example
$(DUNE) build @build-example

run-build:
rm -rf build
MODE=build commands/reshowcase2 ./_build/default/newexample/newexample/newexample/NewDemo.js

run-watch:
rm -rf build
MODE=watch commands/reshowcase2 ./_build/default/newexample/newexample/newexample/NewDemo.js
27 changes: 27 additions & 0 deletions commands/node-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { fileURLToPath } from "url";
import { basename } from "path";

function getFilenameWithoutExtension(filePath) {
return basename(filePath, ".js"); // or use extname to auto-detect
}

export async function load(url, context, nextLoad) {
if (url.includes("_Doc")) {
const filePath = fileURLToPath(url);

const filename = getFilenameWithoutExtension(filePath);

const stubModule = `
export const modulePath = "${filePath}";
export const demoName = "${filename}";
`;

return {
format: "module",
source: stubModule,
shortCircuit: true,
};
}

return nextLoad(url, context);
}
4 changes: 4 additions & 0 deletions commands/polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// polyfill.js
if (typeof window === "undefined") {
global.window = {};
}
5 changes: 5 additions & 0 deletions commands/reshowcase2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# node_custom_bin

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec node --require "$SCRIPT_DIR/polyfill.js" "$@"
5 changes: 4 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(dirs commands example src tests)
(dirs commands example newexample src tests)

(install
(section bin)
Expand All @@ -7,6 +7,9 @@
commands/demo-template.html
commands/favicon.png
commands/reshowcase
commands/reshowcase2
commands/node-loader.js
commands/polyfill.js
commands/ui-template.html))

(rule
Expand Down
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
ocaml
(melange
(>= 5.0.1))
(melange-json
(>= 2.0.0))
(reason
(>= 3.11.0))
(reason-react
Expand Down
10 changes: 9 additions & 1 deletion example/Demo.re
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ demo(({addDemo: _, addCategory}) =>
addCategory("Headings", ({addDemo, addCategory: _}) => {
addDemo("H1", ({string, int, _}) => {
let size =
int("Font size", {min: 0, max: 100, initial: 30, step: 1});
int(
"Font size",
{
min: 0,
max: 100,
initial: 30,
step: 1,
},
);

<h1 className={Css.h1Size(size)}>
{string("Text", "hello")->React.string}
Expand Down
Empty file added newexample/.ocamlformat
Empty file.
62 changes: 62 additions & 0 deletions newexample/ButtonHuge_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "Huge";

let spaceConcat = (x1, x2) =>
switch (x1, x2) {
| ("", x)
| (x, "") => x
| (x1, x2) => x1 ++ " " ++ x2
};

let (+++) = spaceConcat;

module Cn = {
let ifTrue = (cn, x) => x ? cn : "";
};

module Css = {
let button = [%cx
{|
color: #fff;
border: none;
padding: 10px;
border-radius: 10px;
font-family: inherit;
font-size: inherit;
|}
];

let buttonHuge = [%cx {|
padding: 20px;
font-size: 30px;
|}];

let buttonDisabled = [%cx {|
cursor: default;
opacity: 0.5;
|}];

let buttonColor = color => {
let color = `hex(color);
[%cx {|
background-color: $(color);
|}];
};
};

[@react.component]
let make = () => {
let disabled = false;
let color = "0091FF";

<button
disabled
className={
Css.button
+++ Css.buttonHuge
+++ Css.buttonDisabled->Cn.ifTrue(disabled)
+++ Css.buttonColor(color)
}>
{React.string("Hello")}
</button>;
};
56 changes: 56 additions & 0 deletions newexample/ButtonNormal_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "Normal";

let spaceConcat = (x1, x2) =>
switch (x1, x2) {
| ("", x)
| (x, "") => x
| (x1, x2) => x1 ++ " " ++ x2
};

let (+++) = spaceConcat;

module Cn = {
let ifTrue = (cn, x) => x ? cn : "";
};

module Css = {
let button = [%cx
{|
color: #fff;
border: none;
padding: 10px;
border-radius: 10px;
font-family: inherit;
font-size: inherit;
|}
];

let buttonDisabled = [%cx {|
cursor: default;
opacity: 0.5;
|}];

let buttonColor = color => {
let color = `hex(color);
[%cx {|
background-color: $(color);
|}];
};
};

[@react.component]
let make = () => {
let disabled = false;
let color = "0091FF";

<button
disabled
className={
Css.button
+++ Css.buttonDisabled->Cn.ifTrue(disabled)
+++ Css.buttonColor(color)
}>
{React.string("hello")}
</button>;
};
46 changes: 46 additions & 0 deletions newexample/CodeExample_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "Code example";

module Css = {
let code = [%cx
{|
white-space: pre;
padding: 0;
background-color: #f5f6f6;
|}
];
};

[@react.component]
let make = () => {
<code className=Css.code>
{js|open Reshowcase.Entry;

demo(({addDemo: _, addCategory}) =>
addCategory("Typography", ({addDemo: _, addCategory}) => {
addCategory("Headings", ({addDemo, addCategory: _}) => {
addDemo("H1", ({string, int, _}) => {
let size =
int("Font size", {min: 0, max: 100, initial: 30, step: 1});

<h1 className={Css.h1Size(size)}>
{string("Text", "hello")->React.string}
</h1>;
});
addDemo("H2", ({string, _}) =>
<h2> {string("Text", "hello")->React.string} </h2>
);
});
addCategory("Text", ({addDemo, addCategory: _}) => {
addDemo("Paragraph", ({string, _}) =>
<p> {string("Text", "hello")->React.string} </p>
);
addDemo("Italic", ({string, _}) =>
<i> {string("Text", "hello")->React.string} </i>
);
});
})
);|js}
->React.string
</code>;
};
18 changes: 18 additions & 0 deletions newexample/H1_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "H1";

module Css = {
let h1Size = size => {
let fontSize = `px(size);
[%cx {|
font-size: $(fontSize);
|}];
};
};

[@react.component]
let make = () => {
let size = 30;

<h1 className={Css.h1Size(size)}> {React.string("hello")} </h1>;
};
7 changes: 7 additions & 0 deletions newexample/H2_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "H2";

[@react.component]
let make = () => {
<h2> {React.string("hello")} </h2>;
};
7 changes: 7 additions & 0 deletions newexample/Italic_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "Italic";

[@react.component]
let make = () => {
<i> {React.string("hello")} </i>;
};
73 changes: 73 additions & 0 deletions newexample/NewDemo.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
let items: array(Reshowcase.NewEntity.item) = [|
Category({
name: "Buttons",
items: [|
Demo({
name: ButtonNormal_Doc.demoName,
modulePath: ButtonNormal_Doc.modulePath,
}),
Demo({
name: ButtonHuge_Doc.demoName,
modulePath: ButtonHuge_Doc.modulePath,
}),
|],
}),
Category({
name: "Headings",
items: [|
Demo({
name: H1_Doc.demoName,
modulePath: H1_Doc.modulePath,
}),
Demo({
name: H2_Doc.demoName,
modulePath: H2_Doc.modulePath,
}),
|],
}),
Category({
name: "Text",
items: [|
Demo({
name: Paragraph_Doc.demoName,
modulePath: Paragraph_Doc.modulePath,
}),
Demo({
name: Italic_Doc.demoName,
modulePath: Italic_Doc.modulePath,
}),
Category({
name: "Nested Text",
items: [|
Demo({
name: Italic_Doc.demoName,
modulePath: Italic_Doc.modulePath,
}),
|],
}),
|],
}),
Demo({
name: CodeExample_Doc.demoName,
modulePath: CodeExample_Doc.modulePath,
}),
Category({
name: "Test search",
items: [|
Demo({
name: OneTwoThreeFour_Doc.demoName,
modulePath: OneTwoThreeFour_Doc.modulePath,
}),
Demo({
name: OneTwoThreeFive_Doc.demoName,
modulePath: OneTwoThreeFive_Doc.modulePath,
}),
Demo({
name: OneTwoFourSeven_Doc.demoName,
modulePath: OneTwoFourSeven_Doc.modulePath,
}),
|],
}),
|];

let () = Reshowcase.NewEntry.start(~items, ~outputDir="./build", ());
5 changes: 5 additions & 0 deletions newexample/OneTwoFourSeven_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "OneTwoFourSeven";

[@react.component]
let make = () => React.null;
5 changes: 5 additions & 0 deletions newexample/OneTwoThreeFive_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "OneTwoThreeFive";

[@react.component]
let make = () => React.null;
5 changes: 5 additions & 0 deletions newexample/OneTwoThreeFour_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "OneTwoThreeFour";

[@react.component]
let make = () => React.null;
7 changes: 7 additions & 0 deletions newexample/Paragraph_Doc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let modulePath = Reshowcase.Utils.getFilepath();
let demoName = "Paragraph";

[@react.component]
let make = () => {
<p> {React.string("hello")} </p>;
};
Loading