Skip to content

Commit

Permalink
Merge pull request #5 from snaplet/cdw/docs
Browse files Browse the repository at this point in the history
Move docs from docs repo into snapshot repo
  • Loading branch information
CarelFdeWaal authored Aug 5, 2024
2 parents b51e27c + 9434b04 commit 8a11d24
Show file tree
Hide file tree
Showing 138 changed files with 22,664 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ out
.parcel-cache
.snaplet/snaplet.d.ts
cli/scripts/predictions/.yarn/*

docs/.next
docs/node_modules
38 changes: 38 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### Prerequisites

Install `brew`, `git`, `pnpm` and `Node.js` :

#### Brew

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

#### Git

```bash
brew install git
```

#### Pnpm and Node.js

```bash
curl -fsSL https://get.pnpm.io/install.sh | sh -
pnpm env use --global lts
corepack enable
```

### Installation

```bash
git clone git@github.com:snaplet/docs.git
cd docs
pnpm install
```

### Run the project

```bash
pnpm next
# Go to http://localhost:3000
```
98 changes: 98 additions & 0 deletions docs/components/Editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import MonacoEditor, { type Monaco } from "@monaco-editor/react";
import { useCallback, type ComponentProps, useEffect, useRef } from "react";
import {
fakerDefs,
snapletClientTypes,
snapletConfig,
snapletTypes,
} from "./seed-tutorial";
import type { editor } from "monaco-editor";
import { AutoTypings, LocalStorageCache } from "monaco-editor-auto-typings";

export function Editor(props: ComponentProps<typeof MonacoEditor>) {
return (
<MonacoEditor
options={{
fontSize: 14,
lineNumbers: "off",
renderLineHighlight: "none",
minimap: { enabled: false },
overviewRulerLanes: 0,
hideCursorInOverviewRuler: true,
scrollBeyondLastLine: false,
padding: { top: 18 },
lineDecorationsWidth: 0,
}}
theme="vs-dark"
defaultLanguage="typescript"
{...props}
/>
);
}

export function SeedTutorialEditor() {
const monacoRef = useRef<Monaco>();

const handleBeforeMount = useCallback((monaco: Monaco) => {
monacoRef.current = monaco;

monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.Latest,
module: monaco.languages.typescript.ModuleKind.ESNext,
allowNonTsExtensions: true,
strict: true,
alwaysStrict: true,
noImplicitAny: true,
allowJs: false,
});

monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSuggestionDiagnostics: true,
});

monaco.languages.typescript.typescriptDefaults.addExtraLib(
fakerDefs,
"inmemory://faker.d.ts"
);
monaco.languages.typescript.typescriptDefaults.addExtraLib(
snapletClientTypes,
"inmemory://.snaplet/snaplet-client.d.ts"
);
monaco.languages.typescript.typescriptDefaults.addExtraLib(
snapletTypes,
"inmemory://.snaplet/snaplet.d.ts"
);
monaco.editor.createModel(
snapletConfig,
"typescript",
monaco.Uri.parse("inmemory://snaplet.config.ts")
);
}, []);

const handleMount = useCallback(
(editor: editor.IStandaloneCodeEditor, monaco: Monaco) => {
AutoTypings.create(editor, {
sourceCache: new LocalStorageCache(),
monaco,
});
},
[]
);

useEffect(() => {
return () => {
monacoRef.current?.editor.getModels().forEach((model) => {
model.dispose();
});
};
}, []);

return (
<Editor
height="500px"
beforeMount={handleBeforeMount}
onMount={handleMount}
defaultValue={snapletConfig}
/>
);
}
17 changes: 17 additions & 0 deletions docs/components/Image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import NextImage, { type ImageProps } from "next/image";
import Zoom from "./Zoom";

export function Image(props: { src: string; alt: string; zoom?: boolean }) {
const ImageComponent = props.zoom ? Zoom : NextImage;

return (
<div className="relative w-full h-[400px] mt-7">
<ImageComponent
className="object-contain"
fill
src={props.src}
alt={props.alt}
/>
</div>
);
}
224 changes: 224 additions & 0 deletions docs/components/Logo.tsx

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions docs/components/ReleaseNotes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useData } from "nextra/data"
import dynamic from "next/dynamic"

function ReleaseNote(props: { filename: string }) {
const Content = dynamic(() => import(`../releases/${props.filename}`))

return (
<Content />
)
}

export function ReleaseNotes() {
const { releases } = useData() as { releases: Array<{ filename: string }>}

return (
<>
{ releases.map((release, index) => <ReleaseNote key={index} filename={release.filename} />) }
</>
)
}
25 changes: 25 additions & 0 deletions docs/components/Step.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { Zoom } from "./Zoom";

export function Step(props: {
children: React.ReactNode;
image?: { src: string; alt: string };
}) {
if (!props.image) {
return props.children;
}

return (
<div className="nx-mt-6 block lg:flex lg:flex-row">
<div className="lg:flex-1">{props.children}</div>
<div className="lg:flex-1 relative h-[320px]">
<Zoom
className="object-contain"
src={props.image.src}
alt={props.image.alt}
fill
/>
</div>
</div>
);
}
Loading

0 comments on commit 8a11d24

Please sign in to comment.