Skip to content

Commit 46cd24c

Browse files
committed
Import code blocks and shared content into pages.
1 parent 610298b commit 46cd24c

55 files changed

Lines changed: 896 additions & 8368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎frontend/purestack.studio/components/actions/badge/badge.mdx‎

Lines changed: 2 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -60,105 +60,7 @@ Edit the label and explore every tone and variant. The default surface treatment
6060
```
6161
</TabPane>
6262
<TabPane id="badge-playground-ts" label="badge-playground.ts">
63-
```typescript
64-
import {
65-
type ComponentVariant,
66-
defineBadgeComponents,
67-
defineButtonComponents,
68-
defineFlexComponents,
69-
defineFormInputField,
70-
defineFormSelectField,
71-
defineGridComponents,
72-
defineIconComponents,
73-
type FormSelectOption,
74-
} from '@purestack/ts-components'
75-
import { SEMANTIC_TONES, type SemanticTone } from '@purestack/ts-style'
76-
import { lucide_chevron_down } from '@purestack/ts-svg-icons'
77-
import { batch, createApp, defineComponent, html, type Ref, ref } from 'regor'
78-
79-
export interface BadgePlayground {
80-
badgeLabel: Ref<string>
81-
tone: Ref<SemanticTone>
82-
variant: Ref<ComponentVariant>
83-
tones: FormSelectOption[]
84-
variants: FormSelectOption[]
85-
reset: () => void
86-
}
87-
88-
const badgePlaygroundTemplate = html`<Flex direction="column">
89-
<Flex align="center" justify="center" class="p-4">
90-
<Badge :tone="tone" :variant="variant">{{ badgeLabel }}</Badge>
91-
</Flex>
92-
<Grid columns="1" columnsSm="2" columnsLg="3">
93-
<FormInputField id="badge-label" label="Label" :model="badgeLabel"/>
94-
<FormSelectField id="badge-tone" label="Tone" :model="tone" :options="tones"/>
95-
<FormSelectField id="badge-variant" label="Variant" :model="variant" :options="variants"/>
96-
</Grid>
97-
<Btn variant="link" @click="reset">Reset playground</Btn>
98-
</Flex>`
99-
100-
function createBadgePlayground(): BadgePlayground {
101-
const badgeLabel = ref('Stable')
102-
const tone = ref<SemanticTone>('success')
103-
const variant = ref<ComponentVariant>('surface')
104-
return {
105-
badgeLabel,
106-
tone,
107-
variant,
108-
tones: SEMANTIC_TONES.map((value) => ({ label: value, value })),
109-
variants: [
110-
'solid',
111-
'surface',
112-
'surfaceAlt',
113-
'spotlight',
114-
'glass',
115-
'flat',
116-
'flatAlt',
117-
'flatSolid',
118-
'outlineFill',
119-
'outline',
120-
'subtle',
121-
'subtleBtn',
122-
'link',
123-
'sheen',
124-
'underline',
125-
'rail',
126-
'bracket',
127-
'none',
128-
].map((value) => ({ label: value, value })),
129-
reset: () =>
130-
batch(() => {
131-
badgeLabel('Stable')
132-
tone('success')
133-
variant('surface')
134-
}),
135-
}
136-
}
137-
138-
const component = defineComponent<BadgePlayground>(badgePlaygroundTemplate, {
139-
context: createBadgePlayground,
140-
})
141-
142-
createApp(
143-
{
144-
components: {
145-
BadgePlayground: component,
146-
...defineBadgeComponents(),
147-
...defineButtonComponents(),
148-
...defineFlexComponents(),
149-
...defineGridComponents(),
150-
...defineFormInputField(),
151-
...defineFormSelectField(),
152-
...defineIconComponents((name) => {
153-
if (name !== 'lucide:chevron-down')
154-
throw new Error(`Icon is not registered: ${name}`)
155-
return lucide_chevron_down
156-
}),
157-
},
158-
},
159-
{ selector: 'app#badge-playground', template: html`<BadgePlayground/>` },
160-
)
161-
```
63+
<import-codeblock src="./badge-playground.ts"/>
16264
</TabPane>
16365
</Tabs>
16466

@@ -341,122 +243,7 @@ This example runs entirely in your browser. It models a release workflow without
341243
```
342244
</TabPane>
343245
<TabPane id="release-checklist-ts" label="release-checklist.ts">
344-
```typescript
345-
import {
346-
defineBadgeComponents,
347-
defineBtnGroupComponents,
348-
defineButtonComponents,
349-
defineFlexComponents,
350-
defineFormComponents,
351-
} from '@purestack/ts-components'
352-
import type { SemanticTone } from '@purestack/ts-style'
353-
import {
354-
batch,
355-
type ComputedRef,
356-
computed,
357-
createApp,
358-
defineComponent,
359-
html,
360-
type Ref,
361-
ref,
362-
} from 'regor'
363-
364-
export interface ReleaseChecklist {
365-
documentation: Ref<boolean>
366-
tests: Ref<boolean>
367-
review: Ref<boolean>
368-
published: Ref<boolean>
369-
completed: ComputedRef<number>
370-
status: ComputedRef<string>
371-
tone: ComputedRef<SemanticTone>
372-
message: ComputedRef<string>
373-
publishDisabled: ComputedRef<boolean>
374-
publish: () => void
375-
reset: () => void
376-
}
377-
378-
const releaseChecklistTemplate = html`<Flex direction="column" align="start">
379-
<fieldset class="m-0 p-3 w-full">
380-
<legend>Release checklist</legend>
381-
<Flex direction="column" align="start">
382-
<FormCheck id="release-documentation" label="Documentation is up to date" :checked="documentation" :disabled="published"/>
383-
<FormCheck id="release-tests" label="Tests are passing" :checked="tests" :disabled="published"/>
384-
<FormCheck id="release-review" label="Review is complete" :checked="review" :disabled="published"/>
385-
</Flex>
386-
</fieldset>
387-
<Flex align="center" wrap="true" role="status">
388-
<Badge :tone="tone">{{ status }}</Badge>
389-
<span>{{ message }}</span>
390-
</Flex>
391-
<BtnGroup :wrap="true" role="group" aria-label="Release actions">
392-
<Btn tone="accent" :disabled="publishDisabled" @click="publish">Publish preview</Btn>
393-
<Btn variant="surface" @click="reset">Reset checklist</Btn>
394-
</BtnGroup>
395-
</Flex>`
396-
397-
function createReleaseChecklist(): ReleaseChecklist {
398-
const documentation = ref(false)
399-
const tests = ref(false)
400-
const review = ref(false)
401-
const published = ref(false)
402-
const completed = computed(
403-
() => Number(documentation()) + Number(tests()) + Number(review()),
404-
)
405-
const status = computed(() =>
406-
published() ? 'Published' : `${completed()}/3 ready`,
407-
)
408-
const tone = computed<SemanticTone>(() =>
409-
published() || completed() === 3 ? 'success' : 'warning',
410-
)
411-
const message = computed<string>(() =>
412-
published()
413-
? 'Preview release published.'
414-
: completed() === 3
415-
? 'All checks passed. Ready to publish.'
416-
: 'Complete every check to publish the preview.',
417-
)
418-
const publishDisabled = computed(() => completed() !== 3 || published())
419-
return {
420-
documentation,
421-
tests,
422-
review,
423-
published,
424-
completed,
425-
status,
426-
tone,
427-
message,
428-
publishDisabled,
429-
publish: () => {
430-
if (!publishDisabled()) published(true)
431-
},
432-
reset: () =>
433-
batch(() => {
434-
documentation(false)
435-
tests(false)
436-
review(false)
437-
published(false)
438-
}),
439-
}
440-
}
441-
442-
const component = defineComponent<ReleaseChecklist>(releaseChecklistTemplate, {
443-
context: createReleaseChecklist,
444-
})
445-
446-
createApp(
447-
{
448-
components: {
449-
ReleaseChecklist: component,
450-
...defineBadgeComponents(),
451-
...defineBtnGroupComponents(),
452-
...defineButtonComponents(),
453-
...defineFlexComponents(),
454-
...defineFormComponents(),
455-
},
456-
},
457-
{ selector: 'app#release-checklist', template: html`<ReleaseChecklist/>` },
458-
)
459-
```
246+
<import-codeblock src="./release-checklist.ts"/>
460247
</TabPane>
461248
</Tabs>
462249

0 commit comments

Comments
 (0)