/** @jsxImportSource react */ // Ported from Charm Lip Gloss's brightness example (MIT). import React from "react"; import { adaptive, darken, lighten, rgb, type ColorInput } from "#/color/index.ts"; import { Box, render, Text } from "#/index.ts"; import type { Color } from "#/screen/index.ts"; const colors: ReadonlyArray = [ ["Red", rgb(255, 0, 0)], ["Blue", rgb(0, 102, 255)], ["Green", rgb(0, 255, 0)], ["Gray", rgb(128, 128, 128)], ]; function Scale({ label, color, direction, }: { readonly label: string; readonly color: Color; readonly direction: "lighter" | "darker"; }) { return ( {label} {Array.from({ length: 20 }, (_, index) => { const amount = 0.05 * (index + 1); const shade: ColorInput = direction === "lighter" ? lighten(color, amount) : darken(color, amount); return ( ██ ); })} ); } function App() { return ( {colors.map(([name, color]) => ( {name} ))} ); } render();