Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
253 changes: 178 additions & 75 deletions examples/release-demo/src/scenario1-screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,135 @@ const cmt = (t: string) => s(t, { fg: tComment, italic: true });

const typescriptCode: readonly (readonly RichTextSpan[])[] = [
[cmt("// Typed core API")],
[kw("import"), plain(" { "), fn("createApp"), plain(", "), fn("ui"), plain(" } "), kw("from"), plain(" "), str('"@rezi-ui/core"')],
[kw("import"), plain(" { "), fn("createNodeBackend"), plain(" } "), kw("from"), plain(" "), str('"@rezi-ui/node"')],
[
kw("import"),
plain(" { "),
fn("createApp"),
plain(", "),
fn("ui"),
plain(" } "),
kw("from"),
plain(" "),
str('"@rezi-ui/core"'),
],
[
kw("import"),
plain(" { "),
fn("createNodeBackend"),
plain(" } "),
kw("from"),
plain(" "),
str('"@rezi-ui/node"'),
],
[plain("")],
[kw("const"), plain(" app = "), fn("createApp"), sym("({")],
[plain(" backend"), sym(":"), plain(" "), fn("createNodeBackend"), sym("(),")],
[plain(" initialState"), sym(":"), plain(" { count"), sym(":"), plain(" "), num("0"), plain(" },")],
[
plain(" initialState"),
sym(":"),
plain(" { count"),
sym(":"),
plain(" "),
num("0"),
plain(" },"),
],
[sym("});")],
[plain("")],
[plain("app."), fn("view"), sym("("), plain("state "), sym("=>")],
[plain(" ui."), fn("column"), sym("({ p: "), num("1"), sym(", gap: "), num("1"), sym(" }, [")],
[plain(" ui."), fn("text"), sym("("), str('`Count: ${state.count}`'), sym("),")],
[plain(" ui."), fn("button"), sym("("), str('"inc"'), sym(", "), str('"+1"'), sym(", { onPress: () => app.update(s => ({ ...s, count: s.count + "), num("1"), sym(" })) })")],
[plain(" ui."), fn("text"), sym("("), str("`Count: ${state.count}`"), sym("),")],
[
plain(" ui."),
fn("button"),
sym("("),
str('"inc"'),
sym(", "),
str('"+1"'),
sym(", { onPress: () => app.update(s => ({ ...s, count: s.count + "),
num("1"),
sym(" })) })"),
],
[plain(" ])"), sym(",")],
[sym(");")],
];

const jsxCode: readonly (readonly RichTextSpan[])[] = [
[cmt("// JSX runtime")],
[kw("import"), plain(" { "), ty("Column"), plain(", "), ty("Text"), plain(", "), ty("Button"), plain(" } "), kw("from"), plain(" "), str('"@rezi-ui/jsx"')],
[kw("import"), plain(" { "), fn("useState"), plain(" } "), kw("from"), plain(" "), str('"react"')],
[
kw("import"),
plain(" { "),
ty("Column"),
plain(", "),
ty("Text"),
plain(", "),
ty("Button"),
plain(" } "),
kw("from"),
plain(" "),
str('"@rezi-ui/jsx"'),
],
[
kw("import"),
plain(" { "),
fn("useState"),
plain(" } "),
kw("from"),
plain(" "),
str('"react"'),
],
[plain("")],
[kw("function"), plain(" "), fn("Counter"), sym("()"), plain(" {")],
[plain(" "), kw("const"), plain(" [count, setCount] = "), fn("useState"), sym("("), num("0"), sym(");")],
[
plain(" "),
kw("const"),
plain(" [count, setCount] = "),
fn("useState"),
sym("("),
num("0"),
sym(");"),
],
[plain(" "), kw("return"), plain(" (")],
[plain(" "), sym("<"), ty("Column"), plain(" p"), sym("={"), num("1"), sym("}"), plain(" gap"), sym("={"), num("1"), sym("}>")],
[plain(" "), sym("<"), ty("Text"), sym(">"), plain("Count: {count}"), sym("</"), ty("Text"), sym(">")],
[plain(" "), sym("<"), ty("Button"), plain(" id="), str('"inc"'), plain(" label="), str('"+1"')],
[plain(" onPress"), sym("={() => "), fn("setCount"), sym("(c => c + "), num("1"), sym(")}"), plain(" />")],
[
plain(" "),
sym("<"),
ty("Column"),
plain(" p"),
sym("={"),
num("1"),
sym("}"),
plain(" gap"),
sym("={"),
num("1"),
sym("}>"),
],
[
plain(" "),
sym("<"),
ty("Text"),
sym(">"),
plain("Count: {count}"),
sym("</"),
ty("Text"),
sym(">"),
],
[
plain(" "),
sym("<"),
ty("Button"),
plain(" id="),
str('"inc"'),
plain(" label="),
str('"+1"'),
],
[
plain(" onPress"),
sym("={() => "),
fn("setCount"),
sym("(c => c + "),
num("1"),
sym(")}"),
plain(" />"),
],
[plain(" "), sym("</"), ty("Column"), sym(">")],
[plain(" "), sym(")")],
[sym("}")],
Expand Down Expand Up @@ -140,75 +241,77 @@ app.view(({ revision, wipe }) => {
return ui.box({ flex: 1, style: { bg } }, [
ui.row({ flex: 1, justify: "center" }, [
ui.column({ key: `shot-${revision}`, width: captureWidth, gap: 0, items: "stretch" }, [
ui.box(
{
border: "rounded",
mt: 1,
px: 1,
py: 0,
style: { bg: panel, fg: borderBright },
},
[
ui.column({ gap: 0, items: "stretch" }, [
...logoLines.map((line) => ui.row({ justify: "center", width: "100%" }, [ui.richText(line)])),
ui.row({ justify: "center", width: "100%" }, [
ui.richText([
s("Two API styles: Custom TypeScript and JSX (React)", {
fg: fg,
}),
ui.box(
{
border: "rounded",
mt: 1,
px: 1,
py: 0,
style: { bg: panel, fg: borderBright },
},
[
ui.column({ gap: 0, items: "stretch" }, [
...logoLines.map((line) =>
ui.row({ justify: "center", width: "100%" }, [ui.richText(line)]),
),
ui.row({ justify: "center", width: "100%" }, [
ui.richText([
s("Two API styles: Custom TypeScript and JSX (React)", {
fg: fg,
}),
]),
]),
]),
ui.row({ justify: "center", width: "100%" }, [
ui.row({ gap: 1, items: "center" }, [
chip("Custom TypeScript", rgb(76, 204, 255)),
chip("JSX (React)", rgb(116, 176, 255)),
ui.row({ justify: "center", width: "100%" }, [
ui.row({ gap: 1, items: "center" }, [
chip("Custom TypeScript", rgb(76, 204, 255)),
chip("JSX (React)", rgb(116, 176, 255)),
]),
]),
]),
]),
],
),

ui.row({ gap: 1, mt: 1, mb: 1, items: "stretch" }, [
codePanel(
"Custom TypeScript",
"Typed API with direct state updates",
["Custom API", "Type-safe"],
typescriptCode,
borderBright,
true,
),
codePanel(
"JSX (React)",
"React-style JSX with hooks state",
["JSX", "React hooks"],
jsxCode,
border,
false,
],
),
]),

ui.box(
{
border: "rounded",
mb: 1,
px: 1,
py: 0,
style: { bg: panel, fg: border },
},
[
ui.row({ justify: "between", items: "center", gap: 2 }, [
ui.richText([
s("$ npm i ", { fg: fgDim }),
s("@rezi-ui/core @rezi-ui/node @rezi-ui/jsx", { fg: accent, bold: true }),
]),
ui.richText([
s("Custom TypeScript", { fg: success }),
s(" • ", { fg: fgDim }),
s("JSX (React)", { fg: accentWarm }),
ui.row({ gap: 1, mt: 1, mb: 1, items: "stretch" }, [
codePanel(
"Custom TypeScript",
"Typed API with direct state updates",
["Custom API", "Type-safe"],
typescriptCode,
borderBright,
true,
),
codePanel(
"JSX (React)",
"React-style JSX with hooks state",
["JSX", "React hooks"],
jsxCode,
border,
false,
),
]),

ui.box(
{
border: "rounded",
mb: 1,
px: 1,
py: 0,
style: { bg: panel, fg: border },
},
[
ui.row({ justify: "between", items: "center", gap: 2 }, [
ui.richText([
s("$ npm i ", { fg: fgDim }),
s("@rezi-ui/core @rezi-ui/node @rezi-ui/jsx", { fg: accent, bold: true }),
]),
ui.richText([
s("Custom TypeScript", { fg: success }),
s(" • ", { fg: fgDim }),
s("JSX (React)", { fg: accentWarm }),
]),
]),
]),
],
),
],
),
]),
]),
]);
Expand Down
Loading
Loading