Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit 8a11d24

Browse files
authored
Merge pull request #5 from snaplet/cdw/docs
Move docs from docs repo into snapshot repo
2 parents b51e27c + 9434b04 commit 8a11d24

138 files changed

Lines changed: 22664 additions & 0 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.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ out
5757
.parcel-cache
5858
.snaplet/snaplet.d.ts
5959
cli/scripts/predictions/.yarn/*
60+
61+
docs/.next
62+
docs/node_modules

docs/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
### Prerequisites
2+
3+
Install `brew`, `git`, `pnpm` and `Node.js` :
4+
5+
#### Brew
6+
7+
```bash
8+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
9+
```
10+
11+
#### Git
12+
13+
```bash
14+
brew install git
15+
```
16+
17+
#### Pnpm and Node.js
18+
19+
```bash
20+
curl -fsSL https://get.pnpm.io/install.sh | sh -
21+
pnpm env use --global lts
22+
corepack enable
23+
```
24+
25+
### Installation
26+
27+
```bash
28+
git clone git@github.com:snaplet/docs.git
29+
cd docs
30+
pnpm install
31+
```
32+
33+
### Run the project
34+
35+
```bash
36+
pnpm next
37+
# Go to http://localhost:3000
38+
```

docs/components/Editor.tsx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import MonacoEditor, { type Monaco } from "@monaco-editor/react";
2+
import { useCallback, type ComponentProps, useEffect, useRef } from "react";
3+
import {
4+
fakerDefs,
5+
snapletClientTypes,
6+
snapletConfig,
7+
snapletTypes,
8+
} from "./seed-tutorial";
9+
import type { editor } from "monaco-editor";
10+
import { AutoTypings, LocalStorageCache } from "monaco-editor-auto-typings";
11+
12+
export function Editor(props: ComponentProps<typeof MonacoEditor>) {
13+
return (
14+
<MonacoEditor
15+
options={{
16+
fontSize: 14,
17+
lineNumbers: "off",
18+
renderLineHighlight: "none",
19+
minimap: { enabled: false },
20+
overviewRulerLanes: 0,
21+
hideCursorInOverviewRuler: true,
22+
scrollBeyondLastLine: false,
23+
padding: { top: 18 },
24+
lineDecorationsWidth: 0,
25+
}}
26+
theme="vs-dark"
27+
defaultLanguage="typescript"
28+
{...props}
29+
/>
30+
);
31+
}
32+
33+
export function SeedTutorialEditor() {
34+
const monacoRef = useRef<Monaco>();
35+
36+
const handleBeforeMount = useCallback((monaco: Monaco) => {
37+
monacoRef.current = monaco;
38+
39+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
40+
target: monaco.languages.typescript.ScriptTarget.Latest,
41+
module: monaco.languages.typescript.ModuleKind.ESNext,
42+
allowNonTsExtensions: true,
43+
strict: true,
44+
alwaysStrict: true,
45+
noImplicitAny: true,
46+
allowJs: false,
47+
});
48+
49+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
50+
noSuggestionDiagnostics: true,
51+
});
52+
53+
monaco.languages.typescript.typescriptDefaults.addExtraLib(
54+
fakerDefs,
55+
"inmemory://faker.d.ts"
56+
);
57+
monaco.languages.typescript.typescriptDefaults.addExtraLib(
58+
snapletClientTypes,
59+
"inmemory://.snaplet/snaplet-client.d.ts"
60+
);
61+
monaco.languages.typescript.typescriptDefaults.addExtraLib(
62+
snapletTypes,
63+
"inmemory://.snaplet/snaplet.d.ts"
64+
);
65+
monaco.editor.createModel(
66+
snapletConfig,
67+
"typescript",
68+
monaco.Uri.parse("inmemory://snaplet.config.ts")
69+
);
70+
}, []);
71+
72+
const handleMount = useCallback(
73+
(editor: editor.IStandaloneCodeEditor, monaco: Monaco) => {
74+
AutoTypings.create(editor, {
75+
sourceCache: new LocalStorageCache(),
76+
monaco,
77+
});
78+
},
79+
[]
80+
);
81+
82+
useEffect(() => {
83+
return () => {
84+
monacoRef.current?.editor.getModels().forEach((model) => {
85+
model.dispose();
86+
});
87+
};
88+
}, []);
89+
90+
return (
91+
<Editor
92+
height="500px"
93+
beforeMount={handleBeforeMount}
94+
onMount={handleMount}
95+
defaultValue={snapletConfig}
96+
/>
97+
);
98+
}

docs/components/Image.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import NextImage, { type ImageProps } from "next/image";
2+
import Zoom from "./Zoom";
3+
4+
export function Image(props: { src: string; alt: string; zoom?: boolean }) {
5+
const ImageComponent = props.zoom ? Zoom : NextImage;
6+
7+
return (
8+
<div className="relative w-full h-[400px] mt-7">
9+
<ImageComponent
10+
className="object-contain"
11+
fill
12+
src={props.src}
13+
alt={props.alt}
14+
/>
15+
</div>
16+
);
17+
}

docs/components/Logo.tsx

Lines changed: 224 additions & 0 deletions
Large diffs are not rendered by default.

docs/components/ReleaseNotes.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useData } from "nextra/data"
2+
import dynamic from "next/dynamic"
3+
4+
function ReleaseNote(props: { filename: string }) {
5+
const Content = dynamic(() => import(`../releases/${props.filename}`))
6+
7+
return (
8+
<Content />
9+
)
10+
}
11+
12+
export function ReleaseNotes() {
13+
const { releases } = useData() as { releases: Array<{ filename: string }>}
14+
15+
return (
16+
<>
17+
{ releases.map((release, index) => <ReleaseNote key={index} filename={release.filename} />) }
18+
</>
19+
)
20+
}

docs/components/Step.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from "react";
2+
import { Zoom } from "./Zoom";
3+
4+
export function Step(props: {
5+
children: React.ReactNode;
6+
image?: { src: string; alt: string };
7+
}) {
8+
if (!props.image) {
9+
return props.children;
10+
}
11+
12+
return (
13+
<div className="nx-mt-6 block lg:flex lg:flex-row">
14+
<div className="lg:flex-1">{props.children}</div>
15+
<div className="lg:flex-1 relative h-[320px]">
16+
<Zoom
17+
className="object-contain"
18+
src={props.image.src}
19+
alt={props.image.alt}
20+
fill
21+
/>
22+
</div>
23+
</div>
24+
);
25+
}

0 commit comments

Comments
 (0)