From bfb78c9e855226013ed8ba574d4247254faf8c2d Mon Sep 17 00:00:00 2001 From: dhananjaykuber Date: Mon, 8 Jul 2024 22:56:28 +0530 Subject: [PATCH] Fix Calendar Block color options in editor --- packages/block-library/src/calendar/edit.js | 12 +++++++++++- packages/block-library/src/calendar/style.scss | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/calendar/edit.js b/packages/block-library/src/calendar/edit.js index a60a18d8eeae8..aee0e4116853c 100644 --- a/packages/block-library/src/calendar/edit.js +++ b/packages/block-library/src/calendar/edit.js @@ -34,7 +34,17 @@ const getYearMonth = memoize( ( date ) => { } ); export default function CalendarEdit( { attributes } ) { - const blockProps = useBlockProps(); + const blockProps = useBlockProps( { + className: [ + attributes.backgroundColor + ? `has-${ attributes.backgroundColor }-background-color` + : '', + attributes.textColor ? `has-${ attributes.textColor }-color` : '', + ] + .filter( Boolean ) + .join( ' ' ), + } ); + const { date, hasPosts, hasPostsResolved } = useSelect( ( select ) => { const { getEntityRecords, hasFinishedResolution } = select( coreStore ); diff --git a/packages/block-library/src/calendar/style.scss b/packages/block-library/src/calendar/style.scss index 969d1aafec99e..f16b0c0ff7d06 100644 --- a/packages/block-library/src/calendar/style.scss +++ b/packages/block-library/src/calendar/style.scss @@ -37,9 +37,26 @@ color: inherit; } } + + &.has-background { + table#wp-calendar th { + background: inherit; + } + } } // Keep the hard-coded header background color for backward compatibility. :where(.wp-block-calendar table:not(.has-background) th) { background: $gray-300; } + +// Update editor color. +.wp-block-calendar.has-link-color table#wp-calendar th, +.wp-block-calendar.has-link-color table#wp-calendar { + color: inherit; + border-color: inherit; +} + +.wp-block-calendar.has-link-color table#wp-calendar td { + border-color: inherit; +}