diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index 3a115df8..0f2b9c9d 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -62,7 +62,7 @@ function createCarouselStyles(number: number): string { } `; - const delays = Array.from({ length: number }) + const delayList = Array.from({ length: number }) .map((_, i) => { return css` &:nth-child(${i + 1}) { @@ -73,6 +73,10 @@ function createCarouselStyles(number: number): string { `; }) .join("\n"); + const delays = css` + .carousel > img { + ${delayList} + }`; return css` .carousel > img { @@ -88,9 +92,7 @@ function createCarouselStyles(number: number): string { } } - .carousel > img { - ${delays} - } + ${delays} ${keyframes} `; diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 9cd74190..b26ab36e 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -140,7 +140,6 @@ function RenderCategory(props: Menu): JSX.Element { * @param props.title - The title of the link. * @returns The rendered category header. */ -// TODO(lishaduck): Add a component to centralize anchor styling. function RenderCategoryHeader({ url, title }: BasicMenu): JSX.Element { return ( ): JSX.Element {
{ - // TODO(lishaduck): Enable moderation. - e.preventDefault(); if (threadId.value === undefined) { diff --git a/src/islands/Selector.tsx b/src/islands/Selector.tsx index 81d0b1df..bcc76071 100644 --- a/src/islands/Selector.tsx +++ b/src/islands/Selector.tsx @@ -22,9 +22,6 @@ export interface SelectorProps { readonly required?: boolean; /** A hacky way to get Fresh to serialize the `info` prop. */ readonly children?: ComponentChildren; - /** A hacky way to get Fresh *not* to serialize the `info` prop. */ - // TODO(lishaduck): Is this really needed? - readonly hasInfo?: boolean; } export interface SelectorListObject { @@ -56,7 +53,6 @@ export function Selector({ current: currentValue, required, children: info, - hasInfo, }: SelectorProps): JSX.Element { const current = useSignal( list.find((val) => val.name === currentValue) ?? { name: "", value: "" }, @@ -109,7 +105,7 @@ export function Selector({ > diff --git a/src/routes/calculator/results.tsx b/src/routes/calculator/results.tsx index de381789..a09dc82e 100644 --- a/src/routes/calculator/results.tsx +++ b/src/routes/calculator/results.tsx @@ -20,7 +20,6 @@ import { type StateData, stateData } from "../../utils/calc/solar.ts"; import { useCsp } from "../../utils/csp.ts"; import type { FreshContextHelper } from "../../utils/handlers.ts"; import { usdFormat, yearFormat } from "../../utils/intl.ts"; -import { isKey } from "../../utils/type-helpers.ts"; export const config = { csp: true, @@ -76,11 +75,15 @@ function parseData( if ( geoType.success && - typeof region === "string" && - isKey(stateData, region) + region !== undefined && + Object.hasOwn(stateData, region) ) { return { - solarRegionData: stateData[region], + solarRegionData: + stateData[ + // See microsoft/TypeScript#44253 + region as keyof typeof stateData + ], geoCostData: { isHilly: Boolean(isHilly), needsRenovations: Boolean(renovations), diff --git a/src/routes/solutions/[category]/index.tsx b/src/routes/solutions/[category]/index.tsx index 6273b73e..9bb38cbf 100644 --- a/src/routes/solutions/[category]/index.tsx +++ b/src/routes/solutions/[category]/index.tsx @@ -11,7 +11,7 @@ import { Meta } from "../../../components/Meta.tsx"; import { solutions } from "../../../utils/categories.gen.ts"; import { useCsp } from "../../../utils/csp.ts"; import type { FreshContextHelper } from "../../../utils/handlers.ts"; -import { hasSlug, isKey } from "../../../utils/type-helpers.ts"; +import { hasSlug } from "../../../utils/type-helpers.ts"; export const config = { csp: true, @@ -51,7 +51,7 @@ export const handler: Handlers = { if ( category === undefined || category === "" || - !isKey(categoryMetadata, category) + !Object.hasOwn(categoryMetadata, category) ) { return await ctx.renderNotFound(); } @@ -76,10 +76,16 @@ export const handler: Handlers = { } } + const metadata = + categoryMetadata[ + // See microsoft/TypeScript#44253 + category as keyof typeof categoryMetadata + ]; + return await ctx.render({ pages: categoryPropsPages.parse(data), - title: categoryMetadata[category].title, - description: categoryMetadata[category].description, + title: metadata.title, + description: metadata.description, heros: data.map((page) => page.picture), }); } catch (e) { diff --git a/src/utils/type-helpers.ts b/src/utils/type-helpers.ts index 05b2ddfa..df852044 100644 --- a/src/utils/type-helpers.ts +++ b/src/utils/type-helpers.ts @@ -3,20 +3,5 @@ import type { SolutionPage } from "./solutions.ts"; export function hasSlug( data: SolutionPage, ): data is SolutionPage & { slug: string | undefined } { - return isKey(data, "slug"); -} - -/** - * Check if an object has a key. - * - * @typeParam T - The type of the object. - * @param obj - The object to check. - * @param key - The key to check for. - * @returns Whether the object has the key. - */ -export function isKey( - obj: T, - key: PropertyKey, -): key is keyof T { - return Object.hasOwn(obj, key); + return Object.hasOwn(data, "slug"); }