Skip to content

Commit

Permalink
Merge pull request #56 from PHS-TSA/miscui
Browse files Browse the repository at this point in the history
UI Rewrite
  • Loading branch information
lishaduck committed May 22, 2024
2 parents 4e52cbe + ec985d2 commit c32dd35
Show file tree
Hide file tree
Showing 135 changed files with 2,207 additions and 1,036 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"”": true,
"…": true,
"–": true,
"—": true
"—": true,
"×": true
}
},
"cSpell.words": ["Preact"]
Expand Down
26 changes: 14 additions & 12 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"check": "deno task lint & deno task typecheck",
"lint": "deno lint & deno task biome:check",
"ci": "deno lint & deno task biome:ci & deno task typecheck",
"typecheck": "deno check src/**/*.ts src/**/*.tsx",
"typecheck": "deno check src/**/*.ts src/**/*.tsx tool/**/*.ts",
"test": "deno test --allow-env --allow-read --coverage=cov/",
"test:coverage": "deno coverage --lcov cov/ > cov/cov.lcov",
"test:coverage:genhtml": "genhtml -o cov/html cov/cov.lcov",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run --env -A --watch src/dev.ts",
"start": "deno run --env -A --watch=static/ src/dev.ts",
"build": "deno task compile:mdx && deno run --env -A src/dev.ts build",
"preview": "deno run --env -A src/main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update .",
Expand All @@ -24,8 +24,8 @@
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
"$gfm": "https://deno.land/x/gfm@0.6.0/mod.ts",
"$tabler_icons/": "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/",
"@deno/gfm": "https://deno.land/x/gfm@0.6.0/mod.ts",
"@headlessui/react": "https://esm.sh/v135/*@headlessui/react@2.0.3",
"@headlessui/tailwindcss": "npm:@headlessui/tailwindcss@0.2.0",
"@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1",
Expand All @@ -35,12 +35,13 @@
"@std/path": "jsr:@std/path@^0.224.0",
"@tailwindcss/forms": "npm:@tailwindcss/forms@0.5.7",
"@tailwindcss/typography": "npm:@tailwindcss/typography@0.5.13",
"@vendor/": "./vendor/",
"clsx": "npm:clsx@2.1.1",
"idb-keyval": "npm:idb-keyval@6.2.1",
"openai": "https://deno.land/x/openai@v4.43.0/mod.ts",
"openai/": "https://deno.land/x/openai@v4.43.0/",
"preact": "https://esm.sh/v135/*preact@10.21.0",
"preact/": "https://esm.sh/v135/*preact@10.21.0/",
"openai": "https://deno.land/x/openai@v4.47.1/mod.ts",
"openai/": "https://deno.land/x/openai@v4.47.1/",
"preact": "https://esm.sh/v135/*preact@10.22.0",
"preact/": "https://esm.sh/v135/*preact@10.22.0/",
"rehype-mathjax": "npm:rehype-mathjax@6.0.0",
"remark-frontmatter": "npm:remark-frontmatter@5.0.0",
"remark-lint-checkbox-content-indent": "npm:remark-lint-checkbox-content-indent@5.0.0",
Expand All @@ -54,6 +55,7 @@
"remark-mdx-frontmatter": "npm:remark-mdx-frontmatter@4.0.0",
"remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@6.0.0",
"remark-preset-lint-recommended": "npm:remark-preset-lint-recommended@7.0.0",
"tailwind-scrollbar": "npm:tailwind-scrollbar@3.1.0",
"tailwindcss": "npm:tailwindcss@3.4.3",
"tailwindcss/plugin": "npm:tailwindcss@3.4.3/plugin.js",
"unified": "npm:unified@11.0.4",
Expand All @@ -80,13 +82,13 @@
"@swc/helpers/": "https://esm.sh/v135/*@swc/helpers@0.5.11/",
"@tanstack/react-virtual": "https://esm.sh/v135/*@tanstack/react-virtual@3.5.0",
"@tanstack/virtual-core": "npm:@tanstack/virtual-core@3.5.0",
"@types/react": "https://esm.sh/v135/*preact@10.21.0/compat",
"@types/react": "https://esm.sh/v135/*preact@10.22.0/compat",
"client-only": "npm:client-only@0.0.1",
"node:process": "https://esm.sh/v135/*node_process.js",
"react-dom": "https://esm.sh/v135/*preact@10.21.0/compat",
"react": "https://esm.sh/v135/*preact@10.21.0/compat",
"react/jsx-runtime": "https://esm.sh/v135/*preact@10.21.0/jsx-runtime",
"react-dom/test-utils": "https://esm.sh/v135/*preact@10.21.0/test-utils",
"react-dom": "https://esm.sh/v135/*preact@10.22.0/compat",
"react": "https://esm.sh/v135/*preact@10.22.0/compat",
"react/jsx-runtime": "https://esm.sh/v135/*preact@10.22.0/jsx-runtime",
"react-dom/test-utils": "https://esm.sh/v135/*preact@10.22.0/test-utils",
"tabbable": "npm:tabbable@6.2.0"
}
},
Expand Down
16 changes: 6 additions & 10 deletions src/components/Admonition.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type { JSX, RenderableProps } from "preact";
import {
IconAlertTriangle,
IconFlame,
IconInfoCircle,
} from "../utils/icons.ts";
import { tw } from "../utils/tailwind.ts";
import { tw } from "../utils/tags.ts";
import { IconAlertTriangle, IconFlame, IconInfoCircle } from "./icons.ts";

type AdmonitionType =
export type AdmonitionType =
| "note"
| "warning"
| "tip"
Expand All @@ -15,7 +11,7 @@ type AdmonitionType =
| "caution";

export interface AdmonitionProps {
type?: AdmonitionType;
readonly type?: AdmonitionType;
}

const noteStyles = tw`bg-blue-300 divide-blue-500 border-blue-400 dark:divide-blue-400 dark:border-blue-500 dark:bg-blue-600`;
Expand Down Expand Up @@ -55,8 +51,8 @@ function getTitle(type: AdmonitionType): string {
}
}

interface AdmonitionIconProps {
type: AdmonitionType;
interface AdmonitionIconProps extends AdmonitionProps {
readonly type: AdmonitionType;
}

function AdmonitionIcon({ type }: AdmonitionIconProps): JSX.Element {
Expand Down
18 changes: 18 additions & 0 deletions src/components/CalculatorScaffold.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ComponentChildren, JSX } from "preact";

export interface CalculatorScaffoldProps {
readonly children: ComponentChildren;
}

export default function CalculatorScaffold({
children,
}: CalculatorScaffoldProps): JSX.Element {
return (
<main class="flex flex-col bg-slate-200 p-16 dark:bg-slate-800 place-items-center">
<span class="p-5 text-lg">
Calculate and compare the pricing for solar and geothermal.
</span>
{children}
</main>
);
}
47 changes: 0 additions & 47 deletions src/components/CalculatorSearch.tsx

This file was deleted.

87 changes: 87 additions & 0 deletions src/components/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { asset } from "$fresh/runtime.ts";
import type { JSX } from "preact";
import { ScrollDown } from "../islands/ScrollDown.tsx";
import { css } from "../utils/tags.ts";
import type { HeroProps } from "./Cover.tsx";

export interface CarouselProps extends HeroProps {
heros: string[];
scrollDown?: boolean;
}

export function Carousel({
children,
heros,
scrollDown,
}: CarouselProps): JSX.Element {
const totalAnimationTime = heros.length * 5;
const visibilityPercentage = 100 / (2 * heros.length);

const keyframes = css`
0% {
opacity: 0;
}
${visibilityPercentage}%,
${2 * visibilityPercentage}% {
opacity: 1;
}
${3 * visibilityPercentage}%,
100% {
opacity: 0;
}
`;

const delays = heros
.map((_, i) => {
return css`
&:nth-child(${i + 1}) {
animation-delay: ${
(i * 2 * visibilityPercentage * totalAnimationTime) / 100
}s;
}
`;
})
.join("\n");

const styles = css`
.carousel > img {
opacity: 0;
animation: animate-fade ${totalAnimationTime}s infinite;
}
.carousel.hero > img {
animation: image-down linear both, animate-fade ${totalAnimationTime}s infinite;
animation-timeline: --page-scroll, auto;
animation-range: 0 100svh, normal;
}
.carousel > img {
${delays}
}
@keyframes animate-fade {
${keyframes}
}
`;

return (
<div class="relative flex h-[65svh] flex-col px-4 pt-2 sm:pt-3 md:h-[75svh] md:pt-4 lg:h-svh lg:pt-24">
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: It's just CSS that we control. */}
<style dangerouslySetInnerHTML={{ __html: styles }} />

<div class="carousel hero">
{heros.map((hero) => (
<img key={hero} src={asset(hero)} alt="" />
))}
</div>
<div class="relative z-10 flex items-center justify-center">
{children}
</div>
{scrollDown && (
<div class="absolute bottom-4 sm:bottom-1 md:bottom-14 lg:bottom-32 left-1/2 -translate-x-1/2">
<ScrollDown />
</div>
)}
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { JSX, RenderableProps } from "preact";

export function Content({ children }: RenderableProps<unknown>): JSX.Element {
return (
<article class="prose prose-slate prose-lg flex max-w-none flex-col bg-slate-200 px-10 py-10 dark:prose-invert prose-headings:flex prose-headings:flex-row prose-headings:items-center md:px-20 lg:px-40 dark:bg-slate-800 [&_img]:m-auto [&_img]:w-3/4 [&_mjx-container>svg]:inline">
<article class="prose prose-slate prose-lg flex max-w-none flex-col bg-slate-100 px-10 py-10 dark:prose-invert prose-headings:flex prose-headings:flex-row prose-headings:items-center md:px-20 lg:px-40 dark:bg-slate-900 [&_img]:m-auto [&_img]:w-3/4 [&_mjx-container>svg]:inline">
{children}
</article>
);
Expand Down
38 changes: 30 additions & 8 deletions src/components/Cover.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { JSX, RenderableProps } from "preact";
import type { ComponentChildren, ComponentType, JSX } from "preact";
import { Logo } from "./Logo.tsx";

/**
* Properties for the {@link Cover} component.
* Properties for the {@linkcode Cover} component.
*/
export interface CoverProps {
/**
Expand All @@ -13,7 +13,14 @@ export interface CoverProps {
/**
* The icon to render as the attention grabber.
*/
readonly icon?: JSX.Element;
readonly icon?: ComponentChildren;

/**
* The additional content to render.
*/
readonly children?: ComponentChildren;

readonly Hero?: ComponentType<HeroProps>;
}

/**
Expand All @@ -30,15 +37,30 @@ export interface CoverProps {
export function Cover({
title,
children,
icon = <Logo />,
}: RenderableProps<CoverProps>): JSX.Element {
icon = <Logo class="size-32" />,
Hero = Hulk,
}: CoverProps): JSX.Element {
return (
<div class="flex flex-row justify-center bg-green-500 px-4 py-8 dark:bg-green-700">
<Hero>
<div class="flex max-w-screen-sm flex-col items-center justify-center gap-y-4 text-balance text-center lg:max-w-screen-md">
{icon}
<h1 class="text-4xl font-bold">{title}</h1>
{children}
<div class="inset-0 rounded-md p-4 backdrop-blur-sm bg-slate-50/55 dark:bg-slate-950/55">
<h1 class="text-pretty text-4xl font-bold">{title}</h1>
{children}
</div>
</div>
</Hero>
);
}

export interface HeroProps {
readonly children?: ComponentChildren;
}

function Hulk({ children }: HeroProps): JSX.Element {
return (
<div class="flex flex-row justify-center bg-green-500 px-4 py-8 dark:bg-green-700">
{children}
</div>
);
}
Loading

0 comments on commit c32dd35

Please sign in to comment.