Skip to content

Commit dffdd7e

Browse files
timphandevclaude
andcommitted
docs: name the link to each package's example app by its host
The overview of each package now has a playground of its own, so the link that opens the example app of the package reads "Open in StackBlitz" or "Open in Snack" rather than "Playground". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 4e489f9 commit dffdd7e

4 files changed

Lines changed: 26 additions & 15 deletions

File tree

‎AGENTS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ Native's `style` prop keeps its identity between renders.
134134
docs depend on React Native and its React types only to typecheck the
135135
recipes of `@lynstack/native-recipe`.
136136
- `examples` holds an example of each package that readers open in the
137-
browser, from the Playground link of its overview page: `recipe` and
137+
browser, from the Open in StackBlitz or Open in Snack link of its
138+
overview page: `recipe` and
138139
`class-recipe` are React apps, built with Vite, that StackBlitz opens
139140
from the `main` branch, and `native-recipe/App.tsx` is the app of an
140141
Expo Snack, whose link `docs/src/packages.ts` builds. The examples are not in the

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ button({ tone: "danger" });
5858

5959
The [Quick start](https://lynstack.github.io/recipe/class-recipe/quick-start/)
6060
styles a component step by step, and each package's README shows its own
61-
example. To try a package in the browser, open the Playground link on the
62-
overview page of its docs.
61+
example. To try a package in the browser, choose its variants in the
62+
playground on the overview page of its docs, or open its example app from
63+
the Open in StackBlitz or Open in Snack link there.
6364

6465
## Why recipe
6566

‎docs/src/components/PackageMeta.astro‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ const pkg = packages[Astro.props.folder];
2424
<a href={pkg.source}>Source</a>
2525
</li>
2626
<li>
27-
<a href={pkg.playground}>Playground</a>
27+
<a href={pkg.exampleApp.url}>Open in {pkg.exampleApp.host}</a>
2828
</li>
2929
</ul>

‎docs/src/packages.ts‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import recipePackage from "../../packages/recipe/package.json";
66

77
const repository = "https://github.com/lynstack/recipe";
88

9+
/** An app that runs an example of a package, and the site that hosts it. */
10+
interface ExampleApp {
11+
readonly host: "Snack" | "StackBlitz";
12+
readonly url: string;
13+
}
14+
915
/** A package of the repository, as the docs present it. */
1016
interface PackageInfo {
1117
/** The npm name of the package. */
@@ -25,30 +31,33 @@ interface PackageInfo {
2531
/** The package's changelog on GitHub. */
2632
readonly changelog: string;
2733
/** An example of the package that runs in the browser, to edit and try. */
28-
readonly playground: string;
34+
readonly exampleApp: ExampleApp;
2935
/** The requirements of the package, on its installation page. */
3036
readonly requirements: string;
3137
}
3238

3339
/** Opens the example in `examples/<folder>` on StackBlitz. */
34-
function stackBlitzUrl(folder: PackageIconName, file: string): string {
40+
function stackBlitzApp(folder: PackageIconName, file: string): ExampleApp {
3541
const query = new URLSearchParams({ file, title: `${folder} example` });
36-
return `https://stackblitz.com/github/lynstack/recipe/tree/main/examples/${folder}?${query}`;
42+
return {
43+
host: "StackBlitz",
44+
url: `https://stackblitz.com/github/lynstack/recipe/tree/main/examples/${folder}?${query}`,
45+
};
3746
}
3847

3948
/**
4049
* Opens `code` as the `App.js` of an Expo Snack that installs `dependency`.
4150
* The editor of Snack checks TypeScript with a version too old to read the
4251
* types of the packages, so the example runs as JavaScript.
4352
*/
44-
function snackUrl(dependency: string, code: string): string {
53+
function snackApp(dependency: string, code: string): ExampleApp {
4554
const query = new URLSearchParams({
4655
dependencies: dependency,
4756
files: JSON.stringify({ "App.js": { contents: code, type: "CODE" } }),
4857
name: "native-recipe example",
4958
platform: "web",
5059
});
51-
return `https://snack.expo.dev/?${query}`;
60+
return { host: "Snack", url: `https://snack.expo.dev/?${query}` };
5261
}
5362

5463
function packageInfo(
@@ -59,15 +68,15 @@ function packageInfo(
5968
readonly description: string;
6069
readonly license: string;
6170
},
62-
{ label, playground }: Pick<PackageInfo, "label" | "playground">,
71+
{ label, exampleApp }: Pick<PackageInfo, "exampleApp" | "label">,
6372
): PackageInfo {
6473
return {
6574
changelog: `${repository}/blob/main/packages/${folder}/CHANGELOG.md`,
75+
exampleApp,
6676
label,
6777
license: manifest.license,
6878
name: manifest.name,
6979
npm: `https://www.npmjs.com/package/${manifest.name}`,
70-
playground,
7180
requirements: `/recipe/${folder}/installation/#requirements`,
7281
source: `${repository}/tree/main/packages/${folder}`,
7382
summary: manifest.description,
@@ -78,19 +87,19 @@ function packageInfo(
7887
/** Each package, by the name of its folder, which is also its sidebar topic. */
7988
const packages = {
8089
"class-recipe": packageInfo("class-recipe", classRecipePackage, {
90+
exampleApp: stackBlitzApp("class-recipe", "src/recipes.ts"),
8191
label: "Class names",
82-
playground: stackBlitzUrl("class-recipe", "src/recipes.ts"),
8392
}),
8493
"native-recipe": packageInfo("native-recipe", nativeRecipePackage, {
85-
label: "React Native styles",
86-
playground: snackUrl(
94+
exampleApp: snackApp(
8795
`${nativeRecipePackage.name}@${nativeRecipePackage.version}`,
8896
nativeRecipeExample,
8997
),
98+
label: "React Native styles",
9099
}),
91100
recipe: packageInfo("recipe", recipePackage, {
101+
exampleApp: stackBlitzApp("recipe", "src/recipes.ts"),
92102
label: "Core engine",
93-
playground: stackBlitzUrl("recipe", "src/recipes.ts"),
94103
}),
95104
} as const satisfies Readonly<Record<PackageIconName, PackageInfo>>;
96105

0 commit comments

Comments
 (0)