Spaces:
Sleeping
Sleeping
Commit
·
a0e5a60
1
Parent(s):
2e6ae7a
add generic codemirror + autcomplete
Browse files- bun.lockb +0 -0
- package.json +4 -2
- src/pages/api/hello.ts +0 -13
- src/pages/index.tsx +37 -108
- src/styles/globals.css +0 -30
bun.lockb
CHANGED
|
Binary files a/bun.lockb and b/bun.lockb differ
|
|
|
package.json
CHANGED
|
@@ -9,9 +9,11 @@
|
|
| 9 |
"lint": "next lint"
|
| 10 |
},
|
| 11 |
"dependencies": {
|
|
|
|
|
|
|
|
|
|
| 12 |
"react": "^18",
|
| 13 |
-
"react-dom": "^18"
|
| 14 |
-
"next": "14.2.5"
|
| 15 |
},
|
| 16 |
"devDependencies": {
|
| 17 |
"typescript": "^5",
|
|
|
|
| 9 |
"lint": "next lint"
|
| 10 |
},
|
| 11 |
"dependencies": {
|
| 12 |
+
"@uiw/react-codemirror": "^4.23.0",
|
| 13 |
+
"codemirror-extension-inline-suggestion": "^0.0.3",
|
| 14 |
+
"next": "14.2.5",
|
| 15 |
"react": "^18",
|
| 16 |
+
"react-dom": "^18"
|
|
|
|
| 17 |
},
|
| 18 |
"devDependencies": {
|
| 19 |
"typescript": "^5",
|
src/pages/api/hello.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
| 1 |
-
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
| 2 |
-
import type { NextApiRequest, NextApiResponse } from "next";
|
| 3 |
-
|
| 4 |
-
type Data = {
|
| 5 |
-
name: string;
|
| 6 |
-
};
|
| 7 |
-
|
| 8 |
-
export default function handler(
|
| 9 |
-
req: NextApiRequest,
|
| 10 |
-
res: NextApiResponse<Data>,
|
| 11 |
-
) {
|
| 12 |
-
res.status(200).json({ name: "John Doe" });
|
| 13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/pages/index.tsx
CHANGED
|
@@ -1,118 +1,47 @@
|
|
| 1 |
import Image from "next/image";
|
| 2 |
import { Inter } from "next/font/google";
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
const inter = Inter({ subsets: ["latin"] });
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
export default function Home() {
|
| 7 |
return (
|
| 8 |
-
<
|
| 9 |
-
className=
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
<div className="
|
| 17 |
-
<
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
height={24}
|
| 30 |
-
priority
|
| 31 |
-
/>
|
| 32 |
-
</a>
|
| 33 |
</div>
|
| 34 |
</div>
|
| 35 |
-
|
| 36 |
-
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-full sm:before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full sm:after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700/10 after:dark:from-sky-900 after:dark:via-[#0141ff]/40 before:lg:h-[360px]">
|
| 37 |
-
<Image
|
| 38 |
-
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
|
| 39 |
-
src="/next.svg"
|
| 40 |
-
alt="Next.js Logo"
|
| 41 |
-
width={180}
|
| 42 |
-
height={37}
|
| 43 |
-
priority
|
| 44 |
-
/>
|
| 45 |
-
</div>
|
| 46 |
-
|
| 47 |
-
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
|
| 48 |
-
<a
|
| 49 |
-
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
|
| 50 |
-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
| 51 |
-
target="_blank"
|
| 52 |
-
rel="noopener noreferrer"
|
| 53 |
-
>
|
| 54 |
-
<h2 className={`mb-3 text-2xl font-semibold`}>
|
| 55 |
-
Docs{" "}
|
| 56 |
-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
| 57 |
-
->
|
| 58 |
-
</span>
|
| 59 |
-
</h2>
|
| 60 |
-
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
| 61 |
-
Find in-depth information about Next.js features and API.
|
| 62 |
-
</p>
|
| 63 |
-
</a>
|
| 64 |
-
|
| 65 |
-
<a
|
| 66 |
-
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
|
| 67 |
-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
| 68 |
-
target="_blank"
|
| 69 |
-
rel="noopener noreferrer"
|
| 70 |
-
>
|
| 71 |
-
<h2 className={`mb-3 text-2xl font-semibold`}>
|
| 72 |
-
Learn{" "}
|
| 73 |
-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
| 74 |
-
->
|
| 75 |
-
</span>
|
| 76 |
-
</h2>
|
| 77 |
-
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
| 78 |
-
Learn about Next.js in an interactive course with quizzes!
|
| 79 |
-
</p>
|
| 80 |
-
</a>
|
| 81 |
-
|
| 82 |
-
<a
|
| 83 |
-
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
|
| 84 |
-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
| 85 |
-
target="_blank"
|
| 86 |
-
rel="noopener noreferrer"
|
| 87 |
-
>
|
| 88 |
-
<h2 className={`mb-3 text-2xl font-semibold`}>
|
| 89 |
-
Templates{" "}
|
| 90 |
-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
| 91 |
-
->
|
| 92 |
-
</span>
|
| 93 |
-
</h2>
|
| 94 |
-
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
|
| 95 |
-
Discover and deploy boilerplate example Next.js projects.
|
| 96 |
-
</p>
|
| 97 |
-
</a>
|
| 98 |
-
|
| 99 |
-
<a
|
| 100 |
-
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template-tw&utm_campaign=create-next-app"
|
| 101 |
-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
|
| 102 |
-
target="_blank"
|
| 103 |
-
rel="noopener noreferrer"
|
| 104 |
-
>
|
| 105 |
-
<h2 className={`mb-3 text-2xl font-semibold`}>
|
| 106 |
-
Deploy{" "}
|
| 107 |
-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
|
| 108 |
-
->
|
| 109 |
-
</span>
|
| 110 |
-
</h2>
|
| 111 |
-
<p className={`m-0 max-w-[30ch] text-sm opacity-50 text-balance`}>
|
| 112 |
-
Instantly deploy your Next.js site to a shareable URL with Vercel.
|
| 113 |
-
</p>
|
| 114 |
-
</a>
|
| 115 |
-
</div>
|
| 116 |
-
</main>
|
| 117 |
);
|
| 118 |
-
}
|
|
|
|
| 1 |
import Image from "next/image";
|
| 2 |
import { Inter } from "next/font/google";
|
| 3 |
+
import CodeMirror from "@uiw/react-codemirror";
|
| 4 |
+
import { inlineSuggestion } from "codemirror-extension-inline-suggestion";
|
| 5 |
+
import { EditorState } from "@codemirror/state";
|
| 6 |
|
| 7 |
const inter = Inter({ subsets: ["latin"] });
|
| 8 |
|
| 9 |
+
const fetchRandomWord = async (state: EditorState): Promise<string> => {
|
| 10 |
+
if (state.doc.length === 0) {
|
| 11 |
+
return "";
|
| 12 |
+
}
|
| 13 |
+
const res = await fetch(
|
| 14 |
+
`https://random-word-api.herokuapp.com/word?number=5`
|
| 15 |
+
);
|
| 16 |
+
const data = await res.json();
|
| 17 |
+
return data.join(" ");
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
export default function Home() {
|
| 21 |
return (
|
| 22 |
+
<div>
|
| 23 |
+
<h1 className="text-6xl text-slate-800 mt-28 font-bold font-sans text-center">
|
| 24 |
+
Smol<span className="text-red-600">Pilot</span>
|
| 25 |
+
</h1>
|
| 26 |
+
<p className="text-slate-800 italic text-sm mb-4 mt-2 text-center">
|
| 27 |
+
What if you had a 350M parameter model in your pocket?
|
| 28 |
+
</p>
|
| 29 |
+
<div className="flex justify-center mt-10">
|
| 30 |
+
<div className="w-full border-2 border-slate-200 shadow-2xl rounded-lg max-w-4xl">
|
| 31 |
+
<CodeMirror
|
| 32 |
+
placeholder="Type anything to suggest a word"
|
| 33 |
+
height="400px"
|
| 34 |
+
extensions={
|
| 35 |
+
[
|
| 36 |
+
inlineSuggestion({
|
| 37 |
+
fetchFn: fetchRandomWord,
|
| 38 |
+
delay: 500
|
| 39 |
+
})
|
| 40 |
+
]
|
| 41 |
+
}
|
| 42 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
</div>
|
| 44 |
</div>
|
| 45 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
);
|
| 47 |
+
}
|
src/styles/globals.css
CHANGED
|
@@ -1,33 +1,3 @@
|
|
| 1 |
@tailwind base;
|
| 2 |
@tailwind components;
|
| 3 |
@tailwind utilities;
|
| 4 |
-
|
| 5 |
-
:root {
|
| 6 |
-
--foreground-rgb: 0, 0, 0;
|
| 7 |
-
--background-start-rgb: 214, 219, 220;
|
| 8 |
-
--background-end-rgb: 255, 255, 255;
|
| 9 |
-
}
|
| 10 |
-
|
| 11 |
-
@media (prefers-color-scheme: dark) {
|
| 12 |
-
:root {
|
| 13 |
-
--foreground-rgb: 255, 255, 255;
|
| 14 |
-
--background-start-rgb: 0, 0, 0;
|
| 15 |
-
--background-end-rgb: 0, 0, 0;
|
| 16 |
-
}
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
body {
|
| 20 |
-
color: rgb(var(--foreground-rgb));
|
| 21 |
-
background: linear-gradient(
|
| 22 |
-
to bottom,
|
| 23 |
-
transparent,
|
| 24 |
-
rgb(var(--background-end-rgb))
|
| 25 |
-
)
|
| 26 |
-
rgb(var(--background-start-rgb));
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
@layer utilities {
|
| 30 |
-
.text-balance {
|
| 31 |
-
text-wrap: balance;
|
| 32 |
-
}
|
| 33 |
-
}
|
|
|
|
| 1 |
@tailwind base;
|
| 2 |
@tailwind components;
|
| 3 |
@tailwind utilities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|