Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

adds settings menu

Chris Bautista85d8e57a506f
diff --git a/components.json b/components.json
new file mode 100644
index 00000000..808b51f9
--- /dev/null
+++ b/components.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "https://ui.shadcn.com/schema.json",
+ "style": "default",
+ "rsc": true,
+ "tailwind": {
+ "config": "tailwind.config.js",
+ "css": "src/styles/globals.css",
+ "baseColor": "zinc",
+ "cssVariables": true
+ },
+ "aliases": {
+ "components": "~/components",
+ "utils": "~/utils"
+ }
+}
diff --git a/package.json b/package.json
index e081aa9d..3cdcec49 100644
--- a/package.json
+++ b/package.json
@@ -13,12 +13,19 @@
},
"dependencies": {
"@clerk/nextjs": "^4.19.0",
+ "@hookform/resolvers": "^3.1.1",
"@monaco-editor/react": "^4.5.1",
"@next-auth/prisma-adapter": "^1.0.6",
"@prisma/client": "^4.14.0",
+ "@radix-ui/react-dialog": "^1.0.4",
+ "@radix-ui/react-dropdown-menu": "^2.0.5",
+ "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.3",
+ "@radix-ui/react-select": "^1.2.2",
+ "@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
+ "@radix-ui/react-toast": "^1.1.4",
"@t3-oss/env-nextjs": "^0.3.1",
"@tanstack/react-query": "^4.29.7",
"@trpc/client": "^10.26.0",
@@ -36,6 +43,7 @@
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
+ "react-hook-form": "^7.45.0",
"react-markdown": "^8.0.7",
"superjson": "1.12.2",
"tailwind-merge": "^1.12.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 692faf67..91644f13 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4,6 +4,9 @@ dependencies:
'@clerk/nextjs':
specifier: ^4.19.0
+ '@hookform/resolvers':
+ specifier: ^3.1.1
+ version: 3.1.1([email protected])
'@monaco-editor/react':
specifier: ^4.5.1
@@ -13,15 +16,33 @@ dependencies:
'@prisma/client':
specifier: ^4.14.0
version: 4.14.0([email protected])
+ '@radix-ui/react-dialog':
+ specifier: ^1.0.4
+ '@radix-ui/react-dropdown-menu':
+ specifier: ^2.0.5
+ '@radix-ui/react-label':
+ specifier: ^2.0.2
'@radix-ui/react-navigation-menu':
specifier: ^1.1.3
+ '@radix-ui/react-select':
+ specifier: ^1.2.2
+ '@radix-ui/react-separator':
+ specifier: ^1.0.3
'@radix-ui/react-slot':
specifier: ^1.0.2
version: 1.0.2(@types/[email protected])([email protected])
'@radix-ui/react-tabs':
specifier: ^1.0.4
+ '@radix-ui/react-toast':
+ specifier: ^1.1.4
'@t3-oss/env-nextjs':
specifier: ^0.3.1
@@ -73,6 +94,9 @@ dependencies:
react-dom:
specifier: 18.2.0
version: 18.2.0([email protected])
+ react-hook-form:
+ specifier: ^7.45.0
+ version: 7.45.0([email protected])
react-markdown:
specifier: ^8.0.7
version: 8.0.7(@types/[email protected])([email protected])
@@ -506,6 +530,35 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
+ /@floating-ui/[email protected]:
+ resolution: {integrity: sha512-Bu+AMaXNjrpjh41znzHqaz3r2Nr8hHuHZT6V2LBKMhyMl0FgKA62PNYbqnfgmzOhoWZj70Zecisbo4H1rotP5g==}
+ dev: false
+
+ /@floating-ui/[email protected]:
+ resolution: {integrity: sha512-loCXUOLzIC3jp50RFOKXZ/kQjjz26ryr/23M+FWG9jrmAv8lRf3DUfC2AiVZ3+K316GOhB08CR+Povwz8e9mDw==}
+ dependencies:
+ '@floating-ui/core': 1.3.1
+ dev: false
+
+ resolution: {integrity: sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==}
+ peerDependencies:
+ react: '>=16.8.0'
+ react-dom: '>=16.8.0'
+ dependencies:
+ '@floating-ui/dom': 1.4.1
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-tS16bAUkqjITNSvbJuO1x7MXbn7Oe8ZziDTJdA9mMvsoYthnOOiznOTGBYwbdlYBgU+tgpI/BtTU3paRbCuSlg==}
+ peerDependencies:
+ react-hook-form: ^7.0.0
+ dependencies:
+ react-hook-form: 7.45.0([email protected])
+ dev: false
+
/@humanwhocodes/[email protected]:
resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==}
engines: {node: '>=10.10.0'}
@@ -704,14 +757,14 @@ packages:
dependencies:
asn1js: 3.0.5
pvtsutils: 1.3.2
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
/@peculiar/[email protected]:
resolution: {integrity: sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==}
engines: {node: '>=8.0.0'}
dependencies:
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
/@peculiar/[email protected]:
@@ -721,7 +774,7 @@ packages:
'@peculiar/asn1-schema': 2.3.6
'@peculiar/json-schema': 1.1.12
pvtsutils: 1.3.2
- tslib: 2.4.1
+ tslib: 2.5.3
webcrypto-core: 1.7.7
dev: false
@@ -759,12 +812,39 @@ packages:
resolution: {integrity: sha512-PDNlhP/1vyTgmNyiucGqGCdXIp7HIkkvKO50si3y3PcceeHvqtiKPaH1iJdz63jCWMVMbj2MElSxXPOeBvEVIQ==}
requiresBuild: true
+ /@radix-ui/[email protected]:
+ resolution: {integrity: sha512-T5gIdVO2mmPW3NNhjNgEP3cqMXjXL9UbO0BzWcXfvdBs+BohbQxvd/K5hSVKmn9/lbTdsQVKbUcP5WLCwvUbBg==}
+ dependencies:
+ '@babel/runtime': 7.22.5
+ dev: false
+
/@radix-ui/[email protected]:
resolution: {integrity: sha512-yQ8oGX2GVsEYMWGxcovu1uGWPCxV5BFfeeYxqPmuAzUyLT9qmaMXSAhXpb0WrspIeqYzdJpkh2vHModJPgRIaw==}
dependencies:
'@babel/runtime': 7.22.5
dev: false
+ resolution: {integrity: sha512-wSP+pHsB/jQRaL6voubsQ/ZlrGBHHrOjmBnr19hxYgtS0WvAFwZhK2WP/YY5yF9uKECCEEDGxuLxq1NBK51wFA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-3SzW+0PW7yBBoQlT8wNcGtaxaD0XSu0uLUFgrtHY08Acx05TaHaOmVLR73c0j/cqpDy53KBMO7s0dx2wmOIDIA==}
peerDependencies:
@@ -817,6 +897,40 @@ packages:
react: 18.2.0
dev: false
+ resolution: {integrity: sha512-hJtRy/jPULGQZceSAP2Re6/4NpKo8im6V8P2hUqZsdFiSL8l35kYsw3qbRI6Ay5mQd2+wlLqje770eq+RJ3yZg==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-focus-guards': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-focus-scope': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-portal': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-slot': 1.0.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ aria-hidden: 1.2.3
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-remove-scroll: 2.5.5(@types/[email protected])([email protected])
+ dev: false
+
resolution: {integrity: sha512-RXcvnXgyvYvBEOhCBuddKecVkoMiI10Jcm5cTI7abJRAHYfFxeu+FBQs/DvdxSYucxR5mna0dNsL6QFlds5TMA==}
peerDependencies:
@@ -856,6 +970,70 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-xdOrZzOTocqqkCkYo8yRPCib5OkTkqN7lqNCdxwPOdE466DOaNl4N8PkUIlsXthQvW5Wwkd+aEmWpfWlBoDPEw==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-menu': 2.0.5(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-Rect2dWbQ8waGzhMavsIbmSVCgYxkXLxxR3ZvCX79JOglzdEy4JXMb98lq4hPxUbLr77nP0UOGf4rcMU+s1pUA==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@types/react': 18.2.8
+ react: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-upXdPfqI4islj2CslyfUBNlaJCPybbqRHAi1KER7Isel9Q2AtSJ0zRBZv8mWQiFXD2nyAJ4BhC3yXgZ6kMBSrQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-tI7sT/kqYp8p96yGWY1OAnLHrqDgzHefRBKQ2YAkBS5ja7QLcZ9Z/uY7bEjPUatf8RomoXM8/1sMj1IJaE5UzQ==}
peerDependencies:
@@ -871,6 +1049,65 @@ packages:
react: 18.2.0
dev: false
+ resolution: {integrity: sha512-N5ehvlM7qoTLx7nWPodsPYPgMzA5WM8zZChQg8nyFJKnDO5WHdba1vv5/H6IO5LtJMfD2Q3wh1qHFGNtK0w3bQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-Gw4f9pwdH+w5w+49k0gLjN0PfRDHvxmAgG16AbyJZ7zhwZ6PBHKtWohvnSwfusfnK3L68dpBREHpVkj8wEM7ZA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-direction': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-focus-guards': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-focus-scope': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-popper': 1.1.2(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-portal': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-roving-focus': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-slot': 1.0.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ aria-hidden: 1.2.3
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-remove-scroll: 2.5.5(@types/[email protected])([email protected])
+ dev: false
+
resolution: {integrity: sha512-x4Uv0N47ABx3/frJazYXxvMpZeKJe0qmRIgQ2o3lhTqnTVg+CaZfVVO4nQLn3QJcDkTz8icElKffhFng47XIBA==}
peerDependencies:
@@ -905,6 +1142,57 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-1CnGGfFi/bbqtJZZ0P/NQY20xdG3E0LALJaLUEoKwPLwl6PPPfbeiCqMVQnhoFRAxjJj4RpBRJzDmUgsex2tSg==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@floating-ui/react-dom': 2.0.1([email protected])([email protected])
+ '@radix-ui/react-arrow': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-rect': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-size': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/rect': 1.0.1
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-xLYZeHrWoPmA5mEKEfZZevoVRK/Q43GfzRXkWV6qawIWWK8t6ifIiLQdd7rmQ4Vk1bmI21XhqF9BN3jWf+phpA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-UXLW4UAbIY5ZjcvzjfRFo5gxva8QirC9hF7wRE4U5gz+TP0DbRk+//qyuAQ1McDxBt1xNMBTaciFGvEmJvAZCg==}
peerDependencies:
@@ -977,6 +1265,68 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-zI7McXr8fNaSrUY9mZe4x/HC0jTLY9fWNhO1oLWYMQGDXuV4UCivIGTxwioSzO0ZCYX9iSLyWmAh/1TOmX3Cnw==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/number': 1.0.1
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-direction': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-focus-guards': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-focus-scope': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-popper': 1.1.2(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-portal': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-slot': 1.0.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-previous': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-visually-hidden': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ aria-hidden: 1.2.3
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-remove-scroll: 2.5.5(@types/[email protected])([email protected])
+ dev: false
+
+ resolution: {integrity: sha512-itYmTy/kokS21aiV5+Z56MZB54KrhPgn6eHDKkFeOLR34HMN2s8PaN47qZZAGnvupcjxHaFZnW4pQEh0BvvVuw==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-YeTpuq4deV+6DusvVUW4ivBgnkHwECUu0BiN43L5UCDFgdhsRUWAghhTF5MbvNTPzmiFOx90asDSUjWuCNapwg==}
peerDependencies:
@@ -1020,6 +1370,38 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-wf+fc8DOywrpRK3jlPlWVe+ELYGHdKDaaARJZNuUTWyWYq7+ANCFLp4rTjZ/mcGkJJQ/vZ949Zis9xxEpfq9OA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-portal': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-layout-effect': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-visually-hidden': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@types/react': 18.2.8
+ '@types/react-dom': 18.2.4
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-D94LjX4Sp0xJFVaoQOd3OO9k7tpBYNOXdVhkltUbGv2Qb9OXdrg/CpsjlZv7ia14Sylv398LswWBVVu5nqKzAQ==}
peerDependencies:
@@ -1092,6 +1474,36 @@ packages:
react: 18.2.0
dev: false
+ resolution: {integrity: sha512-Cq5DLuSiuYVKNU8orzJMbl15TXilTnJKUCltMVQg53BQOF1/C5toAaGrowkgksdBQ9H+SRL23g0HDmg9tvmxXw==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/rect': 1.0.1
+ '@types/react': 18.2.8
+ react: 18.2.0
+ dev: false
+
+ resolution: {integrity: sha512-ibay+VqrgcaI6veAojjofPATwledXiSmX+C0KrBk/xgpX9rBzPV3OsfwlhQdUOFbh+LKQorLYT+xTXW9V8yd0g==}
+ peerDependencies:
+ '@types/react': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.22.5
+ '@radix-ui/react-use-layout-effect': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.8
+ react: 18.2.0
+ dev: false
+
resolution: {integrity: sha512-D4w41yN5YRKtu464TLnByKzMDG/JlMPHtfZgQAu9v6mNakUqGUI9vUrfQKz8NK41VMm/xbZbh76NUTVtIYqOMA==}
peerDependencies:
@@ -1113,6 +1525,12 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ /@radix-ui/[email protected]:
+ resolution: {integrity: sha512-fyrgCaedtvMg9NK3en0pnOYJdtfwxUcNolezkNPUsoX57X8oQk+NkqcvzHXD2uKNij6GXmWU9NDru2IWjrO4BQ==}
+ dependencies:
+ '@babel/runtime': 7.22.5
+ dev: false
+
/@rushstack/[email protected]:
resolution: {integrity: sha512-RkmuBcqiNioeeBKbgzMlOdreUkJfYaSjwgx9XDgGGpjvWgyaxWvDmZVSN9CS6LjEASadhgPv2BcFp+SeouWXXA==}
dev: true
@@ -1572,6 +1990,13 @@ packages:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
dev: true
+ resolution: {integrity: sha512-xcLxITLe2HYa1cnYnwCjkOO1PqUHQpozB8x9AR0OgWN2woOBi5kSDVxKfd0b7sb1hw5qFeJhXm9H1nu3xSfLeQ==}
+ engines: {node: '>=10'}
+ dependencies:
+ tslib: 2.5.3
+ dev: false
+
resolution: {integrity: sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==}
dependencies:
@@ -1637,7 +2062,7 @@ packages:
dependencies:
pvtsutils: 1.3.2
pvutils: 1.1.3
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -1990,6 +2415,10 @@ packages:
engines: {node: '>=6'}
dev: false
+ resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==}
+ dev: false
+
resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}
@@ -2026,7 +2455,7 @@ packages:
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
dependencies:
no-case: 3.0.4
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -2600,6 +3029,11 @@ packages:
has-symbols: 1.0.3
dev: true
+ resolution: {integrity: sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==}
+ engines: {node: '>=6'}
+ dev: false
+
resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
engines: {node: '>=10'}
@@ -2810,6 +3244,12 @@ packages:
side-channel: 1.0.4
dev: true
+ resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==}
+ dependencies:
+ loose-envify: 1.4.0
+ dev: false
+
resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==}
engines: {node: '>= 0.4'}
@@ -3138,7 +3578,7 @@ packages:
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
dependencies:
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -3556,7 +3996,7 @@ packages:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
dependencies:
lower-case: 2.0.2
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -3977,7 +4417,7 @@ packages:
resolution: {integrity: sha512-+Ipe2iNUyrZz+8K/2IOo+kKikdtfhRKzNpQbruF2URmqPtoqAs8g3xS7TJvFF2GcPXjh7DkqMnpVveRFq4PgEQ==}
dependencies:
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -4007,6 +4447,15 @@ packages:
scheduler: 0.23.0
dev: false
+ resolution: {integrity: sha512-AbHeZ4ad+0dEIknSW9dBgIwcvRDfZ1O97sgj75WaMdOX0eg8TBiUf9wxzVkIjZbk76BBIE9lmFOzyD4PN80ZQg==}
+ engines: {node: '>=12.22.0'}
+ peerDependencies:
+ react: ^16.8.0 || ^17 || ^18
+ dependencies:
+ react: 18.2.0
+ dev: false
+
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
@@ -4041,6 +4490,41 @@ packages:
- supports-color
dev: false
+ resolution: {integrity: sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.8
+ react: 18.2.0
+ react-style-singleton: 2.2.1(@types/[email protected])([email protected])
+ tslib: 2.5.3
+ dev: false
+
+ resolution: {integrity: sha512-ImKhrzJJsyXJfBZ4bzu8Bwpka14c/fQt0k+cyFp/PBhTfyDnU5hjOtM4AG/0AMyy8oKzOTR0lDgJIM7pYXI0kw==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.8
+ react: 18.2.0
+ react-remove-scroll-bar: 2.3.4(@types/[email protected])([email protected])
+ react-style-singleton: 2.2.1(@types/[email protected])([email protected])
+ tslib: 2.5.3
+ use-callback-ref: 1.3.0(@types/[email protected])([email protected])
+ use-sidecar: 1.1.2(@types/[email protected])([email protected])
+ dev: false
+
resolution: {integrity: sha512-yFNHrlVEReVYKsLI5lF05tZoHveA5pGzjFbFJY/3pOqqjGOmMmqx83N4hIjN2n6E1AOa+eQEUxs3CgRnPmT0RQ==}
peerDependencies:
@@ -4049,6 +4533,23 @@ packages:
react: 18.2.0
dev: false
+ resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.8
+ get-nonce: 1.0.1
+ invariant: 2.2.4
+ react: 18.2.0
+ tslib: 2.5.3
+ dev: false
+
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
engines: {node: '>=0.10.0'}
@@ -4219,7 +4720,7 @@ packages:
resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==}
dependencies:
dot-case: 3.0.4
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
@@ -4665,6 +5166,37 @@ packages:
punycode: 2.3.0
dev: true
+ resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.8
+ react: 18.2.0
+ tslib: 2.5.3
+ dev: false
+
+ resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==}
+ engines: {node: '>=10'}
+ peerDependencies:
+ '@types/react': ^16.9.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ dependencies:
+ '@types/react': 18.2.8
+ detect-node-es: 1.1.0
+ react: 18.2.0
+ tslib: 2.5.3
+ dev: false
+
resolution: {integrity: sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==}
peerDependencies:
@@ -4722,7 +5254,7 @@ packages:
'@peculiar/json-schema': 1.1.12
asn1js: 3.0.5
pvtsutils: 1.3.2
- tslib: 2.4.1
+ tslib: 2.5.3
dev: false
diff --git a/prisma/seed.ts b/prisma/seed.ts
index 30f39588..da588916 100644
--- a/prisma/seed.ts
+++ b/prisma/seed.ts
@@ -1,7 +1,34 @@
-import { PrismaClient } from '@prisma/client';
+import { Difficulty, Prisma, PrismaClient } from '@prisma/client';
import uuidByString from 'uuid-by-string';
const prisma = new PrismaClient();
+const CHALLENGES_TO_CREATE = 50;
+const DIFFICULTIES = ['BEGINNER', 'EASY', 'MEDIUM', 'HARD', 'EXTREME'];
+const randomDifficulty = (): Difficulty => {
+ return DIFFICULTIES[Math.floor(Math.random() * DIFFICULTIES.length)] as Difficulty;
+};
+
+const challenges = (who: string): Prisma.ChallengeCreateNestedManyWithoutUserInput => ({
+ create: Array.from({ length: CHALLENGES_TO_CREATE }, (_, challengeIndex) => ({
+ name: `Challenge ${challengeIndex + 1}`,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ description: `### ${who} is a cool guy
+ - he likes to eat ${who}
+ - he likes to sleep in ${who}
+ - he likes to be ${who}
+ `,
+ prompt: `/* _____________ Test Cases _____________ */
+Extends<HelloWorld, \`Hello, \${string}\`>()
+
+Extends<HelloWorld, \`\${string}!\`>()
+
+/* _____________ Your Code Here _____________ */
+type HelloWorld =`,
+ difficulty: randomDifficulty(),
+ })),
+});
+
async function main() {
const trashId = uuidByString('trash');
await prisma.user.upsert({
@@ -11,26 +38,7 @@ async function main() {
id: trashId,
name: 'chris',
- Challenge: {
- create: {
- createdAt: new Date(),
- updatedAt: new Date(),
- name: "trash's first challenge",
- description: `### trash is a cool guy
- - he likes to eat trash
- - he likes to sleep in trash
- - he likes to be trash
- `,
- prompt: `/* _____________ Test Cases _____________ */
-Extends<HelloWorld, \`Hello, \${string}\`>()
-
-Extends<HelloWorld, \`\${string}!\`>()
-
-/* _____________ Your Code Here _____________ */
-type HelloWorld =`,
- difficulty: 'EASY',
- },
- },
+ Challenge: challenges('trash'),
},
});
const gId = uuidByString('g');
@@ -41,22 +49,7 @@ type HelloWorld =`,
id: gId,
name: 'g',
- Challenge: {
- create: {
- createdAt: new Date(),
- updatedAt: new Date(),
- name: "g's first challenge",
- description: `### g is a cool guy
- - he does not like to eat trash
- - he does not like to sleep in trash
- - he doesn not like to be trash
- `,
- prompt: `Equal<T, 1>();
-
-type T =`,
- difficulty: 'EASY',
- },
- },
+ Challenge: challenges('g'),
},
});
}
diff --git a/src/app/challenge/[id]/page.tsx b/src/app/challenge/[id]/page.tsx
index b32bb27d..1848787c 100644
--- a/src/app/challenge/[id]/page.tsx
+++ b/src/app/challenge/[id]/page.tsx
@@ -1,5 +1,4 @@
import { Challenge } from '~/components/challenge';
-import {} from '~/components/user/profile';
interface Props {
params: {
diff --git a/src/app/explore/page.tsx b/src/app/explore/page.tsx
new file mode 100644
index 00000000..f9a7395d
--- /dev/null
+++ b/src/app/explore/page.tsx
@@ -0,0 +1,5 @@
+import { Explore } from '~/components/explore';
+
+export default function Page() {
+ return <Explore />;
+}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index be672c22..6c73bd4f 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -4,6 +4,7 @@ import '../styles/globals.css';
import { Inter } from 'next/font/google';
import { Navigation } from '~/components/ui/navigation';
+import { Toaster } from '~/components/ui/toaster';
const inter = Inter({ subsets: ['latin'] });
export const metadata = {
@@ -15,12 +16,13 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html suppressHydrationWarning>
<head />
- <body className="flex flex-col">
+ <body className={`${inter.className} flex flex-col`}>
<Providers>
<Navigation />
- <main className={`${inter.className} flex-1 bg-white dark:bg-neutral-900`}>
- {children}
+ <main className="flex-1">
+ <div className="container h-full">{children}</div>
</main>
+ <Toaster />
</Providers>
</body>
</html>
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 00f2fd6f..782d932a 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -20,7 +20,7 @@ export default async function Index() {
{session && <span>Logged in as {session.user?.name}</span>}
</p>
</div>
- <SignInOutButton />
+ <SignInOutButton session={session} />
</>
);
}
diff --git a/src/components/challenge/description-panel.tsx b/src/components/challenge/description-panel.tsx
index 8c233e49..17d7669b 100644
--- a/src/components/challenge/description-panel.tsx
+++ b/src/components/challenge/description-panel.tsx
@@ -1,14 +1,14 @@
'use client';
import type { Challenge, Vote } from '@prisma/client';
+import { clsx } from 'clsx';
import { debounce } from 'lodash';
+import { ArrowBigUp } from 'lucide-react';
import { useSession } from 'next-auth/react';
+import { useRef, useState } from 'react';
import ReactMarkdown from 'react-markdown';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';
import { incrementOrDecrementUpvote } from './increment.action';
-import { useRef, useState } from 'react';
-import { ArrowBigUp } from 'lucide-react';
-import { clsx } from 'clsx';
interface Props {
challenge: Challenge & {
@@ -30,6 +30,7 @@ export function DescriptionPanel({ challenge }: Props) {
}
}, 500),
).current;
+
return (
<div className="flex-1 rounded-md bg-white dark:bg-zinc-800">
<Tabs defaultValue="description" className="w-full">
@@ -38,12 +39,12 @@ export function DescriptionPanel({ challenge }: Props) {
<TabsTrigger value="solutions">Solutions</TabsTrigger>
</TabsList>
<TabsContent value="description" className="mt-0">
- <div className="flex">
+ <div className="flex h-full">
<div className="p-t-[2px] flex w-[30px] items-start justify-center">
{session?.data?.user?.id && (
<button
className=""
- onClick={async () => {
+ onClick={(): void => {
let shouldIncrement: boolean;
if (hasVoted) {
setVotes((v) => v - 1);
@@ -54,7 +55,11 @@ export function DescriptionPanel({ challenge }: Props) {
shouldIncrement = true;
setHasVoted(true);
}
- debouncedSearch(challenge.id, session?.data?.user?.id, shouldIncrement);
+ debouncedSearch(challenge.id, session?.data?.user?.id, shouldIncrement)?.catch(
+ (e) => {
+ console.error(e);
+ },
+ );
}}
>
<ArrowBigUp className={clsx({ 'fill-red-500': hasVoted })} />
@@ -68,7 +73,7 @@ export function DescriptionPanel({ challenge }: Props) {
</div>
</TabsContent>
<TabsContent value="solutions">
- <div className="p-4">solu</div>
+ <div className="p-4">solutions</div>
</TabsContent>
</Tabs>
</div>
diff --git a/src/components/challenge/editor/index.tsx b/src/components/challenge/editor/index.tsx
index 87d4f537..69ca85f0 100644
--- a/src/components/challenge/editor/index.tsx
+++ b/src/components/challenge/editor/index.tsx
@@ -1,7 +1,16 @@
'use client';
import Editor from '@monaco-editor/react';
+import { Settings } from 'lucide-react';
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
-import React from 'react';
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from '~/components/ui/dialog';
+import useLocalStorage from '~/utils/useLocalStorage';
+import { DEFAULT_SETTINGS, SettingsForm } from '../settings-form';
import { createTwoslashInlayProvider } from './twoslash';
import { VimStatusBar, loadVim } from './vimMode';
@@ -12,14 +21,13 @@ declare global {
var model: monaco.editor.ITextModel;
}
-const options: monaco.editor.IStandaloneEditorConstructionOptions = {
+const defaultOptions: monaco.editor.IStandaloneEditorConstructionOptions = {
lineNumbers: 'off',
tabSize: 2,
insertSpaces: false,
minimap: {
enabled: false,
},
- // readOnly: true,
};
type Monaco = typeof monaco;
@@ -88,7 +96,7 @@ const onMount =
globalThis.model = model;
globalThis.editor = editor;
- loadVim(editor);
+ loadVim(editor);
const ts = await (await monaco.languages.typescript.getTypeScriptWorker())(model.uri);
@@ -134,8 +142,31 @@ interface Props {
prompt: string;
}
export const CodePanel = ({ prompt }: Props) => {
+ const [settings] = useLocalStorage('settings', JSON.stringify(DEFAULT_SETTINGS));
+ const parsedSettings = JSON.parse(settings);
+ const options = {
+ ...defaultOptions,
+ ...parsedSettings,
+ } as monaco.editor.IStandaloneEditorConstructionOptions;
return (
<>
+ <div className="container flex items-end space-y-2 bg-muted py-4">
+ <div className="ml-auto flex w-full space-x-2 sm:justify-end">
+ <Dialog>
+ <DialogTrigger>
+ <Settings />
+ </DialogTrigger>
+ <DialogContent className="w-[200px]">
+ <DialogHeader>
+ <DialogTitle>Settings</DialogTitle>
+ <div className="py-4">
+ <SettingsForm />
+ </div>
+ </DialogHeader>
+ </DialogContent>
+ </Dialog>
+ </div>
+ </div>
<Editor
theme="vs-dark"
options={options}
diff --git a/src/components/challenge/settings-form.tsx b/src/components/challenge/settings-form.tsx
new file mode 100644
index 00000000..466ce2fe
--- /dev/null
+++ b/src/components/challenge/settings-form.tsx
@@ -0,0 +1,144 @@
+'use client';
+
+import { zodResolver } from '@hookform/resolvers/zod';
+import { useForm } from 'react-hook-form';
+import * as z from 'zod';
+
+import { Button } from '~/components/ui/button';
+import {
+ Form,
+ FormControl,
+ FormDescription,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from '~/components/ui/form';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '~/components/ui/select';
+import { toast } from '~/components/ui/use-toast';
+import useLocalStorage from '~/utils/useLocalStorage';
+
+const formSchema = z.object({
+ fontSize: z.string(),
+ bindings: z.string(),
+ tabSize: z.string(),
+});
+
+export type FormSchema = z.infer<typeof formSchema>;
+
+export const DEFAULT_SETTINGS = {
+ fontSize: '12',
+ bindings: 'standard',
+ tabSize: '2',
+};
+export function SettingsForm() {
+ const [settings, setSettings] = useLocalStorage('settings', JSON.stringify(DEFAULT_SETTINGS));
+ const parsedSettings = JSON.parse(settings) as FormSchema;
+ const form = useForm<FormSchema>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ fontSize: parsedSettings.fontSize,
+ bindings: parsedSettings.bindings,
+ tabSize: parsedSettings.tabSize,
+ },
+ });
+
+ function onSubmit(data: FormSchema) {
+ setSettings(JSON.stringify(data));
+ toast({
+ title: 'Settings updated!',
+ description: (
+ <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
+ <code className="text-white">{JSON.stringify(data, null, 2)}</code>
+ </pre>
+ ),
+ });
+ }
+
+ return (
+ <Form {...form}>
+ {/* eslint-disable-next-line @typescript-eslint/no-misused-promises */}
+ <form onSubmit={form.handleSubmit(onSubmit)}>
+ <FormField
+ control={form.control}
+ name="fontSize"
+ render={({ field }) => (
+ <FormItem className="mb-3">
+ <FormLabel>Font Size</FormLabel>
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder="Select a font size" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ <SelectItem value="12">12px</SelectItem>
+ <SelectItem value="13">13px</SelectItem>
+ <SelectItem value="14">14px</SelectItem>
+ <SelectItem value="15">15px</SelectItem>
+ <SelectItem value="16">16px</SelectItem>
+ <SelectItem value="17">17px</SelectItem>
+ <SelectItem value="18">18px</SelectItem>
+ <SelectItem value="19">19px</SelectItem>
+ <SelectItem value="20">20px</SelectItem>
+ <SelectItem value="21">21px</SelectItem>
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="bindings"
+ render={({ field }) => (
+ <FormItem className="mb-3">
+ <FormLabel>Key Bindings</FormLabel>
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder="Select a font size" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ <SelectItem value="standard">Standard</SelectItem>
+ <SelectItem value="vim">Vim</SelectItem>
+ <SelectItem value="emacs">Emacs</SelectItem>
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="tabSize"
+ render={({ field }) => (
+ <FormItem className="mb-3">
+ <FormLabel>Tab Size</FormLabel>
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
+ <FormControl>
+ <SelectTrigger>
+ <SelectValue placeholder="Select a tab size" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ <SelectItem value="2">2 spaces</SelectItem>
+ <SelectItem value="4">4 spaces</SelectItem>
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <Button type="submit">Submit</Button>
+ </form>
+ </Form>
+ );
+}
diff --git a/src/components/explore/difficulty-badge.tsx b/src/components/explore/difficulty-badge.tsx
new file mode 100644
index 00000000..ce869db8
--- /dev/null
+++ b/src/components/explore/difficulty-badge.tsx
@@ -0,0 +1,22 @@
+import { Difficulty } from '@prisma/client';
+import { Badge } from '../ui/badge';
+import clsx from 'clsx';
+
+interface Props {
+ difficulty: Difficulty;
+}
+export function DifficultyBadge({ difficulty }: Props) {
+ return (
+ <Badge
+ className={clsx({
+ 'bg-pink-300': difficulty === 'BEGINNER',
+ 'bg-green-300': difficulty === 'EASY',
+ 'bg-yellow-300': difficulty === 'MEDIUM',
+ 'bg-red-300': difficulty === 'HARD',
+ 'bg-orange-300': difficulty === 'EXTREME',
+ })}
+ >
+ {difficulty}
+ </Badge>
+ );
+}
diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsx
new file mode 100644
index 00000000..961602be
--- /dev/null
+++ b/src/components/explore/explore-card.tsx
@@ -0,0 +1,34 @@
+import { ArrowBigUp } from 'lucide-react';
+
+import { Challenges } from '.';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
+import { DifficultyBadge } from './difficulty-badge';
+
+interface Props {
+ challenge: Awaited<Challenges>[0];
+}
+export function ExploreCard({ challenge }: Props) {
+ return (
+ <Card>
+ <CardHeader className="grid grid-cols-[1fr_110px] items-start gap-4 space-y-0">
+ <div className="space-y-1">
+ <CardTitle>{challenge.name}</CardTitle>
+ <CardDescription>{challenge.description}</CardDescription>
+ </div>
+ </CardHeader>
+ <CardContent>
+ <div className="flex justify-between text-sm text-muted-foreground">
+ <div className="flex">
+ <div className="flex items-center">
+ <DifficultyBadge difficulty={challenge.difficulty} />
+ </div>
+ <div className="flex items-center">
+ <ArrowBigUp /> {challenge._count.Vote}
+ </div>
+ </div>
+ <div>Updated {challenge.updatedAt.toLocaleDateString()}</div>
+ </div>
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/src/components/explore/index.tsx b/src/components/explore/index.tsx
new file mode 100644
index 00000000..53998f62
--- /dev/null
+++ b/src/components/explore/index.tsx
@@ -0,0 +1,38 @@
+import { prisma } from '~/server/db';
+import { TypographyP } from '../ui/paragraph';
+import { TypographyH1 } from '../ui/typography/h1';
+import { ExploreSection } from './section';
+import { Suspense } from 'react';
+
+export function Explore() {
+ return (
+ <div className="flex h-full flex-col p-4">
+ <section className="mb-8 flex max-w-[980px] flex-col items-start gap-2 pt-4 md:pt-8">
+ <TypographyH1>Explore</TypographyH1>
+ <TypographyP>
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
+ ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
+ ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
+ est laborum
+ </TypographyP>
+ </section>
+
+ <Suspense fallback="loading...">
+ <ExploreSection title="Challenges" data={getChallenges} />
+ </Suspense>
+ </div>
+ );
+}
+
+export type Challenges = ReturnType<typeof getChallenges>;
+async function getChallenges() {
+ return prisma.challenge.findMany({
+ include: {
+ _count: {
+ select: { Vote: true },
+ },
+ },
+ });
+}
diff --git a/src/components/explore/section.tsx b/src/components/explore/section.tsx
new file mode 100644
index 00000000..d094033e
--- /dev/null
+++ b/src/components/explore/section.tsx
@@ -0,0 +1,25 @@
+import Link from 'next/link';
+import type { Challenges } from '.';
+import { TypographyH3 } from '../ui/typography/h3';
+import { ExploreCard } from './explore-card';
+
+interface Props {
+ title: string;
+ data(): Challenges;
+}
+
+export async function ExploreSection({ title, data }: Props) {
+ const challenges = await data();
+ return (
+ <div>
+ <TypographyH3 className="mb-3">{title}</TypographyH3>
+ <div className="grid grid-cols-3 gap-2">
+ {challenges.map((challenge) => (
+ <Link href={`/challenge/${challenge.id}`} key={challenge.id}>
+ <ExploreCard key={challenge.id} challenge={challenge} />
+ </Link>
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx
new file mode 100644
index 00000000..01f4de45
--- /dev/null
+++ b/src/components/ui/badge.tsx
@@ -0,0 +1,33 @@
+import * as React from 'react';
+import { cva, type VariantProps } from 'class-variance-authority';
+
+import { cn } from '~/utils/cn';
+
+const badgeVariants = cva(
+ 'inline-flex items-center border rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
+ {
+ variants: {
+ variant: {
+ default: 'bg-primary hover:bg-primary/80 border-transparent text-primary-foreground',
+ secondary:
+ 'bg-secondary hover:bg-secondary/80 border-transparent text-secondary-foreground',
+ destructive:
+ 'bg-destructive hover:bg-destructive/80 border-transparent text-destructive-foreground',
+ outline: 'text-foreground',
+ },
+ },
+ defaultVariants: {
+ variant: 'default',
+ },
+ },
+);
+
+export interface BadgeProps
+ extends React.HTMLAttributes<HTMLDivElement>,
+ VariantProps<typeof badgeVariants> {}
+
+function Badge({ className, variant, ...props }: BadgeProps) {
+ return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
+}
+
+export { Badge, badgeVariants };
diff --git a/src/components/ui/card.tsx b/src/components/ui/card.tsx
new file mode 100644
index 00000000..441a7e00
--- /dev/null
+++ b/src/components/ui/card.tsx
@@ -0,0 +1,56 @@
+import * as React from 'react';
+
+import { cn } from '~/utils/cn';
+
+const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn('rounded-lg border bg-card text-card-foreground shadow-sm', className)}
+ {...props}
+ />
+ ),
+);
+Card.displayName = 'Card';
+
+const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => (
+ <div ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
+ ),
+);
+CardHeader.displayName = 'CardHeader';
+
+const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
+ ({ className, ...props }, ref) => (
+ <h3
+ ref={ref}
+ className={cn('text-lg font-semibold leading-none tracking-tight', className)}
+ {...props}
+ />
+ ),
+);
+CardTitle.displayName = 'CardTitle';
+
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => (
+ <p ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
+));
+CardDescription.displayName = 'CardDescription';
+
+const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => (
+ <div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
+ ),
+);
+CardContent.displayName = 'CardContent';
+
+const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => (
+ <div ref={ref} className={cn(' flex items-center p-6 pt-0', className)} {...props} />
+ ),
+);
+CardFooter.displayName = 'CardFooter';
+
+export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx
new file mode 100644
index 00000000..bb387f5a
--- /dev/null
+++ b/src/components/ui/dialog.tsx
@@ -0,0 +1,102 @@
+'use client';
+
+import * as React from 'react';
+import * as DialogPrimitive from '@radix-ui/react-dialog';
+import { X } from 'lucide-react';
+
+import { cn } from '~/utils/cn';
+
+const Dialog = DialogPrimitive.Root;
+
+const DialogTrigger = DialogPrimitive.Trigger;
+
+const DialogPortal = ({ className, ...props }: DialogPrimitive.DialogPortalProps) => (
+ <DialogPrimitive.Portal className={cn(className)} {...props} />
+);
+DialogPortal.displayName = DialogPrimitive.Portal.displayName;
+
+const DialogOverlay = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ ref={ref}
+ className={cn(
+ 'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
+ className,
+ )}
+ {...props}
+ />
+));
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
+
+const DialogContent = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full',
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+));
+DialogContent.displayName = DialogPrimitive.Content.displayName;
+
+const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
+ <div className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} {...props} />
+);
+DialogHeader.displayName = 'DialogHeader';
+
+const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
+ {...props}
+ />
+);
+DialogFooter.displayName = 'DialogFooter';
+
+const DialogTitle = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn('text-lg font-semibold leading-none tracking-tight', className)}
+ {...props}
+ />
+));
+DialogTitle.displayName = DialogPrimitive.Title.displayName;
+
+const DialogDescription = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn('text-sm text-muted-foreground', className)}
+ {...props}
+ />
+));
+DialogDescription.displayName = DialogPrimitive.Description.displayName;
+
+export {
+ Dialog,
+ DialogTrigger,
+ DialogContent,
+ DialogHeader,
+ DialogFooter,
+ DialogTitle,
+ DialogDescription,
+};
diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx
new file mode 100644
index 00000000..a1cf6cf1
--- /dev/null
+++ b/src/components/ui/dropdown-menu.tsx
@@ -0,0 +1,187 @@
+'use client';
+
+import * as React from 'react';
+import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
+import { Check, ChevronRight, Circle } from 'lucide-react';
+
+import { cn } from '~/utils/cn';
+
+const DropdownMenu = DropdownMenuPrimitive.Root;
+
+const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
+
+const DropdownMenuGroup = DropdownMenuPrimitive.Group;
+
+const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
+
+const DropdownMenuSub = DropdownMenuPrimitive.Sub;
+
+const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
+
+const DropdownMenuSubTrigger = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+ }
+>(({ className, inset, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubTrigger
+ ref={ref}
+ className={cn(
+ 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent',
+ inset && 'pl-8',
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRight className="ml-auto h-4 w-4" />
+ </DropdownMenuPrimitive.SubTrigger>
+));
+DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
+
+const DropdownMenuSubContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubContent
+ ref={ref}
+ className={cn(
+ 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1',
+ className,
+ )}
+ {...props}
+ />
+));
+DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
+
+const DropdownMenuContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
+>(({ className, sideOffset = 4, ...props }, ref) => (
+ <DropdownMenuPrimitive.Portal>
+ <DropdownMenuPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cn(
+ 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
+ className,
+ )}
+ {...props}
+ />
+ </DropdownMenuPrimitive.Portal>
+));
+DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
+
+const DropdownMenuItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean;
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Item
+ ref={ref}
+ className={cn(
+ 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ inset && 'pl-8',
+ className,
+ )}
+ {...props}
+ />
+));
+DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
+
+const DropdownMenuCheckboxItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
+>(({ className, children, checked, ...props }, ref) => (
+ <DropdownMenuPrimitive.CheckboxItem
+ ref={ref}
+ className={cn(
+ 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ className,
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.CheckboxItem>
+));
+DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
+
+const DropdownMenuRadioItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
+>(({ className, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.RadioItem
+ ref={ref}
+ className={cn(
+ 'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ className,
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Circle className="h-2 w-2 fill-current" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.RadioItem>
+));
+DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
+
+const DropdownMenuLabel = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean;
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Label
+ ref={ref}
+ className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
+ {...props}
+ />
+));
+DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
+
+const DropdownMenuSeparator = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.Separator
+ ref={ref}
+ className={cn('-mx-1 my-1 h-px bg-muted', className)}
+ {...props}
+ />
+));
+DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
+
+const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
+ return (
+ <span className={cn('ml-auto text-xs tracking-widest opacity-60', className)} {...props} />
+ );
+};
+DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
+
+export {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuGroup,
+ DropdownMenuPortal,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuRadioGroup,
+};
diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx
new file mode 100644
index 00000000..c291bff7
--- /dev/null
+++ b/src/components/ui/form.tsx
@@ -0,0 +1,167 @@
+import * as React from 'react';
+import type * as LabelPrimitive from '@radix-ui/react-label';
+import { Slot } from '@radix-ui/react-slot';
+import {
+ Controller,
+ type ControllerProps,
+ type FieldPath,
+ type FieldValues,
+ FormProvider,
+ useFormContext,
+} from 'react-hook-form';
+
+import { cn } from '~/utils/cn';
+import { Label } from '~/components/ui/label';
+
+const Form = FormProvider;
+
+type FormFieldContextValue<
+ TFieldValues extends FieldValues = FieldValues,
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
+> = {
+ name: TName;
+};
+
+const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);
+
+const FormField = <
+ TFieldValues extends FieldValues = FieldValues,
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
+>({
+ ...props
+}: ControllerProps<TFieldValues, TName>) => {
+ return (
+ <FormFieldContext.Provider value={{ name: props.name }}>
+ <Controller {...props} />
+ </FormFieldContext.Provider>
+ );
+};
+
+const useFormField = () => {
+ const fieldContext = React.useContext(FormFieldContext);
+ const itemContext = React.useContext(FormItemContext);
+ const { getFieldState, formState } = useFormContext();
+
+ const fieldState = getFieldState(fieldContext.name, formState);
+
+ if (!fieldContext) {
+ throw new Error('useFormField should be used within <FormField>');
+ }
+
+ const { id } = itemContext;
+
+ return {
+ id,
+ name: fieldContext.name,
+ formItemId: `${id}-form-item`,
+ formDescriptionId: `${id}-form-item-description`,
+ formMessageId: `${id}-form-item-message`,
+ ...fieldState,
+ };
+};
+
+type FormItemContextValue = {
+ id: string;
+};
+
+const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
+
+const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
+ ({ className, ...props }, ref) => {
+ const id = React.useId();
+
+ return (
+ <FormItemContext.Provider value={{ id }}>
+ <div ref={ref} className={cn('space-y-2', className)} {...props} />
+ </FormItemContext.Provider>
+ );
+ },
+);
+FormItem.displayName = 'FormItem';
+
+const FormLabel = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
+>(({ className, ...props }, ref) => {
+ const { error, formItemId } = useFormField();
+
+ return (
+ <Label
+ ref={ref}
+ className={cn(error && 'text-destructive', className)}
+ htmlFor={formItemId}
+ {...props}
+ />
+ );
+});
+FormLabel.displayName = 'FormLabel';
+
+const FormControl = React.forwardRef<
+ React.ElementRef<typeof Slot>,
+ React.ComponentPropsWithoutRef<typeof Slot>
+>(({ ...props }, ref) => {
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
+
+ return (
+ <Slot
+ ref={ref}
+ id={formItemId}
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
+ aria-invalid={!!error}
+ {...props}
+ />
+ );
+});
+FormControl.displayName = 'FormControl';
+
+const FormDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => {
+ const { formDescriptionId } = useFormField();
+
+ return (
+ <p
+ ref={ref}
+ id={formDescriptionId}
+ className={cn('text-sm text-muted-foreground', className)}
+ {...props}
+ />
+ );
+});
+FormDescription.displayName = 'FormDescription';
+
+const FormMessage = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, children, ...props }, ref) => {
+ const { error, formMessageId } = useFormField();
+ const body = error ? String(error?.message) : children;
+
+ if (!body) {
+ return null;
+ }
+
+ return (
+ <p
+ ref={ref}
+ id={formMessageId}
+ className={cn('text-sm font-medium text-destructive', className)}
+ {...props}
+ >
+ {body}
+ </p>
+ );
+});
+FormMessage.displayName = 'FormMessage';
+
+export {
+ useFormField,
+ Form,
+ FormItem,
+ FormLabel,
+ FormControl,
+ FormDescription,
+ FormMessage,
+ FormField,
+};
diff --git a/src/components/ui/h1.tsx b/src/components/ui/h1.tsx
deleted file mode 100644
index 7e2e3a97..00000000
--- a/src/components/ui/h1.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-interface Props {
- children: React.ReactNode;
-}
-export function TypographyH1({ children }: Props) {
- return (
- <h1 className="scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl">
- {children}
- </h1>
- );
-}
diff --git a/src/components/ui/h2.tsx b/src/components/ui/h2.tsx
deleted file mode 100644
index bd964b4c..00000000
--- a/src/components/ui/h2.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-interface Props {
- children: React.ReactNode;
-}
-export function TypographyH2({ children }: Props) {
- return (
- <h2 className="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0">
- {children}
- </h2>
- );
-}
diff --git a/src/components/ui/h3.tsx b/src/components/ui/h3.tsx
deleted file mode 100644
index 318726ae..00000000
--- a/src/components/ui/h3.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-interface Props {
- children: React.ReactNode;
-}
-export function TypographyH3({ children }: Props) {
- return (
- <h3 className="scroll-m-20 text-2xl font-semibold tracking-tight">
- {children}
- </h3>
- );
-}
diff --git a/src/components/ui/label.tsx b/src/components/ui/label.tsx
new file mode 100644
index 00000000..18fbaeef
--- /dev/null
+++ b/src/components/ui/label.tsx
@@ -0,0 +1,21 @@
+'use client';
+
+import * as React from 'react';
+import * as LabelPrimitive from '@radix-ui/react-label';
+import { cva, type VariantProps } from 'class-variance-authority';
+
+import { cn } from '~/utils/cn';
+
+const labelVariants = cva(
+ 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
+);
+
+const Label = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
+>(({ className, ...props }, ref) => (
+ <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
+));
+Label.displayName = LabelPrimitive.Root.displayName;
+
+export { Label };
diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsx
index 8c3808b6..95574b03 100644
--- a/src/components/ui/navigation.tsx
+++ b/src/components/ui/navigation.tsx
@@ -24,43 +24,55 @@ export function Navigation() {
setMounted(true);
}, []);
- if (!mounted) {
- return null;
- }
-
return (
<header className="w-full">
<nav className="container flex h-14 items-center">
<div className="flex w-full items-center justify-between">
- <div>
+ <div className="flex">
+ <a className="mr-6 flex items-center space-x-2" href="/">
+ <svg
+ viewBox="0 0 24 24"
+ fill="currentColor"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ className="h-6 w-6"
+ >
+ <circle cx="12" cy="12" r="10"></circle>
+ </svg>
+ <span className="hidden font-bold sm:inline-block">type/hero</span>
+ </a>
<NavigationMenu>
<NavigationMenuList>
+ <NavigationMenuItem>
+ <Link href="/explore" legacyBehavior passHref>
+ <NavigationMenuLink className={navigationMenuTriggerStyle()}>
+ Explore
+ </NavigationMenuLink>
+ </Link>
+ </NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuTrigger>Something Nice</NavigationMenuTrigger>
<NavigationMenuContent>
<NavigationMenuLink>Nice</NavigationMenuLink>
</NavigationMenuContent>
</NavigationMenuItem>
- <NavigationMenuItem>
- <Link href="/docs" legacyBehavior passHref>
- <NavigationMenuLink className={navigationMenuTriggerStyle()}>
- Something Good
- </NavigationMenuLink>
- </Link>
- </NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</div>
<div className="flex items-center gap-4 pr-2">
- <button
- type="button"
- onClick={() => {
- setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');
- }}
- >
- {resolvedTheme === 'dark' && <Moon className="h-6 w-6" aria-hidden="true" />}
- {resolvedTheme === 'light' && <Sun className="h-6 w-6" aria-hidden="true" />}
- </button>
+ {mounted && (
+ <button
+ type="button"
+ onClick={() => {
+ setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');
+ }}
+ >
+ {resolvedTheme === 'dark' && <Moon className="h-6 w-6" aria-hidden="true" />}
+ {resolvedTheme === 'light' && <Sun className="h-6 w-6" aria-hidden="true" />}
+ </button>
+ )}
<button type="button">
<Bell className="h-6 w-6" aria-hidden="true" />
diff --git a/src/components/ui/paragraph.tsx b/src/components/ui/paragraph.tsx
new file mode 100644
index 00000000..cdb1fa78
--- /dev/null
+++ b/src/components/ui/paragraph.tsx
@@ -0,0 +1,6 @@
+interface Props {
+ children: React.ReactNode;
+}
+export function TypographyP({ children }: Props) {
+ return <p className="leading-7 [&:not(:first-child)]:mt-4">{children}</p>;
+}
diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx
new file mode 100644
index 00000000..cddf4ae8
--- /dev/null
+++ b/src/components/ui/select.tsx
@@ -0,0 +1,121 @@
+'use client';
+
+import * as React from 'react';
+import * as SelectPrimitive from '@radix-ui/react-select';
+import { Check, ChevronDown } from 'lucide-react';
+
+import { cn } from '~/utils/cn';
+
+const Select = SelectPrimitive.Root;
+
+const SelectGroup = SelectPrimitive.Group;
+
+const SelectValue = SelectPrimitive.Value;
+
+const SelectTrigger = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ 'flex h-10 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDown className="h-4 w-4 opacity-50" />
+ </SelectPrimitive.Icon>
+ </SelectPrimitive.Trigger>
+));
+SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
+
+const SelectContent = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
+>(({ className, children, position = 'popper', ...props }, ref) => (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ ref={ref}
+ className={cn(
+ 'relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
+ position === 'popper' &&
+ 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
+ className,
+ )}
+ position={position}
+ {...props}
+ >
+ <SelectPrimitive.Viewport
+ className={cn(
+ 'p-1',
+ position === 'popper' &&
+ 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+));
+SelectContent.displayName = SelectPrimitive.Content.displayName;
+
+const SelectLabel = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Label
+ ref={ref}
+ className={cn('py-1.5 pl-8 pr-2 text-sm font-semibold', className)}
+ {...props}
+ />
+));
+SelectLabel.displayName = SelectPrimitive.Label.displayName;
+
+const SelectItem = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Item
+ ref={ref}
+ className={cn(
+ 'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ className,
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
+
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+));
+SelectItem.displayName = SelectPrimitive.Item.displayName;
+
+const SelectSeparator = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Separator
+ ref={ref}
+ className={cn('-mx-1 my-1 h-px bg-muted', className)}
+ {...props}
+ />
+));
+SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
+
+export {
+ Select,
+ SelectGroup,
+ SelectValue,
+ SelectTrigger,
+ SelectContent,
+ SelectLabel,
+ SelectItem,
+ SelectSeparator,
+};
diff --git a/src/components/ui/separator.tsx b/src/components/ui/separator.tsx
new file mode 100644
index 00000000..3a46b2ff
--- /dev/null
+++ b/src/components/ui/separator.tsx
@@ -0,0 +1,26 @@
+'use client';
+
+import * as React from 'react';
+import * as SeparatorPrimitive from '@radix-ui/react-separator';
+
+import { cn } from '~/utils/cn';
+
+const Separator = React.forwardRef<
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
+>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
+ <SeparatorPrimitive.Root
+ ref={ref}
+ decorative={decorative}
+ orientation={orientation}
+ className={cn(
+ 'shrink-0 bg-border',
+ orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
+ className,
+ )}
+ {...props}
+ />
+));
+Separator.displayName = SeparatorPrimitive.Root.displayName;
+
+export { Separator };
diff --git a/src/components/ui/sign-in-out-button.tsx b/src/components/ui/sign-in-out-button.tsx
index f5c66cbe..30fb7d8f 100644
--- a/src/components/ui/sign-in-out-button.tsx
+++ b/src/components/ui/sign-in-out-button.tsx
@@ -1,16 +1,15 @@
'use client';
-import { signIn, signOut, useSession } from 'next-auth/react';
-
-export function SignInOutButton() {
- const { data: session, status } = useSession();
+import type { Session } from 'next-auth';
+import { signIn, signOut } from 'next-auth/react';
+export function SignInOutButton({ session }: { session: Session | null }) {
return (
<button
className="rounded-full bg-white/10 px-10 py-3 font-semibold text-white no-underline transition hover:bg-white/20"
- onClick={status === 'authenticated' ? () => void signOut() : () => void signIn()}
+ onClick={session ? () => void signOut() : () => void signIn()}
>
- {status === 'authenticated' ? 'Sign out' : 'Sign in'}
+ {session ? 'Sign out' : 'Sign in'}
</button>
);
}
diff --git a/src/components/ui/toast.tsx b/src/components/ui/toast.tsx
new file mode 100644
index 00000000..8e1a7469
--- /dev/null
+++ b/src/components/ui/toast.tsx
@@ -0,0 +1,122 @@
+import * as React from 'react';
+import * as ToastPrimitives from '@radix-ui/react-toast';
+import { cva, type VariantProps } from 'class-variance-authority';
+import { X } from 'lucide-react';
+
+import { cn } from '~/utils/cn';
+
+const ToastProvider = ToastPrimitives.Provider;
+
+const ToastViewport = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Viewport>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Viewport
+ ref={ref}
+ className={cn(
+ 'fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]',
+ className,
+ )}
+ {...props}
+ />
+));
+ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
+
+const toastVariants = cva(
+ 'group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full',
+ {
+ variants: {
+ variant: {
+ default: 'border bg-background',
+ destructive:
+ 'destructive group border-destructive bg-destructive text-destructive-foreground',
+ },
+ },
+ defaultVariants: {
+ variant: 'default',
+ },
+ },
+);
+
+const Toast = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Root>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & VariantProps<typeof toastVariants>
+>(({ className, variant, ...props }, ref) => {
+ return (
+ <ToastPrimitives.Root
+ ref={ref}
+ className={cn(toastVariants({ variant }), className)}
+ {...props}
+ />
+ );
+});
+Toast.displayName = ToastPrimitives.Root.displayName;
+
+const ToastAction = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Action>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Action
+ ref={ref}
+ className={cn(
+ 'inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive',
+ className,
+ )}
+ {...props}
+ />
+));
+ToastAction.displayName = ToastPrimitives.Action.displayName;
+
+const ToastClose = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Close>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Close
+ ref={ref}
+ className={cn(
+ 'absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600',
+ className,
+ )}
+ toast-close=""
+ {...props}
+ >
+ <X className="h-4 w-4" />
+ </ToastPrimitives.Close>
+));
+ToastClose.displayName = ToastPrimitives.Close.displayName;
+
+const ToastTitle = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Title>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Title ref={ref} className={cn('text-sm font-semibold', className)} {...props} />
+));
+ToastTitle.displayName = ToastPrimitives.Title.displayName;
+
+const ToastDescription = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Description>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Description
+ ref={ref}
+ className={cn('text-sm opacity-90', className)}
+ {...props}
+ />
+));
+ToastDescription.displayName = ToastPrimitives.Description.displayName;
+
+type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
+
+type ToastActionElement = React.ReactElement<typeof ToastAction>;
+
+export {
+ type ToastProps,
+ type ToastActionElement,
+ ToastProvider,
+ ToastViewport,
+ Toast,
+ ToastTitle,
+ ToastDescription,
+ ToastClose,
+ ToastAction,
+};
diff --git a/src/components/ui/toaster.tsx b/src/components/ui/toaster.tsx
new file mode 100644
index 00000000..eb72cc22
--- /dev/null
+++ b/src/components/ui/toaster.tsx
@@ -0,0 +1,33 @@
+'use client';
+
+import {
+ Toast,
+ ToastClose,
+ ToastDescription,
+ ToastProvider,
+ ToastTitle,
+ ToastViewport,
+} from '~/components/ui/toast';
+import { useToast } from '~/components/ui/use-toast';
+
+export function Toaster() {
+ const { toasts } = useToast();
+
+ return (
+ <ToastProvider>
+ {toasts.map(function ({ id, title, description, action, ...props }) {
+ return (
+ <Toast key={id} {...props}>
+ <div className="grid gap-1">
+ {title && <ToastTitle>{title}</ToastTitle>}
+ {description && <ToastDescription>{description}</ToastDescription>}
+ </div>
+ {action}
+ <ToastClose />
+ </Toast>
+ );
+ })}
+ <ToastViewport />
+ </ToastProvider>
+ );
+}
diff --git a/src/components/ui/typography/h1.tsx b/src/components/ui/typography/h1.tsx
new file mode 100644
index 00000000..588bae52
--- /dev/null
+++ b/src/components/ui/typography/h1.tsx
@@ -0,0 +1,13 @@
+import { cn } from '~/utils/cn';
+
+interface Props extends React.HTMLAttributes<HTMLHeadingElement> {
+ children: React.ReactNode;
+}
+
+export function TypographyH1({ children, className, ...props }: Props) {
+ return (
+ <h1 className={cn('scroll-m-20 font-bold tracking-tight lg:text-5xl', className)} {...props}>
+ {children}
+ </h1>
+ );
+}
diff --git a/src/components/ui/typography/h2.tsx b/src/components/ui/typography/h2.tsx
new file mode 100644
index 00000000..7a771c92
--- /dev/null
+++ b/src/components/ui/typography/h2.tsx
@@ -0,0 +1,19 @@
+import { cn } from '~/utils/cn';
+
+interface Props extends React.HTMLAttributes<HTMLHeadingElement> {
+ children: React.ReactNode;
+}
+
+export function TypographyH2({ children, className, ...props }: Props) {
+ return (
+ <h2
+ className={cn(
+ 'scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0',
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ </h2>
+ );
+}
diff --git a/src/components/ui/typography/h3.tsx b/src/components/ui/typography/h3.tsx
new file mode 100644
index 00000000..b4ade342
--- /dev/null
+++ b/src/components/ui/typography/h3.tsx
@@ -0,0 +1,13 @@
+import { cn } from '~/utils/cn';
+
+interface Props extends React.HTMLAttributes<HTMLHeadingElement> {
+ children: React.ReactNode;
+}
+
+export function TypographyH3({ children, className, ...props }: Props) {
+ return (
+ <h3 className={cn('scroll-m-20 text-2xl font-semibold tracking-tight', className)} {...props}>
+ {children}
+ </h3>
+ );
+}
diff --git a/src/components/ui/typography/large.tsx b/src/components/ui/typography/large.tsx
new file mode 100644
index 00000000..45458abc
--- /dev/null
+++ b/src/components/ui/typography/large.tsx
@@ -0,0 +1,6 @@
+interface Props {
+ children: React.ReactNode;
+}
+export function TypographyLarge({ children }: Props) {
+ return <div className="text-lg font-semibold">{children}</div>;
+}
diff --git a/src/components/ui/use-toast.ts b/src/components/ui/use-toast.ts
new file mode 100644
index 00000000..1be87a02
--- /dev/null
+++ b/src/components/ui/use-toast.ts
@@ -0,0 +1,187 @@
+// Inspired by react-hot-toast library
+import * as React from 'react';
+
+import type { ToastActionElement, ToastProps } from '~/components/ui/toast';
+
+const TOAST_LIMIT = 1;
+const TOAST_REMOVE_DELAY = 1000000;
+
+type ToasterToast = ToastProps & {
+ id: string;
+ title?: React.ReactNode;
+ description?: React.ReactNode;
+ action?: ToastActionElement;
+};
+
+const actionTypes = {
+ ADD_TOAST: 'ADD_TOAST',
+ UPDATE_TOAST: 'UPDATE_TOAST',
+ DISMISS_TOAST: 'DISMISS_TOAST',
+ REMOVE_TOAST: 'REMOVE_TOAST',
+} as const;
+
+let count = 0;
+
+function genId() {
+ count = (count + 1) % Number.MAX_VALUE;
+ return count.toString();
+}
+
+type ActionType = typeof actionTypes;
+
+type Action =
+ | {
+ type: ActionType['ADD_TOAST'];
+ toast: ToasterToast;
+ }
+ | {
+ type: ActionType['UPDATE_TOAST'];
+ toast: Partial<ToasterToast>;
+ }
+ | {
+ type: ActionType['DISMISS_TOAST'];
+ toastId?: ToasterToast['id'];
+ }
+ | {
+ type: ActionType['REMOVE_TOAST'];
+ toastId?: ToasterToast['id'];
+ };
+
+interface State {
+ toasts: ToasterToast[];
+}
+
+const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
+
+const addToRemoveQueue = (toastId: string) => {
+ if (toastTimeouts.has(toastId)) {
+ return;
+ }
+
+ const timeout = setTimeout(() => {
+ toastTimeouts.delete(toastId);
+ dispatch({
+ type: 'REMOVE_TOAST',
+ toastId: toastId,
+ });
+ }, TOAST_REMOVE_DELAY);
+
+ toastTimeouts.set(toastId, timeout);
+};
+
+export const reducer = (state: State, action: Action): State => {
+ switch (action.type) {
+ case 'ADD_TOAST':
+ return {
+ ...state,
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
+ };
+
+ case 'UPDATE_TOAST':
+ return {
+ ...state,
+ toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)),
+ };
+
+ case 'DISMISS_TOAST': {
+ const { toastId } = action;
+
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
+ // but I'll keep it here for simplicity
+ if (toastId) {
+ addToRemoveQueue(toastId);
+ } else {
+ state.toasts.forEach((toast) => {
+ addToRemoveQueue(toast.id);
+ });
+ }
+
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === toastId || toastId === undefined
+ ? {
+ ...t,
+ open: false,
+ }
+ : t,
+ ),
+ };
+ }
+ case 'REMOVE_TOAST':
+ if (action.toastId === undefined) {
+ return {
+ ...state,
+ toasts: [],
+ };
+ }
+ return {
+ ...state,
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
+ };
+ }
+};
+
+const listeners: Array<(state: State) => void> = [];
+
+let memoryState: State = { toasts: [] };
+
+function dispatch(action: Action) {
+ memoryState = reducer(memoryState, action);
+ listeners.forEach((listener) => {
+ listener(memoryState);
+ });
+}
+
+type Toast = Omit<ToasterToast, 'id'>;
+
+function toast({ ...props }: Toast) {
+ const id = genId();
+
+ const update = (props: ToasterToast) =>
+ dispatch({
+ type: 'UPDATE_TOAST',
+ toast: { ...props, id },
+ });
+ const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
+
+ dispatch({
+ type: 'ADD_TOAST',
+ toast: {
+ ...props,
+ id,
+ open: true,
+ onOpenChange: (open) => {
+ if (!open) dismiss();
+ },
+ },
+ });
+
+ return {
+ id: id,
+ dismiss,
+ update,
+ };
+}
+
+function useToast() {
+ const [state, setState] = React.useState<State>(memoryState);
+
+ React.useEffect(() => {
+ listeners.push(setState);
+ return () => {
+ const index = listeners.indexOf(setState);
+ if (index > -1) {
+ listeners.splice(index, 1);
+ }
+ };
+ }, [state]);
+
+ return {
+ ...state,
+ toast,
+ dismiss: (toastId?: string) => dispatch({ type: 'DISMISS_TOAST', toastId }),
+ };
+}
+
+export { useToast, toast };
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 9ab02bea..61e4b883 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -1,82 +1,79 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
-
+
@layer base {
:root {
--background: 0 0% 100%;
- --foreground: 222.2 47.4% 11.2%;
-
- --muted: 210 40% 96.1%;
- --muted-foreground: 215.4 16.3% 46.9%;
-
+ --foreground: 240 10% 3.9%;
+
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+
--popover: 0 0% 100%;
- --popover-foreground: 222.2 47.4% 11.2%;
-
+ --popover-foreground: 240 10% 3.9%;
+
--card: 0 0% 100%;
- --card-foreground: 222.2 47.4% 11.2%;
-
- --border: 214.3 31.8% 91.4%;
- --input: 214.3 31.8% 91.4%;
-
- --primary: 222.2 47.4% 11.2%;
- --primary-foreground: 210 40% 98%;
-
- --secondary: 210 40% 96.1%;
- --secondary-foreground: 222.2 47.4% 11.2%;
-
- --accent: 210 40% 96.1%;
- --accent-foreground: 222.2 47.4% 11.2%;
-
- --destructive: 0 100% 50%;
- --destructive-foreground: 210 40% 98%;
-
- --ring: 215 20.2% 65.1%;
-
+ --card-foreground: 240 10% 3.9%;
+
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+
+ --primary: 240 5.9% 10%;
+ --primary-foreground: 0 0% 98%;
+
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: ;
+
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+
+ --ring: 240 5% 64.9%;
+
--radius: 0.5rem;
}
-
+
.dark {
- --background: 224 71% 4%;
- --foreground: 213 31% 91%;
-
- --muted: 223 10% 11%;
- --muted-foreground: 215.4 16.3% 56.9%;
-
- --popover: 224 71% 4%;
- --popover-foreground: 215 20.2% 65.1%;
-
- --card: 224 71% 4%;
- --card-foreground: 213 31% 91%;
-
- --border: 216 34% 17%;
- --input: 216 34% 17%;
-
- --primary: 210 40% 98%;
- --primary-foreground: 222.2 47.4% 1.2%;
-
- --secondary: 222.2 47.4% 11.2%;
- --secondary-foreground: 210 40% 98%;
-
- --accent: 216 34% 17%;
- --accent-foreground: 210 40% 98%;
-
- --destructive: 0 63% 31%;
- --destructive-foreground: 210 40% 98%;
-
- --ring: 216 34% 17%;
-
- --radius: 0.5rem;
+ --background: 240 10% 3.9%;
+ --foreground: 0 0% 98%;
+
+ --muted: 240 3.7% 15.9%;
+ --muted-foreground: 240 5% 64.9%;
+
+ --popover: 240 10% 3.9%;
+ --popover-foreground: 0 0% 98%;
+
+ --card: 240 10% 3.9%;
+ --card-foreground: 0 0% 98%;
+
+ --border: 240 3.7% 15.9%;
+ --input: 240 3.7% 15.9%;
+
+ --primary: 0 0% 98%;
+ --primary-foreground: 240 5.9% 10%;
+
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+
+ --accent: 240 3.7% 15.9%;
+ --accent-foreground: ;
+
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 85.7% 97.3%;
+
+ --ring: 240 3.7% 15.9%;
}
}
-
+
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
- font-feature-settings: "rlig" 1, "calt" 1;
}
}
diff --git a/src/utils/useLocalStorage.ts b/src/utils/useLocalStorage.ts
new file mode 100644
index 00000000..3309cd20
--- /dev/null
+++ b/src/utils/useLocalStorage.ts
@@ -0,0 +1,27 @@
+import { useState } from 'react';
+
+const useLocalStorage = (key: string, initialValue: string): [string, (v: string) => void] => {
+ const [storedValue, setStoredValue] = useState(() => {
+ try {
+ return window.localStorage.getItem(key) || initialValue;
+ } catch (error) {
+ console.error(error);
+ return initialValue;
+ }
+ });
+
+ const setValue = (value: string) => {
+ try {
+ setStoredValue(value);
+ window.localStorage.setItem(key, value);
+
+ localStorage.setItem(key, value);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ return [storedValue, setValue];
+};
+
+export default useLocalStorage;
diff --git a/tailwind.config.js b/tailwind.config.js
new file mode 100644
index 00000000..0377ea1d
--- /dev/null
+++ b/tailwind.config.js
@@ -0,0 +1,76 @@
+/** @type {import('tailwindcss').Config} */
+module.exports = {
+ darkMode: ["class"],
+ content: [
+ './pages/**/*.{ts,tsx}',
+ './components/**/*.{ts,tsx}',
+ './app/**/*.{ts,tsx}',
+ './src/**/*.{ts,tsx}',
+ ],
+ theme: {
+ container: {
+ center: true,
+ padding: "2rem",
+ screens: {
+ "2xl": "1400px",
+ },
+ },
+ extend: {
+ colors: {
+ border: "hsl(var(--border))",
+ input: "hsl(var(--input))",
+ ring: "hsl(var(--ring))",
+ background: "hsl(var(--background))",
+ foreground: "hsl(var(--foreground))",
+ primary: {
+ DEFAULT: "hsl(var(--primary))",
+ foreground: "hsl(var(--primary-foreground))",
+ },
+ secondary: {
+ DEFAULT: "hsl(var(--secondary))",
+ foreground: "hsl(var(--secondary-foreground))",
+ },
+ destructive: {
+ DEFAULT: "hsl(var(--destructive))",
+ foreground: "hsl(var(--destructive-foreground))",
+ },
+ muted: {
+ DEFAULT: "hsl(var(--muted))",
+ foreground: "hsl(var(--muted-foreground))",
+ },
+ accent: {
+ DEFAULT: "hsl(var(--accent))",
+ foreground: "hsl(var(--accent-foreground))",
+ },
+ popover: {
+ DEFAULT: "hsl(var(--popover))",
+ foreground: "hsl(var(--popover-foreground))",
+ },
+ card: {
+ DEFAULT: "hsl(var(--card))",
+ foreground: "hsl(var(--card-foreground))",
+ },
+ },
+ borderRadius: {
+ lg: "var(--radius)",
+ md: "calc(var(--radius) - 2px)",
+ sm: "calc(var(--radius) - 4px)",
+ },
+ keyframes: {
+ "accordion-down": {
+ from: { height: 0 },
+ to: { height: "var(--radix-accordion-content-height)" },
+ },
+ "accordion-up": {
+ from: { height: "var(--radix-accordion-content-height)" },
+ to: { height: 0 },
+ },
+ },
+ animation: {
+ "accordion-down": "accordion-down 0.2s ease-out",
+ "accordion-up": "accordion-up 0.2s ease-out",
+ },
+ },
+ },
+ plugins: [require("tailwindcss-animate")],
+}
\ No newline at end of file