-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand bottle panel to include overview
- Loading branch information
Showing
7 changed files
with
158 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { Bottle } from "@peated/server/types"; | ||
import BottleIcon from "@peated/web/components/assets/Bottle"; | ||
import { Link } from "@remix-run/react"; | ||
import { formatCategoryName } from "../lib/strings"; | ||
import BottleMetadata from "./bottleMetadata"; | ||
import PageHeader from "./pageHeader"; | ||
|
||
export default function BottleHeader({ bottle }: { bottle: Bottle }) { | ||
return ( | ||
<PageHeader | ||
icon={BottleIcon} | ||
title={bottle.fullName} | ||
titleExtra={ | ||
<BottleMetadata | ||
data={bottle} | ||
className="w-full truncate text-center text-slate-500 lg:text-left" | ||
/> | ||
} | ||
metadata={ | ||
(bottle.category || bottle.statedAge) && ( | ||
<div className="flex w-full min-w-[150px] flex-col items-center justify-center gap-x-1 text-slate-500 lg:w-auto lg:items-end"> | ||
<div> | ||
{bottle.category && ( | ||
<Link | ||
to={`/bottles?category=${encodeURIComponent( | ||
bottle.category, | ||
)}`} | ||
> | ||
{formatCategoryName(bottle.category)} | ||
</Link> | ||
)} | ||
</div> | ||
<div> | ||
{bottle.statedAge ? `Aged ${bottle.statedAge} years` : null} | ||
</div> | ||
</div> | ||
) | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { Bottle } from "@peated/server/types"; | ||
import RobotImage from "@peated/web/assets/robot.png"; | ||
import { Fragment } from "react"; | ||
import BottleTagDistribution from "./bottleTagDistribution.client"; | ||
import { ClientOnly } from "./clientOnly"; | ||
import Markdown from "./markdown"; | ||
import QueryBoundary from "./queryBoundary"; | ||
|
||
export default function BottleOverview({ bottle }: { bottle: Bottle }) { | ||
return ( | ||
<> | ||
<div className="my-6 px-3 md:px-0"> | ||
<ClientOnly | ||
fallback={ | ||
<div | ||
className="animate-pulse bg-slate-800" | ||
style={{ height: 200 }} | ||
/> | ||
} | ||
> | ||
{() => ( | ||
<QueryBoundary | ||
fallback={ | ||
<div | ||
className="animate-pulse bg-slate-800" | ||
style={{ height: 200 }} | ||
/> | ||
} | ||
loading={<Fragment />} | ||
> | ||
<BottleTagDistribution bottleId={bottle.id} /> | ||
</QueryBoundary> | ||
)} | ||
</ClientOnly> | ||
</div> | ||
|
||
{(bottle.description || bottle.tastingNotes) && ( | ||
<div className="my-6 px-3 md:px-0"> | ||
{bottle.description && ( | ||
<div className="flex space-x-4"> | ||
<div className="prose prose-invert -mt-5 max-w-none flex-auto"> | ||
<Markdown content={bottle.description} /> | ||
</div> | ||
<img src={RobotImage} className="hidden h-40 w-40 sm:block" /> | ||
</div> | ||
)} | ||
{bottle.tastingNotes && ( | ||
<> | ||
<h3 className="text-highlight text-lg font-bold"> | ||
Tasting Notes | ||
</h3> | ||
<div className="prose prose-invert max-w-none flex-auto"> | ||
<dl> | ||
<dt>Nose</dt> | ||
<dd>{bottle.tastingNotes.nose}</dd> | ||
<dt>Palate</dt> | ||
<dd>{bottle.tastingNotes.palate}</dd> | ||
<dt>Finish</dt> | ||
<dd>{bottle.tastingNotes.finish}</dd> | ||
</dl> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { trpc } from "../lib/trpc"; | ||
import { DistributionChart } from "./distributionChart"; | ||
|
||
export default function BottleTagDistribution({ | ||
bottleId, | ||
}: { | ||
bottleId: number; | ||
}) { | ||
const { data } = trpc.bottleTagList.useQuery({ | ||
bottle: bottleId, | ||
}); | ||
|
||
if (!data) return null; | ||
|
||
const { results, totalCount } = data; | ||
|
||
if (!results.length) return null; | ||
|
||
return ( | ||
<DistributionChart | ||
items={results.map((t) => ({ | ||
name: t.tag, | ||
count: t.count, | ||
tag: t.tag, | ||
}))} | ||
totalCount={totalCount} | ||
to={(item) => `/bottles?tag=${encodeURIComponent(item.name)}`} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters