import { useEffect } from 'react';
import { letters } from './font.js';
import { wire } from './chrome.js';
import { conf, HUES } from './config.js';
/* GLYPHS */
function Cells({ rows, cols, grid, className, label, fill, children }) {
const cells = [];
grid.forEach((row, y) =>
row.forEach((on, x) => {
if (!on && !fill) return;
const i = y * cols + x;
cells.push();
}),
);
return (
);
}
export function Glyph({ text, className, label }) {
return ;
}
const pixels = (rows) => rows.map((row) => [...row].map((c) => (c === '1' ? 1 : 0)));
const PANEL = {
left: ['11111', '11001', '11001', '11001', '11111'],
right: ['11111', '10011', '10011', '10011', '11111'],
};
function Panel({ side }) {
return ;
}
function Ring() {
const dots = [];
for (let y = 1; y <= 3; y++) for (let x = 1; x <= 3; x++) dots.push();
return {dots};
}
function Wordmark({ className }) {
return ;
}
/* HEADER */
function Header() {
const site = conf();
return (
);
}
function Dock({ route = '/' }) {
const word = decodeURIComponent(route).split('/').filter(Boolean).pop() ?? 'home';
return (
);
}
/* TREE */
const holds = (node, current) => node.href === current || (node.nodes ?? []).some((sub) => holds(sub, current));
function Leaf({ node, here }) {
return (
{node.icon && }
{node.icon ? {node.name} : node.name}
);
}
function Node({ node, current }) {
const here = node.href === current ? 'page' : undefined;
const lazy = node.lazy !== undefined;
if (!node.nodes && !lazy) return ;
return (
{node.href ? : node.name}
{(node.nodes ?? []).map((sub) => )}
);
}
const EXPLORER = '/git/tree.json';
const hasLazy = (nodes) => nodes.some((node) => node.lazy !== undefined || hasLazy(node.nodes ?? []));
function Tree({ nodes = [], current = '' }) {
const source = hasLazy(nodes) ? EXPLORER : undefined;
return ;
}
/* MENU */
function Dates({ dates }) {
if (!dates?.length) return null;
return {dates.map((date) => {date})}
;
}
function Card({ node }) {
if (!node.figure) return {node.name}
{node.text && {node.text}
};
return (
{node.name}
{node.text && {node.text}
}
);
}
const leaves = (nodes) => nodes.filter((node) => node.href && !(node.nodes && node.nodes.length));
const groups = (nodes) => nodes.filter((node) => node.nodes && node.nodes.length);
export function Grid({ nodes = [] }) {
const list = leaves(nodes);
if (!list.length) return null;
return {list.map((node) => )}
;
}
export function Menu({ tree = [] }) {
const pages = leaves(tree);
return (
{groups(tree).map((group) => (
{group.href ? {group.name} : group.name}
{groups(group.nodes).map((shelf) => (
))}
))}
{pages.length > 0 && (
)}
);
}
/* CONTENTS */
function Contents({ items = [] }) {
return (
);
}
function Controls({ children }) {
return ;
}
const FACES = [
['', 'System'],
['sans', 'Noto Sans'],
['serif', 'Noto Serif'],
['mono', 'Noto Sans Mono'],
['mrly', 'MrlyFont'],
];
const TINTS = [['', 'Auto'], ...HUES.map((hue) => [hue, hue[0].toUpperCase() + hue.slice(1)])];
const SCREENS = [
['', 'Wordmark'],
['matrix', 'Matrix'],
['sleep', 'Sleep'],
['mandelbrot', 'Mandelbrot'],
['julia', 'Julia'],
];
function Pick({ label, name, options }) {
return (
);
}
function Settings() {
return (
);
}
/* FOOTER */
function Mark() {
const site = conf();
const text = site.title.toUpperCase();
const { rows, cols } = letters(text);
return (
<>
>
);
}
function Footer() {
const site = conf();
const year = new Date().getFullYear();
const span = site.since < year ? `${site.since}-${year}` : String(year);
return (
);
}
/* SHELL */
export function Shell({ route = '/', title, lead, tree = [], current = route, contents = [], controls, wide = false, children }) {
useEffect(() => {
wire();
}, []);
return (
<>
Skip to content
{title && (
)}
{children}
>
);
}