Skip to content

Commit

Permalink
fix: goals sometimes do not have highlight clips
Browse files Browse the repository at this point in the history
When a goal has just been scored, there won't be a highlight clip.
Adjust the UX so that the play clip button is not shown in that case.
  • Loading branch information
smoak committed Nov 29, 2023
1 parent d223b31 commit c060b82
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/api/gamecenter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export type GamecenterLandingSummaryScoringGoal = {
readonly name: string;
readonly teamAbbrev: string;
readonly headshot: string;
readonly highlightClip: number;
readonly highlightClip?: number;
readonly goalsToDate: number;
readonly awayScore: number;
readonly homeScore: number;
Expand Down
41 changes: 41 additions & 0 deletions app/components/ScoringDetail/HighlightClipButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useState } from "react";
import { Dialog } from "@headlessui/react";
import { PlayCircleIcon } from "../../PlayCircleIcon";
import { HighlightPlayer } from "../HighlightPlayer";

type HighlightClipButtonProps = {
readonly clipId?: number;
};

export const HighlightClipButton = ({ clipId }: HighlightClipButtonProps) => {
const [isVideoPlayerOpen, setVideoPlayerOpen] = useState(false);

if (clipId == null) {
return null;
}

return (
<>
<div className="flex flex-col pl-3">
<div className="flex flex-row items-center">
<button onClick={() => setVideoPlayerOpen(true)}>
<PlayCircleIcon size="md" />
Play highlight clip
</button>
</div>
</div>
<Dialog
open={isVideoPlayerOpen}
onClose={() => setVideoPlayerOpen(false)}
className="relative z-50"
>
<div className="fixed inset-0 bg-black/30" aria-hidden="true" />
<div className="fixed inset-0 flex w-screen items-center justify-center p-4">
<Dialog.Panel className="h-[calc(100%-1rem)] max-h-full w-full max-w-2xl rounded bg-white">
<HighlightPlayer videoId={clipId} />
</Dialog.Panel>
</div>
</Dialog>
</>
);
};
27 changes: 2 additions & 25 deletions app/components/ScoringDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Dialog } from "@headlessui/react";
import { PlayCircleIcon } from "../PlayCircleIcon";
import { PlayerAvatar } from "../PlayerAvatar";
import { TeamLogo } from "../TeamLogo";
import type { ScoringPlay, TeamAbbreviation } from "../types";
import { QuickScore } from "./QuickScore";
import { ScoringType } from "./ScoringType";
import { HighlightPlayer } from "./HighlightPlayer";
import { useState } from "react";
import { HighlightClipButton } from "./HighlightClipButton";

type ScoringDetailProps = {
readonly scoringPlay: ScoringPlay;
Expand Down Expand Up @@ -43,7 +40,6 @@ const AssistInfo = ({
export const ScoringDetail = ({
scoringPlay,
}: ScoringDetailProps): JSX.Element => {
const [isVideoPlayerOpen, setVideoPlayerOpen] = useState(false);
const {
goalScorer,
awayScore,
Expand Down Expand Up @@ -83,14 +79,7 @@ export const ScoringDetail = ({
/>
</span>
</div>
<div className="flex flex-col pl-3">
<div className="flex flex-row items-center">
<button onClick={() => setVideoPlayerOpen(true)}>
<PlayCircleIcon size="md" />
Play highlight clip
</button>
</div>
</div>
<HighlightClipButton clipId={highlightClip} />
</div>
<div className="flex gap-6">
<div className="flex flex-col">
Expand All @@ -109,18 +98,6 @@ export const ScoringDetail = ({
</div>
</div>
</div>
<Dialog
open={isVideoPlayerOpen}
onClose={() => setVideoPlayerOpen(false)}
className="relative z-50"
>
<div className="fixed inset-0 bg-black/30" aria-hidden="true" />
<div className="fixed inset-0 flex w-screen items-center justify-center p-4">
<Dialog.Panel className="h-[calc(100%-1rem)] max-h-full w-full max-w-2xl rounded bg-white">
<HighlightPlayer videoId={highlightClip} />
</Dialog.Panel>
</div>
</Dialog>
</>
);
};
2 changes: 1 addition & 1 deletion app/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ScoringPlay = {
readonly headshot: string;
};
readonly teamAbbrev: string;
readonly highlightClip: number;
readonly highlightClip?: number;
readonly awayScore: number;
readonly homeScore: number;
readonly goalType: GoalType;
Expand Down

1 comment on commit c060b82

@vercel
Copy link

@vercel vercel bot commented on c060b82 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nhl-remix – ./

nhl-remix.vercel.app
nhl-remix-git-main-smoak.vercel.app
nhl-remix-smoak.vercel.app

Please sign in to comment.