Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 74e2f36

Browse files
authored
Merge pull request #2 from boostvolt/feat/NOTICKET_add-colors
feat: add more gradients and adjust footer opacity [NOTICKET]
2 parents 4262a1e + c374bbe commit 74e2f36

File tree

19 files changed

+74
-22
lines changed

19 files changed

+74
-22
lines changed

.eslintrc.cjs renamed to .eslintrc.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
const fs = require("fs")
33

44
module.exports = {
5-
extends: [
6-
"next",
7-
"prettier",
8-
"plugin:@typescript-eslint/recommended",
9-
"plugin:tailwindcss/recommended",
10-
],
5+
extends: ["next", "prettier", "plugin:@typescript-eslint/recommended", "plugin:tailwindcss/recommended"],
116
parserOptions: {
127
babelOptions: {
138
presets: [require.resolve("next/babel")],
@@ -73,4 +68,4 @@ function getDirectories(path) {
7368
return fs.readdirSync(path).filter(function (file) {
7469
return fs.statSync(path + "/" + file).isDirectory()
7570
})
76-
}
71+
}
File renamed without changes.

app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ThemeProvider } from "@/components/theme-provider"
33
import "@/styles/globals.css"
44

55
export const metadata: Metadata = {
6-
title: "iCover",
6+
title: "iCover - Apple-Style Cover Creator",
77
description:
88
"Design a captivating and visually appealing cover artwork for your Apple Music playlist to engage listeners and convey the theme or mood of the curated songs.",
99
keywords: [
@@ -50,7 +50,7 @@ export const metadata: Metadata = {
5050
],
5151
authors: [{ name: "Boostvolt", url: "https://github.com/boostvolt" }],
5252
openGraph: {
53-
title: "iCover",
53+
title: "iCover - Apple-Style Cover Creator",
5454
description:
5555
"Design a captivating and visually appealing cover artwork for your Apple Music playlist to engage listeners and convey the theme or mood of the curated songs.",
5656
url: "https://icover.vercel.app",

app/page.tsx

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod"
44
import html2canvas from "html2canvas"
55
import { Cog, Info } from "lucide-react"
66
import Image from "next/image"
7+
import { useEffect } from "react"
78
import { useForm } from "react-hook-form"
89
import * as z from "zod"
910
import AppleMusic from "@/components/icons/apple-music"
@@ -36,6 +37,7 @@ const formSchema = z.object({
3637
subTitle: z.string(),
3738
footer: z.string(),
3839
gradient: z.string(),
40+
color: z.string(),
3941
})
4042

4143
export default function Home() {
@@ -48,8 +50,11 @@ export default function Home() {
4850
subTitle: "",
4951
footer: "",
5052
gradient: "0",
53+
color: "",
5154
}),
5255
})
56+
const { dirtyFields } = form.formState
57+
const isEdited = dirtyFields.bigTitle ?? dirtyFields.subTitle ?? dirtyFields.footer
5358

5459
const handleDownload = () => {
5560
const element = document.getElementById("coverElement")
@@ -63,6 +68,10 @@ export default function Home() {
6368
}
6469
}
6570

71+
useEffect(() => {
72+
form.setValue("color", "")
73+
}, [form.watch("gradient")])
74+
6675
return (
6776
<main className="flex justify-center">
6877
<style jsx global>{`
@@ -112,7 +121,9 @@ export default function Home() {
112121
<div id="coverElement" style={{ width: 300, height: 300, position: "relative" }}>
113122
{/* Background Image */}
114123
<Image
115-
src={`/assets/gradients/${form.watch("gradient")}.png`}
124+
src={`/assets/${
125+
form.watch("color") === "" ? `gradients/${form.watch("gradient")}` : `colors/${form.watch("color")}`
126+
}.png`}
116127
loading="eager"
117128
alt={`Gradient ${form.watch("gradient")}`}
118129
layout="fill"
@@ -127,15 +138,19 @@ export default function Home() {
127138
)}
128139
{/* Big Title */}
129140
<div style={{ position: "absolute", top: 55, left: 25 }}>
130-
<h1 className="text-[3em] font-semibold text-white">{form.watch("bigTitle")}</h1>
141+
<h1 className="text-[3em] font-semibold text-white">
142+
{isEdited ? form.watch("bigTitle") : "Big Title"}
143+
</h1>
131144
</div>
132145
{/* Sub Title */}
133146
<div style={{ position: "absolute", top: 105, left: 25 }}>
134-
<h2 className="text-[2.5em] font-thin text-white">{form.watch("subTitle")}</h2>
147+
<h2 className="text-[2.5em] font-thin text-white">
148+
{isEdited ? form.watch("subTitle") : "Sub Title"}
149+
</h2>
135150
</div>
136151
{/* Footer */}
137152
<div style={{ position: "absolute", bottom: 25, left: 25 }}>
138-
<h3 className="text-sm text-slate-300">{form.watch("footer")}</h3>
153+
<h3 className="text-sm text-white text-opacity-60">{isEdited ? form.watch("footer") : "Footer"}</h3>
139154
</div>
140155
</div>
141156
</div>
@@ -163,7 +178,11 @@ export default function Home() {
163178
render={({ field }) => (
164179
<FormItem>
165180
<FormControl>
166-
<Switch checked={field.value} onCheckedChange={field.onChange} title="Toggle Apple Music Logo"/>
181+
<Switch
182+
checked={field.value}
183+
onCheckedChange={field.onChange}
184+
title="Toggle Apple Music Logo"
185+
/>
167186
</FormControl>
168187
</FormItem>
169188
)}
@@ -215,7 +234,6 @@ export default function Home() {
215234
<TabsTrigger value="color" className="w-full">
216235
Color
217236
</TabsTrigger>
218-
<Separator orientation="vertical" />
219237
<TabsTrigger value="image" className="w-full">
220238
Image
221239
</TabsTrigger>
@@ -232,14 +250,19 @@ export default function Home() {
232250
defaultValue={field.value}
233251
className="grid grid-cols-5 gap-4"
234252
>
235-
{[...Array(30)].map((_, index) => (
253+
{[...Array(40)].map((_, index) => (
236254
<Label
237255
key={index}
238256
htmlFor={`${index}`}
239257
className="rounded-full border-2 border-muted bg-popover p-0.5 hover:cursor-pointer hover:bg-accent hover:text-accent-foreground [&:has([data-state=checked])]:border-primary"
240258
>
241259
<Avatar className="h-full w-full">
242-
<RadioGroupItem value={`${index}`} id={`${index}`} className="sr-only" title={`Gradient ${index}`}/>
260+
<RadioGroupItem
261+
value={`${index}`}
262+
id={`${index}`}
263+
className="sr-only"
264+
title={`Gradient ${index}`}
265+
/>
243266
<Image
244267
src={`/assets/gradients/${index}.png`}
245268
alt={`Gradient ${index}`}
@@ -256,11 +279,45 @@ export default function Home() {
256279
/>
257280
</TabsContent>
258281
<TabsContent value="color" className="mt-4">
259-
<Alert>
260-
<Info className="h-4 w-4" />
261-
<AlertTitle>Coming soon</AlertTitle>
262-
<AlertDescription>Color selection will be available soon.</AlertDescription>
263-
</Alert>
282+
<FormField
283+
control={form.control}
284+
name="color"
285+
render={({ field }) => (
286+
<FormItem>
287+
<FormControl>
288+
<RadioGroup
289+
onValueChange={field.onChange}
290+
defaultValue={field.value}
291+
className="grid grid-cols-5 gap-4"
292+
>
293+
{[...Array(7)].map((_, index) => (
294+
<Label
295+
key={index}
296+
htmlFor={`${index}`}
297+
className="rounded-full border-2 border-muted bg-popover p-0.5 hover:cursor-pointer hover:bg-accent hover:text-accent-foreground [&:has([data-state=checked])]:border-primary"
298+
>
299+
<Avatar className="h-full w-full">
300+
<RadioGroupItem
301+
value={`${index}`}
302+
id={`${index}`}
303+
className="sr-only"
304+
title={`Color ${index}`}
305+
/>
306+
<Image
307+
src={`/assets/colors/${index}.png`}
308+
alt={`Color ${index}`}
309+
width={70}
310+
height={70}
311+
/>
312+
</Avatar>
313+
</Label>
314+
))}
315+
</RadioGroup>
316+
</FormControl>
317+
</FormItem>
318+
)}
319+
/>
320+
{/* <Input id="image" type="color" /> */}
264321
</TabsContent>
265322
<TabsContent value="image" className="mt-4">
266323
<Alert>

public/assets/colors/0.png

382 KB
Loading

public/assets/colors/1.png

393 KB
Loading

public/assets/colors/2.png

377 KB
Loading

public/assets/colors/3.png

376 KB
Loading

public/assets/colors/4.png

112 KB
Loading

public/assets/colors/5.png

366 KB
Loading

0 commit comments

Comments
 (0)