Skip to content

Commit

Permalink
Do not use bottle panel by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Jun 11, 2024
1 parent 40065e1 commit 3ab3c44
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions apps/web/app/components/bottleLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import { ClientOnly } from "./clientOnly";
type Props = Omit<ComponentPropsWithoutRef<typeof Link>, "to"> & {
to?: string;
bottle: Bottle;
withPanel?: boolean;
flightId?: string;
};

export default function BottleLink({ bottle, flightId, ...props }: Props) {
export default function BottleLink({
bottle,
flightId,
withPanel = false,
...props
}: Props) {
const [open, setOpen] = useState(false);

const tastingPath = flightId
Expand All @@ -21,26 +27,30 @@ export default function BottleLink({ bottle, flightId, ...props }: Props) {
<>
<Link
onClick={(e) => {
e.preventDefault();
setOpen(true);
if (withPanel) {
e.preventDefault();
setOpen(true);
}
}}
title={bottle.fullName}
className="absolute inset-0"
to={`/bottles/${bottle.id}`}
{...props}
/>
<ClientOnly>
{() => (
<BottlePanel
tastingPath={tastingPath}
bottle={bottle}
open={open}
onClose={() => {
setOpen(false);
}}
/>
)}
</ClientOnly>
{withPanel && (
<ClientOnly>
{() => (
<BottlePanel
tastingPath={tastingPath}
bottle={bottle}
open={open}
onClose={() => {
setOpen(false);
}}
/>
)}
</ClientOnly>
)}
</>
);
}

0 comments on commit 3ab3c44

Please sign in to comment.