Compare commits

...

3 Commits

Author SHA1 Message Date
470b38c7a3 fix colors when album has no vibrantColor #1 2026-02-21 22:23:13 +03:00
ac093d6a51 replace deprecated function 2026-02-21 22:10:47 +03:00
e1e5a8451a rename to music-dl 2026-02-21 00:45:52 +03:00
4 changed files with 21 additions and 10 deletions

2
go.mod
View File

@@ -1,4 +1,4 @@
module music-downloader module music-dl
go 1.25.0 go 1.25.0

View File

@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"music-downloader/monochrome" "music-dl/monochrome"
"net/http" "net/http"
"os" "os"
"path" "path"

View File

@@ -105,10 +105,17 @@ export default function App() {
<div <div
key={album.id} key={album.id}
className="flex gap-2 p-2" className="flex gap-2 p-2"
style={{ style={
backgroundColor: album.vibrantColor, album.vibrantColor
color: contrastColor, ? {
}} backgroundColor: album.vibrantColor,
color: contrastColor,
}
: {
backgroundColor: "white",
color: "black",
}
}
> >
<img <img
src={`/cover/${album.cover}`} src={`/cover/${album.cover}`}
@@ -126,7 +133,11 @@ export default function App() {
<button <button
type="button" type="button"
className="cursor-pointer ml-auto mt-auto py-1 px-2" className="cursor-pointer ml-auto mt-auto py-1 px-2"
style={{ backgroundColor: oppositeColor, color: contrastColor }} style={
album.vibrantColor
? { backgroundColor: oppositeColor, color: contrastColor }
: { backgroundColor: "black", color: "white" }
}
onClick={() => handleDownloadAlbum(album)} onClick={() => handleDownloadAlbum(album)}
> >
Download Download

View File

@@ -13,9 +13,9 @@ export function getContrastYIQ(hexcolor: string) {
} }
// Parse RGB values // Parse RGB values
const r = parseInt(hexcolor.substr(0, 2), 16); const r = parseInt(hexcolor.substring(0, 2), 16);
const g = parseInt(hexcolor.substr(2, 2), 16); const g = parseInt(hexcolor.substring(2, 2), 16);
const b = parseInt(hexcolor.substr(4, 2), 16); const b = parseInt(hexcolor.substring(4, 2), 16);
// Calculate YIQ brightness // Calculate YIQ brightness
const yiq = (r * 299 + g * 587 + b * 114) / 1000; const yiq = (r * 299 + g * 587 + b * 114) / 1000;