mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-09 07:28:55 -07:00
* feat: single SOT for themes + basic custom support * fix: adjust colors for yuu theme * feat: Allow loading of environment variables from file (#20) * feat: allow loading of environment variables from file * Panic if a file for an environment variable cannot be read * Use log.Fatalf + os.Exit instead of panic * fix: remove supurfluous call to os.Exit() --------- Co-authored-by: adaexec <nixos-git.s1pht@simplelogin.com> Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * chore: add pr test workflow * chore: changelog * feat: make all activity grids configurable * fix: adjust activity grid style * fix: make background gradient consistent size * revert: remove year from activity grid opts * style: adjust top item list min size to 200px * feat: add support for custom themes * fix: stabilized the order of top items * chore: update changelog * feat: native import & export * fix: use correct request body for alias requests * fix: clear input when closing edit modal * chore: changelog * docs: make endpoint clearer for some apps * feat: add ui and handler for export * fix: fix pr test workflow --------- Co-authored-by: adaexec <78047743+adaexec@users.noreply.github.com> Co-authored-by: adaexec <nixos-git.s1pht@simplelogin.com>
102 lines
4.1 KiB
TypeScript
102 lines
4.1 KiB
TypeScript
import { Link, useNavigate } from "react-router";
|
|
import ArtistLinks from "./ArtistLinks";
|
|
import { imageUrl, type Album, type Artist, type Track, type PaginatedResponse } from "api/api";
|
|
|
|
type Item = Album | Track | Artist;
|
|
|
|
interface Props<T extends Item> {
|
|
data: PaginatedResponse<T>
|
|
separators?: ConstrainBoolean
|
|
type: "album" | "track" | "artist";
|
|
className?: string,
|
|
}
|
|
|
|
export default function TopItemList<T extends Item>({ data, separators, type, className }: Props<T>) {
|
|
|
|
return (
|
|
<div className={`flex flex-col gap-1 ${className} min-w-[200px]`}>
|
|
{data.items.map((item, index) => {
|
|
const key = `${type}-${item.id}`;
|
|
return (
|
|
<div
|
|
key={key}
|
|
style={{ fontSize: 12 }}
|
|
className={`${
|
|
separators && index !== data.items.length - 1 ? 'border-b border-(--color-fg-tertiary) mb-1 pb-2' : ''
|
|
}`}
|
|
>
|
|
<ItemCard item={item} type={type} key={type+item.id} />
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ItemCard({ item, type }: { item: Item; type: "album" | "track" | "artist" }) {
|
|
|
|
const itemClasses = `flex items-center gap-2`
|
|
|
|
switch (type) {
|
|
case "album": {
|
|
const album = item as Album;
|
|
|
|
return (
|
|
<div style={{fontSize: 12}} className={itemClasses}>
|
|
<Link to={`/album/${album.id}`}>
|
|
<img loading="lazy" src={imageUrl(album.image, "small")} alt={album.title} className="min-w-[48px]" />
|
|
</Link>
|
|
<div>
|
|
<Link to={`/album/${album.id}`} className="hover:text-(--color-fg-secondary)">
|
|
<span style={{fontSize: 14}}>{album.title}</span>
|
|
</Link>
|
|
<br />
|
|
{album.is_various_artists ?
|
|
<span className="color-fg-secondary">Various Artists</span>
|
|
:
|
|
<div>
|
|
<ArtistLinks artists={album.artists ? [album.artists[0]] : [{id: 0, name: 'Unknown Artist'}]}/>
|
|
</div>
|
|
}
|
|
<div className="color-fg-secondary">{album.listen_count} plays</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
case "track": {
|
|
const track = item as Track;
|
|
|
|
return (
|
|
<div style={{fontSize: 12}} className={itemClasses}>
|
|
<Link to={`/track/${track.id}`}>
|
|
<img loading="lazy" src={imageUrl(track.image, "small")} alt={track.title} className="min-w-[48px]" />
|
|
</Link>
|
|
<div>
|
|
<Link to={`/track/${track.id}`} className="hover:text-(--color-fg-secondary)">
|
|
<span style={{fontSize: 14}}>{track.title}</span>
|
|
</Link>
|
|
<br />
|
|
<div>
|
|
<ArtistLinks artists={track.artists || [{id: 0, Name: 'Unknown Artist'}]}/>
|
|
</div>
|
|
<div className="color-fg-secondary">{track.listen_count} plays</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
case "artist": {
|
|
const artist = item as Artist;
|
|
return (
|
|
<div style={{fontSize: 12}}>
|
|
<Link className={itemClasses+' mt-1 mb-[6px] hover:text-(--color-fg-secondary)'} to={`/artist/${artist.id}`}>
|
|
<img loading="lazy" src={imageUrl(artist.image, "small")} alt={artist.name} className="min-w-[48px]" />
|
|
<div>
|
|
<span style={{fontSize: 14}}>{artist.name}</span>
|
|
<div className="color-fg-secondary">{artist.listen_count} plays</div>
|
|
</div>
|
|
</Link>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
}
|