acf-editor-palette icon indicating copy to clipboard operation
acf-editor-palette copied to clipboard

Override palette with custom_colors setting

Open mike-sheppard opened this issue 2 years ago • 4 comments

Summary

Following up on #53 - this PR adds the ability to override the palette with custom_colors setting. It doesn't solve the issue of the ACF admin UI, which will probably need a lot more thought.

Example

$terms_options
    ->addField('using_theme_palette', 'editor_palette')
    ->addField('using_custom_colors', 'editor_palette', [
        'custom_colors' => [
            [
                'name' => 'Cyan',
                'slug' => 'cyan',
                'color' => '#00ffff',
            ],
            [
                'name' => 'Magenta',
                'slug' => 'magenta',
                'color' => '#ff00ff',
            ],
            [
                'name' => 'Yellow',
                'slug' => 'yellow',
                'color' => '#ffff00',
            ],
            [
                'name' => 'Black',
                'slug' => 'black',
                'color' => '#000000',
            ],
        ],
    ]);

Preview

2023-09-07 2019 - Google Chrome

mike-sheppard avatar Sep 07 '23 19:09 mike-sheppard

Added field settings for it. The repeater stuff is super jank though. Not sure if there's a better way to render the sub fields. 😩

I was forced to add _name, etc. to the sub fields which just feels bad.

Screenshot

Log1x avatar Sep 07 '23 19:09 Log1x

Ah nice, decent start!

mike-sheppard avatar Sep 07 '23 20:09 mike-sheppard

Sorry, I just realised my update doesn't take the update_value & validate_value methods into account 😬 looking into it now!

mike-sheppard avatar Sep 07 '23 20:09 mike-sheppard

Ok all working after this update - not sure if this is a great way to do this or confusing things ~~so pushed to another branch. Lemme know if worth bringing over 🙏~~

Update - merged that fix in so we can start using/testing on a real project.

mike-sheppard avatar Sep 07 '23 20:09 mike-sheppard