Refine recipe overlay tooltips
This commit is contained in:
parent
b3972a6032
commit
722f18cc0f
@ -2,7 +2,7 @@ import { ComponentProps, ReactNode, useRef, useEffect } from 'react';
|
|||||||
import OGLoaderImage from './OGLoaderImage';
|
import OGLoaderImage from './OGLoaderImage';
|
||||||
import { IMAGE_OG_DIMENSION } from '@/image-response';
|
import { IMAGE_OG_DIMENSION } from '@/image-response';
|
||||||
import clsx from 'clsx/lite';
|
import clsx from 'clsx/lite';
|
||||||
import { useOGTooltipState } from './state';
|
import { Tooltip, useOGTooltipState } from './state';
|
||||||
import useSupportsHover from '@/utility/useSupportsHover';
|
import useSupportsHover from '@/utility/useSupportsHover';
|
||||||
|
|
||||||
const { aspectRatio } = IMAGE_OG_DIMENSION;
|
const { aspectRatio } = IMAGE_OG_DIMENSION;
|
||||||
@ -15,10 +15,12 @@ const offsetBelow = -6;
|
|||||||
export default function OGTooltip({
|
export default function OGTooltip({
|
||||||
children,
|
children,
|
||||||
caption,
|
caption,
|
||||||
|
color,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
children :ReactNode
|
children :ReactNode
|
||||||
caption?: ReactNode
|
caption?: ReactNode
|
||||||
|
color?: Tooltip['color']
|
||||||
} & ComponentProps<typeof OGLoaderImage>) {
|
} & ComponentProps<typeof OGLoaderImage>) {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
@ -40,7 +42,9 @@ export default function OGTooltip({
|
|||||||
{...props}
|
{...props}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'overflow-hidden rounded-[0.25rem]',
|
'overflow-hidden rounded-[0.25rem]',
|
||||||
'outline-medium bg-extra-dim',
|
color === 'frosted'
|
||||||
|
? 'outline outline-gray-400/25'
|
||||||
|
: 'outline-medium bg-extra-dim',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{caption && <div className={clsx(
|
{caption && <div className={clsx(
|
||||||
@ -61,7 +65,7 @@ export default function OGTooltip({
|
|||||||
onMouseEnter={() => supportsHover &&
|
onMouseEnter={() => supportsHover &&
|
||||||
showTooltip?.(
|
showTooltip?.(
|
||||||
ref.current,
|
ref.current,
|
||||||
{ content, width, height, offsetAbove, offsetBelow },
|
{ content, width, height, offsetAbove, offsetBelow, color },
|
||||||
)}
|
)}
|
||||||
onMouseLeave={() => supportsHover &&
|
onMouseLeave={() => supportsHover &&
|
||||||
dismissTooltip?.(ref.current)}
|
dismissTooltip?.(ref.current)}
|
||||||
|
|||||||
@ -107,7 +107,7 @@ export default function OGTooltipProvider({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<OGTooltipContext.Provider value={{ showTooltip, dismissTooltip }}>
|
<OGTooltipContext.Provider value={{ showTooltip, dismissTooltip }}>
|
||||||
<div className="relative inset-0 z-50 pointer-events-none">
|
<div className="relative inset-0 z-100 pointer-events-none">
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{currentTooltip &&
|
{currentTooltip &&
|
||||||
<motion.div
|
<motion.div
|
||||||
@ -119,7 +119,10 @@ export default function OGTooltipProvider({
|
|||||||
className="fixed"
|
className="fixed"
|
||||||
style={tooltipStyle}
|
style={tooltipStyle}
|
||||||
>
|
>
|
||||||
<MenuSurface className="max-w-none p-1!">
|
<MenuSurface
|
||||||
|
className="max-w-none p-1!"
|
||||||
|
color={currentTooltip.color}
|
||||||
|
>
|
||||||
{currentTooltip.content}
|
{currentTooltip.content}
|
||||||
</MenuSurface>
|
</MenuSurface>
|
||||||
</motion.div>}
|
</motion.div>}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { createContext, ReactNode, use } from 'react';
|
import { ComponentProps, createContext, ReactNode, use } from 'react';
|
||||||
|
import MenuSurface from '../primitives/MenuSurface';
|
||||||
|
|
||||||
export type Tooltip = {
|
export type Tooltip = {
|
||||||
content: ReactNode
|
content: ReactNode
|
||||||
@ -6,6 +7,7 @@ export type Tooltip = {
|
|||||||
height: number
|
height: number
|
||||||
offsetAbove: number
|
offsetAbove: number
|
||||||
offsetBelow: number
|
offsetBelow: number
|
||||||
|
color?: ComponentProps<typeof MenuSurface>['color']
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OGTooltipState = {
|
export type OGTooltipState = {
|
||||||
|
|||||||
@ -99,7 +99,8 @@ export default function EntityLink({
|
|||||||
'peer',
|
'peer',
|
||||||
'inline-flex items-center gap-2 max-w-full truncate',
|
'inline-flex items-center gap-2 max-w-full truncate',
|
||||||
classForContrast(),
|
classForContrast(),
|
||||||
path && !badged && 'hover:text-gray-900 dark:hover:text-gray-100',
|
path && !badged && contrast !== 'frosted' &&
|
||||||
|
'hover:text-gray-900 dark:hover:text-gray-100',
|
||||||
path && !badged && 'active:text-medium!',
|
path && !badged && 'active:text-medium!',
|
||||||
)}
|
)}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
@ -156,6 +157,7 @@ export default function EntityLink({
|
|||||||
title={label}
|
title={label}
|
||||||
path={tooltipImagePath}
|
path={tooltipImagePath}
|
||||||
caption={tooltipCaption}
|
caption={tooltipCaption}
|
||||||
|
color={contrast === 'frosted' ? 'frosted' : undefined}
|
||||||
>
|
>
|
||||||
{renderLink}
|
{renderLink}
|
||||||
</OGTooltip>
|
</OGTooltip>
|
||||||
|
|||||||
@ -122,6 +122,7 @@ export default function PhotoRecipeOverlay({
|
|||||||
{title
|
{title
|
||||||
? <PhotoRecipe
|
? <PhotoRecipe
|
||||||
recipe={title}
|
recipe={title}
|
||||||
|
contrast="frosted"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'text-[15px]',
|
'text-[15px]',
|
||||||
'[&>*>*>*>*]:text-black',
|
'[&>*>*>*>*]:text-black',
|
||||||
@ -161,8 +162,8 @@ export default function PhotoRecipeOverlay({
|
|||||||
{renderDataSquare(
|
{renderDataSquare(
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<PhotoFilm
|
<PhotoFilm
|
||||||
contrast="frosted"
|
|
||||||
film={film}
|
film={film}
|
||||||
|
contrast="frosted"
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'translate-y-[-0.5px]',
|
'translate-y-[-0.5px]',
|
||||||
'*:text-black! *:active:text-black!',
|
'*:text-black! *:active:text-black!',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user