import { For, Show } from "solid-js";
import type { Brew, Infuser, Tea, Vendor, Vessel } from "../lib/types";
import {
brewTitle,
formatEntityDate,
formatRating,
formatSeconds,
formatTemperature,
infusionMethodLabel,
safeExternalUrl,
styleLabel,
} from "../lib/format";
import { useSession } from "../lib/session";
import { AppLink } from "./AppLink";
import { ClockIcon, LeafIcon, PinIcon, StarIcon, StoreIcon } from "./icons";
function recordHref(
kind: "teas" | "vendors" | "vessels" | "infusers",
actor: string | undefined,
rkey: string,
): string {
if (!actor) return "";
return (
"/" +
kind +
"/" +
encodeURIComponent(actor) +
"/" +
encodeURIComponent(rkey)
);
}
function MetaItem(props: { children: any }) {
return {props.children};
}
function Fact(props: {
label: string;
value: string | number | undefined | null;
}) {
return (
{props.label}
{props.value}
);
}
export function BrewContent(props: {
brew: Brew;
showRating?: boolean;
href?: string;
actor?: string;
plainTitle?: boolean;
}) {
const session = useSession();
const tea = () => props.brew.tea;
const title = () => brewTitle(props.brew);
const titleHref = () => props.href ?? "";
return (
{title()}}
>
{title()}
{(vendor) => (
{vendor().name}
)}
{(value) => (
)}
{formatRating(props.brew.rating)}
“{props.brew.tasting_notes}”
);
}
export function TeaContent(props: {
tea: Tea;
showRating?: boolean;
href?: string;
actor?: string;
brewCount?: number;
plainTitle?: boolean;
}) {
return (
{props.tea.name}}
>
{props.tea.name}
{(vendor) => (
{vendor().name}
)}
{formatRating(props.tea.rating)}
“{props.tea.description}”
);
}
export function VendorContent(props: {
vendor: Vendor;
href?: string;
plainTitle?: boolean;
}) {
return (
{props.vendor.name}}
>
{props.vendor.name}
“{props.vendor.description}”
);
}
export function VesselContent(props: {
vessel: Vessel;
href?: string;
plainTitle?: boolean;
}) {
return (
{props.vessel.name}}
>
{props.vessel.name}
{props.vessel.style}
{props.vessel.capacity_ml} ml
{props.vessel.material}
“{props.vessel.description}”
);
}
export function InfuserContent(props: {
infuser: Infuser;
href?: string;
plainTitle?: boolean;
}) {
return (
{props.infuser.name}}
>
{props.infuser.name}
{props.infuser.style}
{props.infuser.material}
“{props.infuser.description}”
);
}