Skip to content

Commit

Permalink
attribute music to Deezer
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemis21 committed Feb 12, 2024
1 parent 8095bc5 commit af8d5d3
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 53 deletions.
11 changes: 11 additions & 0 deletions web/components/Attribution.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Card } from "./Card";
import wordMark from "../deezer_wordmark.png";

export function Attribution() {
// If https://deezerbrand.com ever gets updated, this should be changed to follow those guidelines.
return (
<Card title="Music from" link="https://deezer.com" centred>
<img className="deezer_wordmark" src={wordMark} alt="Deezer" />
</Card>
);
}
45 changes: 21 additions & 24 deletions web/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ type ImageDef = {
alt: string;
};

type Flags = {
good?: boolean;
bad?: boolean;
active?: boolean;
padded?: boolean;
centred?: boolean;
};

type CardProps = {
title: ReactNode;
children?: ReactNode;
onClick?: MouseEventHandler<HTMLDivElement>;
image?: ImageDef;
icon?: IconDefinition;
link?: string;
progress?: number;
} & Flags;

export function Card({
title,
children,
Expand All @@ -17,31 +35,10 @@ export function Card({
icon,
link,
progress,
good,
bad,
active,
extended,
}: {
title: ReactNode;
children?: ReactNode;
onClick?: MouseEventHandler<HTMLDivElement>;
image?: ImageDef;
icon?: IconDefinition;
link?: string;
progress?: number;
good?: boolean;
bad?: boolean;
active?: boolean;
extended?: boolean;
}) {
...flags
}: CardProps) {
const inner = Inner({ icon, image, title, progress, sub: children });
const outerClass = classModifiers("card", {
good,
bad,
active,
extended,
button: link || onClick,
});
const outerClass = classModifiers("card", { button: link || onClick, ...flags });
if (link && link.startsWith("/")) {
return (
<Link to={link} className={outerClass}>
Expand Down
6 changes: 2 additions & 4 deletions web/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useState } from "react";
export type GuessQuery = {
query: string;
id: number | null;
}
};

export function Game() {
const { gameId } = useParams();
Expand All @@ -25,9 +25,7 @@ export function Game() {
}
let game;
if (data.won === null) {
game = (
<Guesses game={data} guessQuery={guess} setGuessQuery={setGuess} />
);
game = <Guesses game={data} guessQuery={guess} setGuessQuery={setGuess} />;
} else {
game = <GameOver game={data} />;
}
Expand Down
8 changes: 7 additions & 1 deletion web/components/GameOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Scrollable } from "./Scrollable";
import { TrackCard } from "./TrackCard";
import { faCrown, faHeartCrack, faPlay } from "@fortawesome/free-solid-svg-icons";
import { Card } from "./Card";
import { Attribution } from "./Attribution";

const COMMENTS = [
"wow!!",
Expand All @@ -27,7 +28,11 @@ export function GameOver({ game }: { game: Game }) {
const comment = COMMENTS[Math.min(guesses.length, COMMENTS.length) - 1];
outcome = (
<Card title={<>You won!&ensp;&bull;&ensp;{type}</>} icon={faCrown} good>
You took <b>{guesses.length} {guessPlural}</b> - {comment}
You took{" "}
<b>
{guesses.length} {guessPlural}
</b>{" "}
- {comment}
</Card>
);
} else {
Expand All @@ -42,6 +47,7 @@ export function GameOver({ game }: { game: Game }) {
<div className="card_stack">
{outcome}
<TrackCard track={track} link />
<Attribution />
<Card title="New Game" icon={faPlay} link="/">
Click to play again
</Card>
Expand Down
4 changes: 1 addition & 3 deletions web/components/Guess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export function NewGuess({
<Card title={search} progress={fractionElapsed} active>
<label htmlFor="new_guess" className="search_label">
<p>Start typing a song title or artist for suggestions.</p>
{remainingTime && (
<p>{(remainingTime / 1000).toFixed(2)}s remaining</p>
)}
{remainingTime && <p>{(remainingTime / 1000).toFixed(2)}s remaining</p>}
</label>
</Card>
);
Expand Down
6 changes: 3 additions & 3 deletions web/components/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export function Info() {
const daily = <GameType game={{ isDaily: true }} />;
return (
<Scrollable>
<div className="card_stack card_stack--centred">
<Card title="How to Play" extended>
<div className="card_stack">
<Card title="How to Play" padded centred>
<ol className="fa-ul">
<li>
<FontAwesomeIcon icon={faPlay} listItem />
Expand Down Expand Up @@ -52,7 +52,7 @@ export function Info() {
</li>
</ol>
</Card>
<Card title="About" extended>
<Card title="About" padded centred>
<p>
<b>Beatdrop</b> is a name-that-tune music guessing game inspired
by the now-discontinued Heardle.
Expand Down
2 changes: 2 additions & 0 deletions web/components/Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import { Scrollable } from "./Scrollable";
import { Card } from "./Card";
import { Attribution } from "./Attribution";

export function Start() {
const { data, error } = useRecentGames();
Expand All @@ -28,6 +29,7 @@ export function Start() {
buttons.push(<UnlimitedButton key="unlimited" />);
buttons.push(<TimedButton key="timed" />);
}
buttons.push(<Attribution />);
return (
<Scrollable>
<div className="card_stack">{buttons}</div>
Expand Down
Binary file added web/deezer_wordmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 18 additions & 18 deletions web/sass/card.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
flex-direction: column
gap: 1rem

.card_stack--centred .card
align-items: center

// if there is no sub OR there is no thumb, centre the title
&:not(:has(.card__sub)), &:not(:has(.card__icon, .card__image))
.card__title
justify-self: center
text-align: center

// if there is only an icon and a title, centre them together
&:has(.card__icon):not(:has(.card__sub))
display: flex
justify-content: center

.card__icon
font-size: 2rem

.card
border: 0
text-decoration: none
Expand Down Expand Up @@ -86,12 +69,29 @@
&.card--with-sub
grid-template-areas: "thumb title" "thumb sub"

.card--extended
.card--padded
padding: 2rem

.card__title
margin-bottom: 0.5rem

.card--centred
place-items: center

// if there is no sub OR there is no thumb, centre the title
&:not(:has(.card__sub)), &:not(:has(.card__icon, .card__image))
.card__title
justify-self: center
text-align: center

// if there is only an icon and a title, centre them together
&:has(.card__icon):not(:has(.card__sub))
display: flex
justify-content: center

.card__icon
font-size: 2rem

.card--button
cursor: pointer
transition: transform 100ms linear
Expand Down
5 changes: 5 additions & 0 deletions web/sass/index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ main
.title, .sub
margin: 0
text-align: center

.deezer_wordmark
max-width: 100%
max-height: 2.5rem
margin-top: 0.5rem
1 change: 1 addition & 0 deletions web/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "*.png";

0 comments on commit af8d5d3

Please sign in to comment.