Newsletter: title color, and color pickers instead of palette dropdowns
Every part color (band, underline, card bar, line, divider, and now the title) is any hex color from a picker; blank is the default, typing none still means no color. Saved drafts keep their colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
24450fba6c
commit
f52a74a383
2 changed files with 18 additions and 20 deletions
|
|
@ -42,11 +42,11 @@ import { mediaUrl } from '../../lib/media.ts'
|
|||
import { SITE_NAME, SITE_ORIGIN, siteUrl } from '../../lib/site.ts'
|
||||
import { seriesLabel } from '../../lib/eventSeries.ts'
|
||||
import { useWideAdminPage } from '../../lib/adminWidth.tsx'
|
||||
import { STORED_PALETTE } from '../../lib/color.ts'
|
||||
import { PLATFORMS } from '../../lib/platforms.ts'
|
||||
import { SOCIAL_LINKS } from '../../data/socialLinks.ts'
|
||||
import {
|
||||
DEFAULT_TITLE,
|
||||
EMAIL_COLOR,
|
||||
newsletterHtml,
|
||||
newsletterText,
|
||||
newsletterTitle,
|
||||
|
|
@ -85,18 +85,14 @@ const PART_TYPES: Array<[string, string, string]> = [
|
|||
]
|
||||
const partLabel = (type: string) => PART_TYPES.find(([value]) => value === type)?.[1] ?? type
|
||||
|
||||
/* The site's palette as choices; an inbox needs the hex itself, and
|
||||
the one stored, not a color blind mode's swap (color.ts). */
|
||||
const SHADES = ['', ', darkest', ', light', ', lightest']
|
||||
const PALETTE_OPTIONS = Object.entries(STORED_PALETTE).flatMap(([family, shades]) =>
|
||||
shades.map((hex, i) => [hex, `${family[0].toUpperCase()}${family.slice(1)}${SHADES[i]}`]),
|
||||
)
|
||||
const colorField = (path: string, label: string, fallback: string, none: string, types: string[]) => ({
|
||||
/* A color picker: any hex color, which is what an inbox needs. Blank
|
||||
is `fallback`; `none` (where given) is typed as the word none. */
|
||||
const colorField = (path: string, label: string, fallback: string, none: string | null, types: string[]) => ({
|
||||
path,
|
||||
label,
|
||||
widget: 'select',
|
||||
options: [['none', none], ...PALETTE_OPTIONS],
|
||||
blankLabel: `Default: ${fallback}`,
|
||||
widget: 'color',
|
||||
placeholder: fallback,
|
||||
help: `Default: ${fallback}${none ? `. Type none for ${none}` : ''}`,
|
||||
when: { path: 'type', value: types },
|
||||
})
|
||||
|
||||
|
|
@ -142,7 +138,7 @@ const PARTS_SPEC = {
|
|||
when: { path: 'type', value: 'header' },
|
||||
help: "A PNG or JPEG: Gmail and Outlook don't show SVG. Default: none, the words alone",
|
||||
},
|
||||
colorField('color', 'Band color', 'Teal, darkest', 'None: no band', ['header', 'social', 'countdown']),
|
||||
colorField('color', 'Band color', EMAIL_COLOR.body, 'no band', ['header', 'social', 'countdown']),
|
||||
{
|
||||
path: 'event',
|
||||
label: 'Event',
|
||||
|
|
@ -154,6 +150,7 @@ const PARTS_SPEC = {
|
|||
},
|
||||
{ path: 'text', label: 'Words above', when: { path: 'type', value: 'countdown' }, help: "Default: the event's title" },
|
||||
{ path: 'text', label: 'Title', full: true, when: { path: 'type', value: 'title' }, help: `Default: ${DEFAULT_TITLE(SITE_NAME)}` },
|
||||
colorField('color', 'Title color', EMAIL_COLOR.ink, null, ['title']),
|
||||
{
|
||||
path: 'source',
|
||||
label: 'Pick from',
|
||||
|
|
@ -174,8 +171,8 @@ const PARTS_SPEC = {
|
|||
when: { path: 'type', value: 'picks' },
|
||||
help: (row: NewsletterPart) => `On each card. Default: ${PICK_DEFAULTS[sourceOf(row)].cta}`,
|
||||
},
|
||||
colorField('rule', 'Heading underline', 'Teal, lightest', 'None: no line', ['picks']),
|
||||
colorField('bar', 'Card bar', 'Teal', 'None: no bar', ['picks']),
|
||||
colorField('rule', 'Heading underline', EMAIL_COLOR.rule, 'no line', ['picks']),
|
||||
colorField('bar', 'Card bar', EMAIL_COLOR.teal, 'no bar', ['picks']),
|
||||
{
|
||||
path: 'text',
|
||||
label: 'Footer',
|
||||
|
|
@ -184,9 +181,9 @@ const PARTS_SPEC = {
|
|||
when: { path: 'type', value: 'footer' },
|
||||
help: `Default: ${SITE_NAME} and ${SITE_ORIGIN}`,
|
||||
},
|
||||
colorField('rule', 'Line above', 'Teal, lightest', 'None: no line', ['footer']),
|
||||
colorField('rule', 'Line above', EMAIL_COLOR.rule, 'no line', ['footer']),
|
||||
...blockFields,
|
||||
colorField('color', 'Line color', 'Teal, lightest', 'None: space only', ['divider']),
|
||||
colorField('color', 'Line color', EMAIL_COLOR.rule, 'space only', ['divider']),
|
||||
{ path: 'size', label: 'Thickness', widget: 'number', when: { path: 'type', value: 'divider' }, help: 'In pixels, 1 to 8. Default: 2' },
|
||||
{ path: 'space', label: 'Space above', widget: 'number', when: { path: 'type', value: 'divider' }, help: 'In pixels, 0 to 64. Default: 24' },
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue