Skip to content

Commit 80da7f5

Browse files
committed
Improve regor docs.
1 parent db63be0 commit 80da7f5

15 files changed

Lines changed: 764 additions & 68 deletions

File tree

‎frontend/purestack.studio/guides/_nav.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"purestack-cli.mdx",
66
"site-config.mdx",
77
"vscode-extension.mdx",
8-
"regor-mdx.mdx",
8+
"regor.mdx",
99
"typography.mdx",
1010
"utility-css-classes.mdx",
1111
"semantic-tones.mdx",

‎frontend/purestack.studio/guides/index.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Guides
3-
description: Learn how to build and style a PureStack site with the CLI, site configuration, VS Code extension, Regor MDX, typography, utility classes, semantic tones, icons, and themes.
3+
description: Learn how to build and style a PureStack site with the CLI, site configuration, VS Code extension, Regor, typography, utility classes, semantic tones, icons, and themes.
44
template: doc
55
layout:
66
showNav: true
@@ -32,9 +32,9 @@ These guides follow the path from a content folder to a finished interface. Star
3232
<BtnLink href="/guides/vscode-extension/" tone="accent" variant="link">Set up the editor</BtnLink>
3333
</Panel>
3434
<Panel tone="neutral" bodyClass="p-3">
35-
<h2 class="mt-0">Regor MDX</h2>
36-
<p>Mix readable content with themed components and choose where browser behavior belongs.</p>
37-
<BtnLink href="/guides/regor-mdx/" tone="accent" variant="link">Write a page</BtnLink>
35+
<h2 class="mt-0">Regor</h2>
36+
<p>Render pages at build time and add interactive apps in the browser with one component model.</p>
37+
<BtnLink href="/guides/regor/" tone="accent" variant="link">Learn Regor</BtnLink>
3838
</Panel>
3939
<Panel tone="neutral" bodyClass="p-3">
4040
<h2 class="mt-0">Typography</h2>

‎frontend/purestack.studio/guides/purestack-cli.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Open the URL printed as `serving at` after the first build. With the default set
7070

7171
## Understand the content folder
7272

73-
The CLI recognizes `.md`, `.mdx`, and `.rmdx` as pages. Both `.mdx` and `.rmdx` use the Regor MDX pipeline. `.md` also uses that pipeline by default; `mdx.compileMdAsMdx` can change how `.md` is compiled. See [Regor MDX](/guides/regor-mdx/) for markup and component usage.
73+
The CLI recognizes `.md`, `.mdx`, and `.rmdx` as pages. Both `.mdx` and `.rmdx` use the Regor MDX pipeline. `.md` also uses that pipeline by default; `mdx.compileMdAsMdx` can change how `.md` is compiled. See the [Regor guide](/guides/regor/) for markup and component usage.
7474

7575
Routes follow filenames and folders:
7676

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import {
2+
defineBadgeComponents,
3+
defineButtonComponents,
4+
defineFlexComponents,
5+
defineFormComponents,
6+
defineIconComponents,
7+
definePanelComponents,
8+
} from '@purestack/ts-components'
9+
import { tabler_rocket } from '@purestack/ts-svg-icons'
10+
import {
11+
batch,
12+
type ComputedRef,
13+
computed,
14+
createApp,
15+
defineComponent,
16+
html,
17+
type Ref,
18+
ref,
19+
} from 'regor'
20+
21+
export interface Task {
22+
id: string
23+
title: string
24+
done: Ref<boolean>
25+
}
26+
27+
export interface TaskRow {
28+
task: Task
29+
}
30+
31+
const taskRow = defineComponent<TaskRow>(
32+
html`<FormCheck :id="'launch-' + task.id" :label="task.title" :checked="task.done" />`,
33+
{ props: ['task'] },
34+
)
35+
36+
export interface LaunchChecklist {
37+
tasks: Task[]
38+
completed: ComputedRef<number>
39+
ready: ComputedRef<boolean>
40+
launched: Ref<boolean>
41+
launch: () => void
42+
reset: () => void
43+
}
44+
45+
const launchChecklistTemplate = html`<Panel tone="neutral" variant="surfaceAlt" bodyClass="p-3">
46+
<Flex direction="column">
47+
<Flex justify="between" align="center" wrap="true">
48+
<strong>Launch checklist</strong>
49+
<Badge :tone="ready ? 'success' : 'warning'" variant="surface">
50+
{{ completed }} of {{ tasks.length }} done
51+
</Badge>
52+
</Flex>
53+
<TaskRow r-for="task in tasks" :task="task" />
54+
<Flex wrap="true">
55+
<Btn tone="accent" icon="tabler:rocket" :disabled="!ready || launched" @click="launch">Launch</Btn>
56+
<Btn tone="neutral" variant="surface" @click="reset">Start over</Btn>
57+
</Flex>
58+
<FormStatus r-if="launched" role="status">Launched. Every check passed.</FormStatus>
59+
</Flex>
60+
</Panel>`
61+
62+
function createLaunchChecklist(): LaunchChecklist {
63+
const tasks: Task[] = [
64+
{ id: 'docs', title: 'Docs reviewed', done: ref(true) },
65+
{ id: 'tests', title: 'Tests passing', done: ref(false) },
66+
{ id: 'notes', title: 'Release notes written', done: ref(false) },
67+
]
68+
const launched = ref(false)
69+
const completed = computed(() => tasks.filter((task) => task.done()).length)
70+
const ready = computed(() => completed() === tasks.length)
71+
return {
72+
tasks,
73+
completed,
74+
ready,
75+
launched,
76+
launch: () => launched(true),
77+
reset: () =>
78+
batch(() => {
79+
for (const task of tasks) task.done(false)
80+
launched(false)
81+
}),
82+
}
83+
}
84+
85+
createApp(
86+
{
87+
components: {
88+
LaunchChecklist: defineComponent<LaunchChecklist>(
89+
launchChecklistTemplate,
90+
{ context: createLaunchChecklist },
91+
),
92+
TaskRow: taskRow,
93+
...defineBadgeComponents(),
94+
...defineButtonComponents(),
95+
...defineFlexComponents(),
96+
...defineFormComponents(),
97+
...defineIconComponents((name) =>
98+
name === 'tabler:rocket' ? tabler_rocket : '',
99+
),
100+
...definePanelComponents(),
101+
},
102+
},
103+
{ selector: 'app#launch-checklist', template: html`<LaunchChecklist />` },
104+
)

‎frontend/purestack.studio/guides/regor-mdx.mdx‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)