Skip to content

Commit

Permalink
landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekg999 committed Aug 25, 2024
1 parent b10455c commit a8be54e
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 110 deletions.
Binary file modified bun.lockb
Binary file not shown.
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
"preview": "vite preview"
},
"dependencies": {
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.436.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/bun": "^1.1.8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
Expand Down
9 changes: 2 additions & 7 deletions secret-worker/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
```
npm install
npm run dev
```
# Cloudflare Worker Handling /api

```
npm run deploy
```
Uses Cloudflare D1 for storage, with Drizzle ORM.
128 changes: 98 additions & 30 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,103 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useState } from 'react';
import { Copy, Link, AlertCircle } from 'lucide-react';
import { type RequestSecretSchema } from '../secret-worker/src/db/schema'

function App() {
const [count, setCount] = useState(0)
const OneTimeSecret = () => {
const [secret, setSecret] = useState('');
const [generatedLink, setGeneratedLink] = useState('');
const [inputEnabled, setInputEnabled] = useState(true);
const [error, setError] = useState('');

const handleCreateLink = () => {
const data = secret.trim();
if (!data.trim()) {
setError('Please enter a secret to create a link.');
return;
}

setInputEnabled(false);

const fetchData = async () => {
const response = await fetch('/api/new', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ data: data.trim() } as RequestSecretSchema),
});

if (response.ok) {
const data = await response.json();
setGeneratedLink(`${window.location.origin}/secret/${data.id}`);
} else {
setGeneratedLink('');
setError('An error occurred while creating the secret link. Please refresh and try again.');
}
};

fetchData();
}

const handleCopyLink = () => {
navigator.clipboard.writeText(generatedLink);
};

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
<div className="min-h-screen bg-gradient-to-br from-gray-900 to-gray-800 flex items-center justify-center p-4">
<div className="bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-md border border-gray-700">
<h1 className="text-2xl font-bold text-gray-100 mb-4 text-center">Create One-Time Secret</h1>
<textarea
className="w-full h-32 p-2 border border-gray-600 rounded-md focus:ring-2 focus:ring-purple-500 focus:border-transparent resize-none bg-gray-700 text-gray-100 disabled:opacity-50 disabled:cursor-not-allowed"
placeholder="Enter your secret here..."
value={secret}
onChange={(e) => setSecret(e.target.value)}
disabled={!inputEnabled}
maxLength={10000}
/>
<button
className={`mt-4 w-full bg-purple-600 text-white font-bold py-2 px-4 rounded-md transition duration-300 ease-in-out flex items-center justify-center ${!generatedLink
? 'hover:bg-purple-700 hover:shadow-lg transform hover:-translate-y-0.5'
: 'opacity-50 cursor-not-allowed'
}`}
onClick={handleCreateLink}
disabled={!inputEnabled}
>
<Link className="mr-2" size={18} />
Create Secret Link
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>

{generatedLink && (
<div className="mt-4">
<p className="text-sm text-gray-400 mb-2">Your secret link:</p>
<div className="flex items-center bg-gray-700 p-2 rounded-md">
<input
type="text"
readOnly
value={generatedLink}
className="flex-grow bg-transparent text-sm text-gray-300 focus:outline-none"
/>
<button
onClick={handleCopyLink}
className="ml-2 text-purple-400 hover:text-purple-300 transition duration-300 ease-in-out transform hover:scale-110"
title="Copy to clipboard"
>
<Copy size={18} />
</button>
</div>
</div>
)}

{error && (
<div className="mt-4 bg-red-900 border border-red-700 text-red-100 px-4 py-3 rounded relative" role="alert">
<div className="flex items-center">
<AlertCircle className="mr-2" size={18} />
<span className="block sm:inline pl-2 pr-2">{error}</span>
</div>
</div>
)}
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}

export default App
</div>
);
};

export default OneTimeSecret;
1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

123 changes: 60 additions & 63 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,68 @@
@tailwind components;
@tailwind utilities;

:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--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%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
@layer base {
* {
@apply border-border;
}
a:hover {
color: #747bff;
body {
@apply bg-background text-foreground;
}
button {
background-color: #f9f9f9;
}
}
}
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
Loading

0 comments on commit a8be54e

Please sign in to comment.