Skip to content

Commit b97a357

Browse files
authored
adds capabilities to toolbar app and config file (#33)
1 parent d607530 commit b97a357

File tree

10 files changed

+862
-3
lines changed

10 files changed

+862
-3
lines changed

toolbar-app/.astro/collections/docs.schema.json

Lines changed: 628 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default new Map();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export default new Map([
3+
["src/content/docs/index.mdoc", () => import("astro:content-layer-deferred-module?astro%3Acontent-layer-deferred-module=&fileName=src%2Fcontent%2Fdocs%2Findex.mdoc&astroContentModuleFlag=true")]]);
4+

toolbar-app/.astro/content.d.ts

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
declare module 'astro:content' {
2+
interface Render {
3+
'.mdoc': Promise<{
4+
Content(props: Record<string, any>): import('astro').MarkdownInstance<{}>['Content'];
5+
headings: import('astro').MarkdownHeading[];
6+
}>;
7+
}
8+
}
9+
10+
declare module 'astro:content' {
11+
interface Render {
12+
'.mdx': Promise<{
13+
Content: import('astro').MarkdownInstance<{}>['Content'];
14+
headings: import('astro').MarkdownHeading[];
15+
remarkPluginFrontmatter: Record<string, any>;
16+
components: import('astro').MDXInstance<{}>['components'];
17+
}>;
18+
}
19+
}
20+
21+
declare module 'astro:content' {
22+
export interface RenderResult {
23+
Content: import('astro/runtime/server/index.js').AstroComponentFactory;
24+
headings: import('astro').MarkdownHeading[];
25+
remarkPluginFrontmatter: Record<string, any>;
26+
}
27+
interface Render {
28+
'.md': Promise<RenderResult>;
29+
}
30+
31+
export interface RenderedContent {
32+
html: string;
33+
metadata?: {
34+
imagePaths: Array<string>;
35+
[key: string]: unknown;
36+
};
37+
}
38+
}
39+
40+
declare module 'astro:content' {
41+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
42+
43+
export type CollectionKey = keyof AnyEntryMap;
44+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
45+
46+
export type ContentCollectionKey = keyof ContentEntryMap;
47+
export type DataCollectionKey = keyof DataEntryMap;
48+
49+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
50+
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
51+
ContentEntryMap[C]
52+
>['slug'];
53+
54+
/** @deprecated Use `getEntry` instead. */
55+
export function getEntryBySlug<
56+
C extends keyof ContentEntryMap,
57+
E extends ValidContentEntrySlug<C> | (string & {}),
58+
>(
59+
collection: C,
60+
// Note that this has to accept a regular string too, for SSR
61+
entrySlug: E,
62+
): E extends ValidContentEntrySlug<C>
63+
? Promise<CollectionEntry<C>>
64+
: Promise<CollectionEntry<C> | undefined>;
65+
66+
/** @deprecated Use `getEntry` instead. */
67+
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
68+
collection: C,
69+
entryId: E,
70+
): Promise<CollectionEntry<C>>;
71+
72+
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
73+
collection: C,
74+
filter?: (entry: CollectionEntry<C>) => entry is E,
75+
): Promise<E[]>;
76+
export function getCollection<C extends keyof AnyEntryMap>(
77+
collection: C,
78+
filter?: (entry: CollectionEntry<C>) => unknown,
79+
): Promise<CollectionEntry<C>[]>;
80+
81+
export function getEntry<
82+
C extends keyof ContentEntryMap,
83+
E extends ValidContentEntrySlug<C> | (string & {}),
84+
>(entry: {
85+
collection: C;
86+
slug: E;
87+
}): E extends ValidContentEntrySlug<C>
88+
? Promise<CollectionEntry<C>>
89+
: Promise<CollectionEntry<C> | undefined>;
90+
export function getEntry<
91+
C extends keyof DataEntryMap,
92+
E extends keyof DataEntryMap[C] | (string & {}),
93+
>(entry: {
94+
collection: C;
95+
id: E;
96+
}): E extends keyof DataEntryMap[C]
97+
? Promise<DataEntryMap[C][E]>
98+
: Promise<CollectionEntry<C> | undefined>;
99+
export function getEntry<
100+
C extends keyof ContentEntryMap,
101+
E extends ValidContentEntrySlug<C> | (string & {}),
102+
>(
103+
collection: C,
104+
slug: E,
105+
): E extends ValidContentEntrySlug<C>
106+
? Promise<CollectionEntry<C>>
107+
: Promise<CollectionEntry<C> | undefined>;
108+
export function getEntry<
109+
C extends keyof DataEntryMap,
110+
E extends keyof DataEntryMap[C] | (string & {}),
111+
>(
112+
collection: C,
113+
id: E,
114+
): E extends keyof DataEntryMap[C]
115+
? string extends keyof DataEntryMap[C]
116+
? Promise<DataEntryMap[C][E]> | undefined
117+
: Promise<DataEntryMap[C][E]>
118+
: Promise<CollectionEntry<C> | undefined>;
119+
120+
/** Resolve an array of entry references from the same collection */
121+
export function getEntries<C extends keyof ContentEntryMap>(
122+
entries: {
123+
collection: C;
124+
slug: ValidContentEntrySlug<C>;
125+
}[],
126+
): Promise<CollectionEntry<C>[]>;
127+
export function getEntries<C extends keyof DataEntryMap>(
128+
entries: {
129+
collection: C;
130+
id: keyof DataEntryMap[C];
131+
}[],
132+
): Promise<CollectionEntry<C>[]>;
133+
134+
export function render<C extends keyof AnyEntryMap>(
135+
entry: AnyEntryMap[C][string],
136+
): Promise<RenderResult>;
137+
138+
export function reference<C extends keyof AnyEntryMap>(
139+
collection: C,
140+
): import('astro/zod').ZodEffects<
141+
import('astro/zod').ZodString,
142+
C extends keyof ContentEntryMap
143+
? {
144+
collection: C;
145+
slug: ValidContentEntrySlug<C>;
146+
}
147+
: {
148+
collection: C;
149+
id: keyof DataEntryMap[C];
150+
}
151+
>;
152+
// Allow generic `string` to avoid excessive type errors in the config
153+
// if `dev` is not running to update as you edit.
154+
// Invalid collection names will be caught at build time.
155+
export function reference<C extends string>(
156+
collection: C,
157+
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
158+
159+
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
160+
type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
161+
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
162+
>;
163+
164+
type ContentEntryMap = {
165+
166+
};
167+
168+
type DataEntryMap = {
169+
"docs": Record<string, {
170+
id: string;
171+
body?: string;
172+
collection: "docs";
173+
data: InferEntrySchema<"docs">;
174+
rendered?: RenderedContent;
175+
filePath?: string;
176+
}>;
177+
178+
};
179+
180+
type AnyEntryMap = ContentEntryMap & DataEntryMap;
181+
182+
export type ContentConfig = typeof import("../src/content.config.js");
183+
}

toolbar-app/.astro/data-store.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

toolbar-app/.astro/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"_variables": {
3+
"lastUpdateCheck": 1742919742088
4+
}
5+
}

toolbar-app/.astro/types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="astro/client" />
2+
/// <reference path="content.d.ts" />

toolbar-app/vonage-toolbar/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
In the preview, there will be a toolbar in the bottom middle of the page.
44
Click the Vonage logo for the instructions.
55

6-
<img width="563" alt="image" src="https://github.com/user-attachments/assets/64a511dd-55c3-497c-9378-97c11465307c">
6+
![Screenshot of toolbar app. A dark gray rectangular interface element with rounded corners, displaying a list of six steps in white text, each preceded by a right-pointing triangle. Below the rectangle is a smaller dark gray rounded rectangle containing five white icons: an Astro logo, cursor arrow, three horizontal lines with a magnification glass, a V, and a gear icon. ](./toolbar.png)

toolbar-app/vonage-toolbar/app.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { defineToolbarApp } from 'astro/toolbar';
33
let tutorial: {
44
files: string[];
55
panels: string[];
6+
capabilities: string[];
67
version: string;
78
} = {
89
files: [],
910
panels: [],
11+
capabilities: [],
1012
version: '',
1113
};
1214

@@ -44,11 +46,21 @@ export default defineToolbarApp({
4446
<ul id='file-list'></ul>
4547
</details>
4648
<details name='steps'>
47-
<summary>Step 4: Enter version</summary>
49+
<summary>Step 4: Select capabilities needed</summary>
50+
Please select any capabilities used in the tutorial
51+
<form id='capabilities'>
52+
<div>
53+
<input type="checkbox" id="voice" name="capabilities" value="voice" />
54+
<label for="voice">Voice</label>
55+
</div>
56+
</form>
57+
</details>
58+
<details name='steps'>
59+
<summary>Step 5: Enter version</summary>
4860
<input id='version' placeholder='0.0.0'/>
4961
</details>
5062
<details name='steps'>
51-
<summary>Step 5: Finish up</summary>
63+
<summary>Step 6: Finish up</summary>
5264
Click to start generating the tutorial: <button id="generate">generate</button>
5365
<p id="status"></p>
5466
<span id="complete">
@@ -116,6 +128,14 @@ export default defineToolbarApp({
116128
).checked = true;
117129
});
118130
}
131+
132+
if (tutorial.capabilities.length !== 0) {
133+
tutorial.capabilities.forEach((capability) => {
134+
(
135+
astroToolbarWindow?.querySelector(`#${capability}`) as HTMLInputElement
136+
).checked = true;
137+
});
138+
}
119139
versionInput.value = tutorial.version;
120140
}
121141

@@ -146,6 +166,21 @@ export default defineToolbarApp({
146166
saveTutorial();
147167
});
148168

169+
const capabilitiesForm = astroToolbarWindow?.querySelector('#capabilities');
170+
171+
capabilitiesForm?.addEventListener('change', (event) => {
172+
console.log('capabilities change event');
173+
tutorial.capabilities = [];
174+
const capabilitiesChecked = astroToolbarWindow?.querySelectorAll(
175+
'input[type="checkbox"][name="capabilities"]:checked'
176+
);
177+
capabilitiesChecked?.forEach((capability) => {
178+
tutorial.capabilities.push(capability.id);
179+
});
180+
saveTutorial();
181+
});
182+
183+
149184
function saveTutorial() {
150185
localStorage.setItem('tutorial', JSON.stringify(tutorial));
151186
}
417 KB
Loading

0 commit comments

Comments
 (0)