Skip to content

Commit

Permalink
chore: readd website
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 16, 2024
1 parent 92bfbbe commit 9dd3f0f
Show file tree
Hide file tree
Showing 32 changed files with 1,436 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ coverage
############################
.node_history
.vercel
website/.next
21 changes: 21 additions & 0 deletions website/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "zinc",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
14 changes: 14 additions & 0 deletions website/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
baseDirectory: __dirname
})

const eslintConfig = [...compat.extends('next/core-web-vitals', 'next/typescript')]

export default eslintConfig
5 changes: 5 additions & 0 deletions website/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
7 changes: 7 additions & 0 deletions website/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
37 changes: 37 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "splashy",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-slot": "~1.1.1",
"@radix-ui/react-toast": "~1.2.3",
"class-variance-authority": "~0.7.1",
"http-body": "~1.0.12",
"lucide-react": "~0.468.0",
"next": "15.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-dropzone": "~14.3.5",
"splashy": "6.0.0-3",
"sugar-high": "~0.7.5",
"tailwind-merge": "~2.5.5",
"tailwindcss-animate": "~1.0.7"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
8 changes: 8 additions & 0 deletions website/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};

export default config;
9 changes: 9 additions & 0 deletions website/src/app/[...colors]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ColorVisualizer from '@/components/color-visualizer'

export default function Page () {
return (
<>
<ColorVisualizer />
</>
)
}
65 changes: 65 additions & 0 deletions website/src/app/api/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// @ts-expect-error ssh
import splashy from 'splashy'

const hex2rgb = (hex: string) => {
const bigint = parseInt(hex.slice(1), 16)
const r = (bigint >> 16) & 255
const g = (bigint >> 8) & 255
const b = bigint & 255
return { r, g, b }
}

const rgb2hsl = (r: number, g: number, b: number) => {
r /= 255
g /= 255
b /= 255
const max = Math.max(r, g, b)
const min = Math.min(r, g, b)
let h = 0,
s = 0
const l = (max + min) / 2

if (max !== min) {
const d = max - min
s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0)
break
case g:
h = (b - r) / d + 2
break
case b:
h = (r - g) / d + 4
break
}
h /= 6
}

return {
h: Math.round(h * 360),
s: Math.round(s * 100),
l: Math.round(l * 100)
}
}

export const POST = async (request: Request) => {
const formData = await request.formData()
const file = formData.get('file') as File
const bytes = await file.arrayBuffer()

const palette = await splashy(Buffer.from(bytes))

const paletteWithDetails = palette.map((color: string) => {
const rgb = hex2rgb(color)
const hsl = rgb2hsl(rgb.r, rgb.g, rgb.b)
return {
hex: color,
rgb: `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,
rgba: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 1)`,
hsl: `hsl(${hsl.h}, ${hsl.s}%, ${hsl.l}%)`
}
})

return Response.json(paletteWithDetails)
}
10 changes: 10 additions & 0 deletions website/src/app/debugger/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Debugger } from '@/components/debugger'
import { ContainerLayout } from '@/components/layout'

export default function Page () {
return (
<ContainerLayout>
<Debugger />
</ContainerLayout>
)
}
10 changes: 10 additions & 0 deletions website/src/app/faq/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FAQ } from '@/components/faq'
import { ContainerLayout } from '@/components/layout'

export default function Page () {
return (
<ContainerLayout>
<FAQ />
</ContainerLayout>
)
}
Binary file added website/src/app/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions website/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseLayout } from '@/components/layout'

export default function Layout ({ children }: { children: React.ReactNode }) {
return <BaseLayout>{children}</BaseLayout>
}
10 changes: 10 additions & 0 deletions website/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ColorExtractor } from '@/components/color-extractor'
import { ContainerLayout } from '@/components/layout'

export default function Page () {
return (
<ContainerLayout>
<ColorExtractor />
</ContainerLayout>
)
}
Loading

0 comments on commit 9dd3f0f

Please sign in to comment.