People tiles: square photos, a frame, even heights, palette initials
Captions are a fixed two lines of name and two of title; what doesn't fit ends in an ellipsis and gives the tile the down arrow, whose details show it in full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5dbb203519
commit
592e07f614
3 changed files with 103 additions and 26 deletions
|
|
@ -73,3 +73,18 @@ export const PALETTE = {
|
|||
from the palette by data, like an initials tile. */
|
||||
export const PALETTE_LIGHT = ['#c2f6ff', '#dfebd6', '#c2ffd6', '#c2fbff', '#aac992', '#5ce7ff'] as const
|
||||
export const PALETTE_DARK = ['#004552', '#27371b', '#00521b', '#004c52'] as const
|
||||
|
||||
/* A palette fill for something colored by its name, like the
|
||||
initials tile of a person with no photo: the same name always gets
|
||||
the same fill, and each fill comes with its readable text (ink on
|
||||
the light ones, white on the dark ones). */
|
||||
const NAMED_FILLS = [
|
||||
...PALETTE_LIGHT.map((background) => ({ background, color: '#001011' })),
|
||||
...PALETTE_DARK.map((background) => ({ background, color: '#ffffff' })),
|
||||
]
|
||||
|
||||
export function paletteFill(name: string): { background: string; color: string } {
|
||||
let hash = 0
|
||||
for (const char of name.trim().toLowerCase()) hash = (hash * 31 + char.charCodeAt(0)) >>> 0
|
||||
return NAMED_FILLS[hash % NAMED_FILLS.length]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue