-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app components board clue: use popover to show answer on click
Instead of using the clue list at the bottom, click on an answered clue to show a popover with its answer. Radix popover: https://www.radix-ui.com/docs/primitives/components/popover Use a popover instead of a tooltip because Radix tooltips do not show up on mobile (no hover events). See discussion: radix-ui/primitives#955 To make clue button a popover trigger, pass a ref with React.forwardRef like so: - radix-ui/primitives#953 - https://buildui.com/videos/do-your-react-components-compose
- Loading branch information
Showing
5 changed files
with
305 additions
and
43 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as PopoverPrimitive from "@radix-ui/react-popover"; | ||
import * as React from "react"; | ||
|
||
export default function Popover({ | ||
children, | ||
content, | ||
}: { | ||
children: React.ReactNode; | ||
content: React.ReactNode; | ||
}) { | ||
return ( | ||
<PopoverPrimitive.Root> | ||
<PopoverPrimitive.Trigger asChild>{children}</PopoverPrimitive.Trigger> | ||
<PopoverPrimitive.Portal> | ||
<PopoverPrimitive.Content | ||
className={ | ||
"data-[state=open]:data-[side=top]:animate-slideDownAndFade " + | ||
"data-[state=open]:data-[side=right]:animate-slideLeftAndFade " + | ||
"data-[state=open]:data-[side=bottom]:animate-slideUpAndFade " + | ||
"data-[state=open]:data-[side=left]:animate-slideRightAndFade " + | ||
"text-white rounded-md bg-blue-600 px-3 py-2 text-sm " + | ||
"shadow-lg max-w-xs" | ||
} | ||
side="top" | ||
sideOffset={5} | ||
> | ||
{content} | ||
<PopoverPrimitive.Arrow className="fill-blue-600" /> | ||
</PopoverPrimitive.Content> | ||
</PopoverPrimitive.Portal> | ||
</PopoverPrimitive.Root> | ||
); | ||
} |
Oops, something went wrong.