Skip to content

v1.4.0

Choose a tag to compare

@Klehm Klehm released this 12 Oct 08:15
· 93 commits to master since this release
7bba97e

This release lets the colour palette follow your theme, including colours your admins edit in your own back office, and shows colour fields as swatches. Existing pages render the same.

Theme variables in the palette (klehm/content-blocks)

A palette entry can name a CSS custom property:

content_blocks:
    palette:
        - { label: 'Primary', color: 'var(--theme-primary, #eb0540)' }

The value is stored and rendered as written, so changing --theme-primary recolours every page that uses it. The hex fallback is the colour's swatch: the builder shows it in the sidebar and the section library thumbnails, and it decides the bg-dark / bg-light tone classes.

In rich text, CKEditor writes the variable as is, and the rich_text sanitizer keeps it. TinyMCE, whose swatches only take hex, writes the fallback.

→ Theme variables in the palette

Colours from your back office (klehm/content-blocks)

When colours are edited in your own admin, store the bare variable and give the current hex as the entry's swatch:

yield new PaletteColor('Primary', 'var(--brand)', swatch: $theme->primaryHex);

Content stores var(--brand) and never changes when the colour does. The builder's swatches, the tone classes and the thumbnails follow the current hex, with no CSS to add to the builder. A config entry takes the same swatch key. The palette is read once per request, so the provider may query your database, worker mode included.

→ Colours from a back office

Colour fields show swatches

PaletteColorType shows a row of swatches (None, your palette, a Custom… picker) instead of a text dropdown, with each colour's name on hover. The field is now a radio group. If a test or script of yours drives it, check() the input[value="#hex"] instead of calling selectOption() on the old <select>.

Fixed

  • A stored colour that is not a hex and is no longer in the palette stays on offer in the field. Before, it fell into the #rrggbb picker and was lost on the next save.

Upgrading

No database migration. The three packages are tagged together. The kit now requires klehm/content-blocks ^1.4.

composer update "klehm/content-blocks*"

Details in each package's changelog: core · kit · i18n