import { paint } from '../material/paint'
/**
* The stroke that says a control opens something, or that one name follows
* another.
*
* Drawn rather than imported. The icon package this workspace ships is written
* for two platforms and arrives with a renderer the web build has to stand in
* for; one path is less code than the shim, and it is also the only version
* that can be imported by a test without a document.
*
* There were three of these: the nav's, the chain panel's, and a lucide chevron
* in the token chooser at a fourth size. One glyph, two numbers, two headings.
*
* The wedge and the tick are here for the same reason rather than because they
* are carets. All three are two or three points and a stroke width; each was
* about to be a second drawing in whichever file first needed it.
*/
/** Where the stroke points. Down opens and up closes again; right leads on,
* which is the separator between the two names of a trail. */
const PATH = { down: 'M2 4 L5 7 L8 4', up: 'M2 6 L5 3 L8 6', right: 'M4 2 L7 5 L4 8' } as const
/**
* The mark beside a name that has more behind it.
*
* A filled triangle, not a stroke, and it is the one place on this surface the
* two are different marks rather than one at two weights. The reference draws
* its wordmark's with a solid triangle, corners taken off, on a 24 grid at 12
* across — measured beside the lockup at 1280, 1440, 1728 and 1920 — and draws
* the chevron above wherever a control opens a list. A hairline pointing down
* beside a solid wordmark reads as a hint; the triangle reads as part of the
* name.
*
* Three points and a radius, the way the gear is four numbers: the shape is
* what it is, and a path written out is a drawing nobody can move.
*/
const CORNERS = [
[6, 7.4],
[18, 7.4],
[12, 17.4],
] as const
/** How much of each corner is taken off. */
const EASE = 1.8
const wedge = (() => {
const round = (n: number) => Math.round(n * 100) / 100
const toward = (from: readonly [number, number], to: readonly [number, number], by: number) => {
const [dx, dy] = [to[0] - from[0], to[1] - from[1]]
const span = Math.hypot(dx, dy)
return [round(from[0] + (dx / span) * by), round(from[1] + (dy / span) * by)] as const
}
return (
CORNERS.map((here, i) => {
const before = CORNERS[(i + CORNERS.length - 1) % CORNERS.length]!
const after = CORNERS[(i + 1) % CORNERS.length]!
const [ix, iy] = toward(here, before, EASE)
const [ox, oy] = toward(here, after, EASE)
return `${i ? 'L' : 'M'}${ix} ${iy}Q${here[0]} ${here[1]} ${ox} ${oy}`
}).join('') + 'Z'
)
})()
export function Wedge({
size = 12,
colour = paint.quiet,
}: { size?: number; colour?: string } = {}) {
return (
)
}
export function Caret({
/** How large the box is. Ten beside a word in the chrome, sixteen between the
* two names of a trail, twenty-four beside a figure on a trade card, which is
* what the reference draws in each. */
size = 10,
/** What it is drawn in. Quiet where it qualifies a word, plain where it is
* half of the control a person is about to press. */
colour = paint.quiet,
to = 'down',
}: { size?: number; colour?: string; to?: keyof typeof PATH } = {}) {
return (
)
}
export function Tick({
/** How large the box is. Fourteen beside a row in an open list, which is what
* the reference draws. */
size = 14,
/** What it is drawn in. Plain, because the tick is the whole of what says
* which entry is in force. */
colour = paint.plain,
}: { size?: number; colour?: string } = {}) {
return (
)
}