Skip to content

Commit f693f71

Browse files
committed
[ref] major redesign, complete project refactoring
1 parent 09967e4 commit f693f71

40 files changed

+1127
-649
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE

Lines changed: 660 additions & 21 deletions
Large diffs are not rendered by default.

env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ namespace NodeJS {
44
GITHUB_AUTHOR: string
55
GITHUB_REPO: string
66
COLORNAMES_REPO: string
7-
DISCORD_WEBHOOK_URL: string
87
}
98
}

next.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
env: {
4-
AUTHOR_NAME: 'guko',
5-
GITHUB_AUTHOR: 'https://github.com/gukodev',
6-
GITHUB_REPO: 'https://github.com/gukodev/pyro',
4+
AUTHOR_NAME: 'nokya',
5+
GITHUB_AUTHOR: 'https://github.com/n0ky4',
6+
GITHUB_REPO: 'https://github.com/n0ky4/pyro',
77
COLORNAMES_REPO: 'https://github.com/meodai/color-names',
88
},
99
}

src/app/[color]/page.tsx

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import ColorCard from '@/components/ColorCard'
22
import ColorDetails from '@/components/ColorDetails'
3-
import ColorList from '@/components/ColorList'
4-
import ColorTheory from '@/components/ColorTheory'
53
import Footer from '@/components/Footer'
64
import NavBar from '@/components/NavBar'
7-
import Palette from '@/components/Palette'
85
import RegenerateColorMobileButton from '@/components/RegenerateColorMobileButton'
9-
import ColorInfo from '@/core/ColorInfo'
106
import { IColorInfo } from '@/core/types'
117
import { getFullLengthHex, isValidColor, removeHash } from '@/util/colorFormat'
12-
import { Metadata } from 'next'
8+
// import { Metadata } from 'next'
9+
import { Items } from '@/components/Items'
10+
import MainContainer from '@/components/MainContainer'
11+
import colorInfo from '@/core/colorInfo'
1312
import { notFound, redirect } from 'next/navigation'
14-
import { Item } from '../page'
1513

1614
interface ColorPageProps {
1715
params: {
@@ -24,74 +22,45 @@ interface ColorPageProps {
2422

2523
let data: IColorInfo | null = null
2624

27-
export async function generateMetadata(): Promise<Metadata> {
28-
if (!data) return {}
25+
// export async function generateMetadata(): Promise<Metadata> {
26+
// if (!data) return {}
2927

30-
const icon = {
31-
url: `/favicon?hex=${removeHash(data.hex)}`,
32-
type: 'image/svg+xml',
33-
}
28+
// const icon = {
29+
// url: `/favicon?hex=${removeHash(data.hex)}`,
30+
// type: 'image/svg+xml',
31+
// }
3432

35-
return {
36-
title: `pyro - ${data.hex}`,
37-
themeColor: data.hex,
38-
icons: {
39-
icon,
40-
shortcut: icon,
41-
},
42-
}
43-
}
33+
// return {
34+
// title: `pyro - ${data.hex}`,
35+
// // themeColor: data.hex,
36+
// icons: {
37+
// icon,
38+
// shortcut: icon,
39+
// },
40+
// }
41+
// }
4442

4543
export default async function ColorPage({ params, searchParams }: ColorPageProps) {
46-
const { color } = params
47-
const fromRandom = searchParams?.r === '' || !!searchParams?.r
44+
const { color } = await params
45+
const rParam = (await searchParams)?.r
46+
const fromRandom = rParam === '' || !rParam
4847

4948
if (!isValidColor(color)) return notFound()
5049
if (removeHash(color).length === 3) return redirect(`/${getFullLengthHex(color)}`)
5150

52-
data = new ColorInfo().getColorInfo(color)
53-
54-
const items: Item[] = [
55-
{
56-
label: 'Tons escuros',
57-
component: <Palette colors={data.palettes.shades} linkColors />,
58-
},
59-
{
60-
label: 'Tons claros',
61-
component: <Palette colors={data.palettes.tints} linkColors />,
62-
},
63-
{
64-
label: 'Hue',
65-
component: <Palette colors={data.palettes.hues} linkColors />,
66-
},
67-
{
68-
id: 'theory',
69-
component: <ColorTheory colors={data.palettes.theory} />,
70-
},
71-
{
72-
label: 'Cores relacionadas',
73-
component: <ColorList colors={data.related} />,
74-
},
75-
]
51+
data = colorInfo.getColorInfo(color)
7652

7753
return (
7854
<>
79-
<main className='mb-48'>
55+
<MainContainer>
8056
<RegenerateColorMobileButton fromRandom={fromRandom} />
8157
<NavBar />
82-
<div className='w-full max-w-screen-lg mx-auto px-4'>
83-
<div className='flex flex-col gap-8'>
84-
<ColorCard data={data} />
85-
<ColorDetails data={data} />
86-
{items.map((x) => (
87-
<div className='flex flex-col gap-2' key={x.id || x.label}>
88-
{x.label && <h1 className='text-2xl font-bold'>{x.label}</h1>}
89-
{x.component}
90-
</div>
91-
))}
92-
</div>
58+
<div className='flex flex-col gap-8'>
59+
<ColorCard data={data} />
60+
<ColorDetails data={data} />
61+
<Items data={data} />
9362
</div>
94-
</main>
63+
</MainContainer>
9564
<Footer />
9665
</>
9766
)

src/app/api/daily-color/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import ColorInfo from '@/core/ColorInfo'
1+
import colorInfo from '@/core/colorInfo'
22
import { NextResponse } from 'next/server'
33

44
export const dynamic = 'force-dynamic'
55
export const revalidate = 0
66

77
export async function GET() {
8-
const dailyColor = new ColorInfo().getDailyColor()
8+
const dailyColor = colorInfo.getDailyColor()
99
return NextResponse.json(dailyColor)
1010
}

src/app/api/random-palette/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PaletteGenerator from '@/core/PaletteGenerator'
1+
import palette from '@/core/paletteGenerator'
22
import { NextRequest, NextResponse } from 'next/server'
33

44
export async function GET(req: NextRequest) {
@@ -11,6 +11,6 @@ export async function GET(req: NextRequest) {
1111
})
1212
}
1313

14-
const palette = new PaletteGenerator().getRandomPalette()
15-
return NextResponse.json(palette)
14+
const pal = palette.getRandomPalette()
15+
return NextResponse.json(pal)
1616
}

src/app/api/random/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import ColorGenerator from '@/core/ColorGenerator'
1+
import color from '@/core/colorGenerator'
22
import { NextResponse } from 'next/server'
33

44
export const dynamic = 'force-dynamic'
55
export const revalidate = 0
66

77
export async function GET() {
8-
const hex = new ColorGenerator().getRandomColor('named')
8+
const hex = color.getRandomColor('named')
9+
910
return new NextResponse(hex, {
1011
headers: {
1112
'content-type': 'text/plain',

src/app/api/reportError/route.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/app/api/suggestions/[query]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ColorInfo from '@/core/ColorInfo'
1+
import colorInfo from '@/core/colorInfo'
22
import { formatQuery } from '@/util/format'
33
import { NextRequest, NextResponse } from 'next/server'
44

@@ -15,7 +15,7 @@ export async function GET(req: NextRequest, { params }: Context) {
1515
const formattedQuery = formatQuery(query)
1616
if (!formattedQuery) return NextResponse.json({ error: true }, { status: 400 })
1717

18-
const suggestions = new ColorInfo().getSuggestions(formattedQuery)
18+
const suggestions = colorInfo.getSuggestions(formattedQuery)
1919

2020
return NextResponse.json({
2121
query,

0 commit comments

Comments
 (0)