This commit is contained in:
@@ -7,6 +7,9 @@ import HorizontalScrollView from "@/components/listview/HorizontalScrollView";
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
|
|
||||||
|
/** TODO: remove when backend sends avatarRenderMode */
|
||||||
|
const COLORED_SVG_RESTAURANT_SLUGS = new Set(["havasone"]);
|
||||||
|
|
||||||
const SVG_MASK_STYLE = {
|
const SVG_MASK_STYLE = {
|
||||||
maskSize: "contain",
|
maskSize: "contain",
|
||||||
maskRepeat: "no-repeat",
|
maskRepeat: "no-repeat",
|
||||||
@@ -20,16 +23,17 @@ function CategoryImage({
|
|||||||
src,
|
src,
|
||||||
size,
|
size,
|
||||||
alt,
|
alt,
|
||||||
// proxyBase,
|
tintWithPrimary = true,
|
||||||
}: {
|
}: {
|
||||||
src: string;
|
src: string;
|
||||||
size: number;
|
size: number;
|
||||||
alt: string;
|
alt: string;
|
||||||
// proxyBase: string | null;
|
tintWithPrimary?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const isSvg = src.endsWith(".svg");
|
const isSvg = src.endsWith(".svg");
|
||||||
|
const shouldUseSvgMask = isSvg && tintWithPrimary;
|
||||||
|
|
||||||
if (isSvg) {
|
if (shouldUseSvgMask) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="shrink-0 bg-primary"
|
className="shrink-0 bg-primary"
|
||||||
@@ -44,17 +48,6 @@ function CategoryImage({
|
|||||||
aria-label={alt}
|
aria-label={alt}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
|
||||||
<img
|
|
||||||
src={src}
|
|
||||||
width={size}
|
|
||||||
height={size}
|
|
||||||
alt={alt}
|
|
||||||
className="shrink-0 object-contain"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -65,6 +58,7 @@ function CategoryImage({
|
|||||||
height={size}
|
height={size}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
className="shrink-0 object-contain"
|
||||||
onError={(event) => {
|
onError={(event) => {
|
||||||
event.currentTarget.src = "/assets/images/food-image.png";
|
event.currentTarget.src = "/assets/images/food-image.png";
|
||||||
}}
|
}}
|
||||||
@@ -107,7 +101,9 @@ const CategoryScroll = ({
|
|||||||
className,
|
className,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const segment = usePathname()?.split("/").filter(Boolean)[0];
|
const segment = usePathname()?.split("/").filter(Boolean)[0];
|
||||||
const proxyBase = segment != null ? `/${segment}` : null;
|
const usesColoredSvg =
|
||||||
|
segment != null &&
|
||||||
|
COLORED_SVG_RESTAURANT_SLUGS.has(segment.toLowerCase());
|
||||||
const { renderer: Renderer, imageSize } = variantConfig[variant];
|
const { renderer: Renderer, imageSize } = variantConfig[variant];
|
||||||
|
|
||||||
const handleSelect = (categoryId: string) => () => onSelect(categoryId);
|
const handleSelect = (categoryId: string) => () => onSelect(categoryId);
|
||||||
@@ -147,7 +143,7 @@ const CategoryScroll = ({
|
|||||||
src={item.avatarUrl || "/assets/images/food-image.png"}
|
src={item.avatarUrl || "/assets/images/food-image.png"}
|
||||||
size={imageSize}
|
size={imageSize}
|
||||||
alt="category image"
|
alt="category image"
|
||||||
// proxyBase={proxyBase}
|
tintWithPrimary={!usesColoredSvg}
|
||||||
/>
|
/>
|
||||||
<span className="text-xs text-foreground text-center">
|
<span className="text-xs text-foreground text-center">
|
||||||
{item.title}
|
{item.title}
|
||||||
|
|||||||
Reference in New Issue
Block a user