diff --git a/next.config.js b/next.config.js index c10e07d..f6b0fe2 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,14 @@ /** @type {import('next').NextConfig} */ const nextConfig = { output: "standalone", + images: { + remotePatterns: [ + { + protocol: "https", + hostname: "i.scdn.co", + }, + ], + }, }; module.exports = nextConfig; diff --git a/src/app/form.tsx b/src/app/form.tsx index c6a298d..0a723d0 100644 --- a/src/app/form.tsx +++ b/src/app/form.tsx @@ -3,7 +3,7 @@ import { useEffect, useState } from "react"; import * as Spotify from "spotify-api.js"; import { pushTrack, searchTracks } from "./actions"; -import Track from "./track"; +import { TrackHeader, TrackItem } from "./track_list"; import { useRouter } from "next/navigation"; export default function Form() { @@ -38,13 +38,25 @@ export default function Form() { value={query} onChange={(e) => setQuery(e.target.value)} /> - {results.map((track) => ( - onTrackClick(track)} - /> - ))} + {results.length > 0 && ( + <> + + + + + + {results.map((track, index) => ( + onTrackClick(track)} + /> + ))} + +
+ + )} ); } diff --git a/src/app/track.module.css b/src/app/track.module.css index 4a816c7..43690c0 100644 --- a/src/app/track.module.css +++ b/src/app/track.module.css @@ -1,36 +1,44 @@ -.container { - height: 150px; - display: grid; - grid-template-columns: 25px 150px 1fr 1fr auto; - grid-gap: 20px; - margin: 5px; +.table { + width: 100%; + border-collapse: collapse; + table-layout: auto; + text-align: left; +} + +.table td { + padding: 5px; +} + +.table th { + padding: 5px; +} + +table .absorbing_column { + width: 100%; +} + +table .cover_column { + width: 120px; +} + +.index { + text-align: center; + font-size: 1.5em; } .cover { - width: 150px; - height: 150px; + width: 120px; + height: 120px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } -.index { - height: 150px; - line-height: 150px; - text-align: center; -} - .title { - margin-top: 50px; color: black; - height: 25px; - line-height: 25px; } .artist { color: #777777; - height: 25px; - line-height: 25px; - margin-bottom: 50px; } diff --git a/src/app/track.tsx b/src/app/track.tsx index b868428..6859fb5 100644 --- a/src/app/track.tsx +++ b/src/app/track.tsx @@ -1,3 +1,4 @@ +import Image from "next/image"; import * as Spotify from "spotify-api.js"; import { DispatchWithoutAction } from "react"; import styles from "./track.module.css"; @@ -9,20 +10,28 @@ interface Props { export default function TrackCover({ track, onClick }: Props) { return ( -
-
{"▸"}
- album cover -
-
{track.name}
-
- {track.artists.map((artist) => artist.name).join(", ")} -
-
-
+ + + + + + + + +
{"▸"} + album cover + +
{track.name}
+
+ {track.artists.map((artist) => artist.name).join(", ")} +
+
); } diff --git a/src/app/track_list.module.css b/src/app/track_list.module.css index 91b6821..932eef4 100644 --- a/src/app/track_list.module.css +++ b/src/app/track_list.module.css @@ -1,26 +1,25 @@ -.row { - height: 50px; - display: grid; - grid-template-columns: 25px 50px 1fr 1fr 100px; - grid-gap: 20px; - margin: 5px; +.table { + width: 100%; + border-collapse: collapse; + table-layout: auto; + text-align: left; } -.header { - color: #999999; - padding-bottom: 10px; +.table td { + padding: 5px; } -.header .row { - height: 25px; +.table th { + padding: 5px; } -.header hr { - height: 1px; - border-width: 0; - border-color: transparent; +table .cover_column { + width: 50px; +} + +.header { color: #999999; - background-color: #999999; + border-bottom: 1px solid #999999; } .track { @@ -48,12 +47,8 @@ .title { color: black; - height: 25px; - line-height: 25px; } .artist { color: #777777; - height: 25px; - line-height: 25px; } diff --git a/src/app/track_list.tsx b/src/app/track_list.tsx index 28131ca..551c769 100644 --- a/src/app/track_list.tsx +++ b/src/app/track_list.tsx @@ -1,3 +1,4 @@ +import Image from "next/image"; import { DispatchWithoutAction } from "react"; import * as Spotify from "spotify-api.js"; import styles from "./track_list.module.css"; @@ -21,22 +22,19 @@ const formatDuration = (milliseconds: number) => { export function TrackHeader() { return ( -
-
-
{"#"}
-
Titre
-
-
Album
-
Durée
-
-
-
+ + {"#"} + Title + + Album + Duration + ); } export function TrackItem({ index, track, onClick }: ItemProps) { return ( -
-
{`${index + 1}.`}
- album cover -
+ {`${index + 1}.`} + + album cover + +
{track.name}
{track.artists.map((artist) => artist.name).join(", ")}
-
-
{track.album?.name}
-
{formatDuration(track.duration)}
-
+ + {track.album?.name ?? "-"} + {formatDuration(track.duration)} + ); } interface ListProps { items: Spotify.Track[]; + onClick?: DispatchWithoutAction; } -export default function TrackList({ items }: ListProps) { +export default function TrackList({ items, onClick }: ListProps) { return ( -
- - {items.map((track, index) => ( - - ))} -
+ + + + + + {items.map((track, index) => ( + + ))} + +
); }