/** @jsxImportSource react */
// Ported from Charm Lip Gloss's layout showcase (MIT), expressed as native
// React/Yoga layout and semantic Sigil paints rather than precomposed strings.
import React from "react";
import { adaptive, interpolateColor, linearGradient, rgb } from "#/color/index.ts";
import { Box, render, Text, useWindowSize } from "#/index.ts";
const highlight = adaptive("#874BFD", "#7D56F4");
const subtle = adaptive("#D9DCCF", "#383838");
const special = adaptive("#43BF6D", "#73F59F");
const questionGradient = linearGradient(["#EDFF82", "#F25D94"]);
function Tab({ active, children }: { readonly active?: boolean; readonly children: string }) {
return (
{children}
);
}
function Checklist({
title,
items,
}: {
readonly title: string;
readonly items: ReadonlyArray;
}) {
return (
{title}
{items.map(([label, done]) => (
{done ? "✓ " : " "}
{label}
))}
);
}
function ColorGrid() {
const topLeft = rgb(242, 93, 148);
const bottomLeft = rgb(100, 58, 255);
const topRight = rgb(237, 255, 130);
const bottomRight = rgb(20, 249, 213);
return (
{Array.from({ length: 8 }, (_row, y) => {
const amountY = y / 7;
const left = interpolateColor(topLeft, bottomLeft, amountY);
const right = interpolateColor(topRight, bottomRight, amountY);
return (
{Array.from({ length: 14 }, (_column, x) => (
{" "}
))}
);
})}
);
}
const histories = [
"The Romans learned from the Greeks that quinces slowly cooked with honey would set when cool. Their preserves of quince and lemon became an ancestor of marmalade.",
"Medieval quince preserves were made in clear and fruit-pulp versions. By the seventeenth century recipes had shed many of their earlier spices.",
"In 1524 Henry VIII received a box of marmalade from Exeter. The solid Portuguese quince paste later became a favourite of Anne Boleyn and her household.",
];
const historyAlignments = ["right", "center", "left"] as const;
function History({
children,
align,
}: {
readonly children: string;
readonly align: "left" | "center" | "right";
}) {
return (
{align === "center" ? ` ${children}` : children}
);
}
function App() {
const { columns } = useWindowSize();
const width = Math.min(96, Math.max(40, columns - 1));
return (
Lip Gloss
Blush
Eye Shadow
Mascara
Sigil Gloss
Style Definitions for Nice Terminal Layouts
From Charm • github.com/charmbracelet/lipgloss
Are you sure you want to eat marmalade?
Yes
Maybe
{width >= 92 ? : null}
{width >= 92 ? (
{histories.map((history, index) => (
{history}
))}
) : null}
STATUS
Ravishingly adaptive!
UTF-8
🍥 Fish Cake
{width >= 92 ? (
Now with Compositing!
) : (
Now with Compositing!
)}
);
}
render();