Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ab78eef
Calendar: Add Border Support
shail-mehta Aug 7, 2024
f4a9b27
Applied feedback changes
shail-mehta Jun 27, 2026
4080aca
fix phpcs issue
shail-mehta Jun 27, 2026
1bc866e
fix phpcs issue
shail-mehta Jun 27, 2026
ff2345d
fix lint issue
shail-mehta Jun 27, 2026
21cd48b
fix lint issue
shail-mehta Jun 27, 2026
83d6dce
Applied feedback changes
shail-mehta Jul 10, 2026
0af8806
fix phpcs issue
shail-mehta Jul 10, 2026
fce28f8
fix phpcs issue
shail-mehta Jul 10, 2026
95da663
apply feedback changes
shail-mehta Jul 11, 2026
ed634c9
apply feedback changes
shail-mehta Jul 11, 2026
61d29fe
fix unit test
shail-mehta Jul 11, 2026
21d1220
Fix bg color and text color issue
shail-mehta Jul 11, 2026
dff0b1c
Fix bg color and text color issue
shail-mehta Jul 11, 2026
f84a7b4
Fix bg color and text color issue
shail-mehta Jul 11, 2026
4fc14ae
Added Spacing Support
shail-mehta Jul 11, 2026
d5c08dc
Added Spacing Support
shail-mehta Jul 11, 2026
fb620d5
Added Spacing Support
shail-mehta Jul 11, 2026
56b73de
Added Spacing Support
shail-mehta Jul 11, 2026
080c5d5
Apply Feedback Changes
shail-mehta Aug 23, 2026
ec5c1db
Fix Changelog Conflict Issue
shail-mehta Aug 23, 2026
27165ca
Fix Changelog Conflict Issue
shail-mehta Aug 23, 2026
b38f87f
Update CHANGELOG for unreleased changes
shail-mehta Aug 23, 2026
4b4064e
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Aug 23, 2026
d7eb901
Fix global style not applied issue
shail-mehta Aug 23, 2026
e8dbb30
Fix global style not applied issue
shail-mehta Aug 23, 2026
ccc0125
Added Space between month/year
shail-mehta Aug 25, 2026
156f9b7
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Aug 26, 2026
4ae2ba3
Fix Lint
shail-mehta Aug 26, 2026
7a0264e
Apply Feedback Changes
shail-mehta Aug 27, 2026
1bf3a91
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Aug 27, 2026
8f654a3
Fix Unit Test
shail-mehta Aug 27, 2026
ad3313b
Fix Unit Test
shail-mehta Aug 27, 2026
49886f2
Fix serialization
shail-mehta Aug 27, 2026
d55e39b
Fix phpcs issue
shail-mehta Aug 27, 2026
c42e56d
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Aug 29, 2026
4117b88
apply feedback changes
shail-mehta Aug 31, 2026
9abdc47
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Aug 31, 2026
074b88a
fix phpcs
shail-mehta Aug 31, 2026
481f745
Apply Feedback Changes
shail-mehta Sep 1, 2026
0456ac7
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Sep 1, 2026
787ef84
Apply Feedback Changes
shail-mehta Sep 1, 2026
dc6ac2a
Removed unrelated changes
shail-mehta Sep 1, 2026
ee28541
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Sep 4, 2026
2a735c4
Fix CodeRabbit issues in PR #64345
coderabbitai[bot] Sep 4, 2026
09b1b19
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Sep 4, 2026
747a6d3
Calendar: address border feedback and drop spacing support
shail-mehta Nov 8, 2026
a285c20
Merge remote-tracking branch 'origin/trunk' into tmp/calendar-conflic…
shail-mehta Nov 8, 2026
d7836bc
Calendar: move changelog to Unreleased and bump @since to 7.3.0
shail-mehta Nov 8, 2026
336e304
Calendar:
shail-mehta Nov 9, 2026
00d5f72
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 9, 2026
f597d58
fix phpstan
shail-mehta Nov 9, 2026
c1444f3
revert unintended changes
shail-mehta Nov 9, 2026
8e062d6
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 9, 2026
0c6aed6
Calendar: Address border support review feedback
shail-mehta Nov 9, 2026
f111e73
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 9, 2026
8ae4c60
Add WordPress 7.3 backport changelog entry
shail-mehta Nov 9, 2026
9973f52
Fix unit test
shail-mehta Nov 9, 2026
640cc86
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 10, 2026
9d366db
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 10, 2026
40e36d2
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 11, 2026
1c314a9
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 11, 2026
5b0b5d6
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 12, 2026
cd9cd5e
Calendar: Fix color-only border thickness and RTL edge selectors
shail-mehta Nov 12, 2026
dcaf9a6
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 12, 2026
b8a7530
Calendar: Fix color-only border width thickening cells
shail-mehta Nov 12, 2026
173ba61
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 12, 2026
7b918f0
Apply Feedback Changes
shail-mehta Nov 13, 2026
274d853
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 13, 2026
bbf4429
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 16, 2026
82c1571
Apply Feedback Changes
shail-wp Nov 17, 2026
058b2a5
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 17, 2026
cc73184
Apply Feedback Changes
shail-wp Nov 17, 2026
945ac40
Merge branch 'trunk' into add/calendar-border-support
shail-mehta Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/7.3/15849.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/15849

* https://github.com/WordPress/gutenberg/pull/64345
1 change: 1 addition & 0 deletions packages/block-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Categories List: Use the UI SelectControl for the Taxonomy setting ([#86197](https://github.com/WordPress/gutenberg/pull/86197)).
- Template Part: Use the UI SelectControl for the Area and Import widget area settings ([#86565](https://github.com/WordPress/gutenberg/pull/86565)).
- Cover: Move the minimum height to the `dimensions` block support ([#83447](https://github.com/WordPress/gutenberg/pull/83447)).
- Calendar: Add border support ([#64345](https://github.com/WordPress/gutenberg/pull/64345)).

### Bug Fixes

Expand Down
13 changes: 13 additions & 0 deletions packages/block-library/src/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
- `clientNavigation`: `true`

## CSS Selectors

_Defined via the [`selectors`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-selectors/) property in block.json._

- **border**:
- root: `.wp-block-calendar th, .wp-block-calendar td`
- radius: `.wp-block-calendar`
- top: `.wp-block-calendar thead th`
- right: `.wp-block-calendar:not(:dir(rtl)) tr > :last-child, .wp-block-calendar:dir(rtl) tr > :first-child`
- bottom: `.wp-block-calendar tbody tr:last-child > *`
- left: `.wp-block-calendar:not(:dir(rtl)) tr > :first-child, .wp-block-calendar:dir(rtl) tr > :last-child`
- **color**: `.wp-block-calendar table, .wp-block-calendar th`

## Block Markup

This is a [**dynamic block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/). It is rendered on the server and does not save HTML in post content.
Expand Down
22 changes: 19 additions & 3 deletions packages/block-library/src/calendar/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"__experimentalDefaultControls": {
"background": true,
"text": true
},
"__experimentalSelector": "table, th"
}
},
"typography": {
"fontSize": true,
Expand All @@ -40,9 +39,26 @@
"fontSize": true
}
},
"__experimentalBorder": {
"color": true,
"width": true,
"style": true,
"__experimentalSkipSerialization": true
},
"interactivity": {
"clientNavigation": true
}
},
"style": "wp-block-calendar"
"style": "wp-block-calendar",
"selectors": {
"border": {
"root": ".wp-block-calendar th, .wp-block-calendar td",
"radius": ".wp-block-calendar",
"top": ".wp-block-calendar thead th",
"right": ".wp-block-calendar:not(:dir(rtl)) tr > :last-child, .wp-block-calendar:dir(rtl) tr > :first-child",
"bottom": ".wp-block-calendar tbody tr:last-child > *",
"left": ".wp-block-calendar:not(:dir(rtl)) tr > :first-child, .wp-block-calendar:dir(rtl) tr > :last-child"
},
"color": ".wp-block-calendar table, .wp-block-calendar th"
}
Comment thread
t-hamano marked this conversation as resolved.
Resolved
}
48 changes: 38 additions & 10 deletions packages/block-library/src/calendar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,51 @@ function render_block_core_calendar( $attributes ) {
}
}

// Calendar applies only text and background colors, not gradients.
$color_attributes = array_intersect_key( $attributes, array_flip( array( 'textColor', 'backgroundColor' ) ) );
/*
* Text, background, and border are skip-serialized onto the table (#42029).
* Cell borders inherit from the table via style.scss (same pattern as Table).
* Calendar applies only text and background colors, not gradients.
*/
$support_attributes = array_intersect_key( $attributes, array_flip( array( 'textColor', 'backgroundColor', 'borderColor' ) ) );
foreach ( array( 'text', 'background' ) as $feature ) {
if ( isset( $attributes['style']['color'][ $feature ] ) ) {
$color_attributes['style']['color'][ $feature ] = $attributes['style']['color'][ $feature ];
$support_attributes['style']['color'][ $feature ] = $attributes['style']['color'][ $feature ];
}
}
if ( isset( $attributes['style']['border'] ) ) {
$support_attributes['style']['border'] = $attributes['style']['border'];
/*
* Radius needs collapsed borders lifted and corner cells rounded.
* Leave it for a follow-up (same as Table). Keep it off the table so
* instance styles match Global Styles targeting the wrapper via
* selectors.border.radius.
*/
unset( $support_attributes['style']['border']['radius'] );
}

$styles = wp_get_block_supports_classes_and_styles( $support_attributes, array( 'color', 'border' ) );
$table_styles = $styles['style'] ?? '';
$table_classes = $styles['class'] ?? '';

$styles = wp_get_color_classes_and_styles( $color_attributes );
$inline_styles = empty( $styles['style'] ) ? '' : sprintf( ' style="%s"', esc_attr( $styles['style'] ) );
$classnames = empty( $styles['class'] ) ? '' : ' ' . esc_attr( $styles['class'] );
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classnames .= ' has-link-color';
$table_classes = trim( $table_classes . ' has-link-color' );
}

$calendar = get_calendar( array( 'display' => false ) );
$calendar = is_string( $calendar ) ? $calendar : '';
$processor = new WP_HTML_Tag_Processor( $calendar );

if ( $processor->next_tag( 'TABLE' ) ) {
if ( '' !== $table_styles ) {
$processor->set_attribute( 'style', $table_styles );
}

foreach ( preg_split( '/\s+/', $table_classes, -1, PREG_SPLIT_NO_EMPTY ) as $classname ) {
$processor->add_class( $classname );
Comment thread
aaronrobertshaw marked this conversation as resolved.
Resolved
}
}
// Apply color classes and styles to the calendar.
$calendar = str_replace( '<table', '<table' . $inline_styles, get_calendar( array( 'display' => false ) ) );
$calendar = str_replace( 'class="wp-calendar-table', 'class="wp-calendar-table' . $classnames, $calendar );

$calendar = $processor->get_updated_html();

$wrapper_attributes = get_block_wrapper_attributes();
$output = sprintf(
Expand Down
111 changes: 108 additions & 3 deletions packages/block-library/src/calendar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
th,
td {
padding: 0.25em;
border: 1px solid;
}

th {
Expand All @@ -32,16 +31,122 @@

:where(table:not(.has-text-color)) {
color: #40464d;
}

/*
* Keep `.wp-block-calendar` outside `:where()` so the specificity stays
* (0,1,0). This beats bare theme `td`/`th` rules while still allowing
* Global Styles to override it.
*/
:where(th),
:where(td) {
border: 1px solid;
}

:where(table:not(.has-text-color) th),
:where(table:not(.has-text-color) td) {
border-color: $gray-300;
}

// Keep the hard-coded border color for backward compatibility.
// Border Styles
//
// Instance borders are applied on the table; th/td inherit color,
// style, and width. Per-side values are treated as outer edges.
// Global Styles target cells via block.json selectors.
// Flat border colors always add has-border-color (style engine).
//
// Color- or style-only selections add a default solid style with no
// width. Without an explicit width the table would draw medium (3px)
// over the 1px cells. Match the cell default instead. Do not touch
// tables that already have a width so cells still inherit it.
table.has-border-color:not([style*="border-width"]),
table[style*="border-style"]:not([style*="border-width"]) {
border-width: 1px;
}

table.has-border-color {
thead,
tbody,
tr,
th,
td {
border-color: $gray-300;
border-color: inherit;
}
}

// Cells inherit style from the table through thead/tbody/tr (same as Table).
// Do not inherit width here: a style-only block border would overwrite a
// Global Styles width on the cells with the table's fallback 1px.
table[style*="border-style"] {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
thead,
tbody,
tr,
th,
td {
border-style: inherit;
}
}

// Style-only borders still need 1px on the row structure so those elements
// do not fall back to medium (~3px). Leave th/td widths alone so Global
// Styles (and the cell defaults) keep control.
table[style*="border-style"]:not([style*="border-width"]) {
thead,
tbody,
tr {
border-width: 1px;
}
}

table[style*="border-width"] {
thead,
tbody,
tr,
th,
td {
border-width: inherit;
border-style: inherit;
}
}

// The calendar table comes from `get_calendar()`, so the markup is fixed:
// one thead with a single row, one tbody, no tfoot. Avoid `> *` so the
// caption never picks up table edge borders.
/*rtl:begin:rename*/
$calendar-border-edges: (
"top": "> thead, > thead > tr, > thead > tr > *",
"right": "> thead, > tbody, > thead > tr, > tbody > tr, > thead > tr > :last-child, > tbody > tr > :last-child",
"bottom": "> tbody, > tbody > tr:last-child, > tbody > tr:last-child > *",
"left": "> thead, > tbody, > thead > tr, > tbody > tr, > thead > tr > :first-child, > tbody > tr > :first-child"
);

@each $edge, $selectors in $calendar-border-edges {
@each $property in ("color", "style", "width") {
table[style*="border-#{$edge}-#{$property}"] {
#{$selectors} {
border-#{$edge}-#{$property}: inherit;

@if $property == "width" {
border-#{$edge}-style: inherit;
}
}
}
}

// Color- or style-only on one side still needs a 1px width. The
// all-sides rule above only matches values set on every edge.
table[style*="border-#{$edge}-color"],
table[style*="border-#{$edge}-style"] {
&:not([style*="border-#{$edge}-width"]) {
border-#{$edge}-width: 1px;
}
}
}
/*rtl:end:rename*/
}

// Keep the hard-coded header background color for backward compatibility.
// Global Styles also targets `th` (see block.json selectors.color).
:where(.wp-block-calendar table:not(.has-background) th) {
background: $gray-300;
}
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ parameters:
-
message: '#^Action callback returns .+ but should not return anything\.$#'
identifier: return.void
# wp_get_color_classes_and_styles() is new in WordPress Core: https://github.com/WordPress/wordpress-develop/pull/14094
# Remove this entry once the WordPress stubs are generated from a Core revision that includes it.
-
message: '#^Function wp_get_color_classes_and_styles not found\.$#'
identifier: function.notFound

# wp_get_shadow_classes_and_styles() is new in WordPress Core: https://github.com/WordPress/wordpress-develop/pull/14094
# Remove this entry once the WordPress stubs are generated from a Core revision that includes it.
-
Expand Down
111 changes: 111 additions & 0 deletions phpunit/blocks/render-block-calendar-test.php
Comment thread
t-hamano marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,117 @@ public function data_color_classes_and_styles() {
'expected_class' => 'wp-calendar-table',
'expected_style' => null,
),
'custom border values' => array(
'attributes' => array(
'style' => array(
'border' => array(
'width' => '3px',
'color' => '#111111',
'style' => 'dashed',
),
),
),
'expected_class' => 'wp-calendar-table has-border-color',
'expected_style' => 'border-color:#111111;border-style:dashed;border-width:3px;',
),
'borderColor preset' => array(
'attributes' => array(
'borderColor' => 'contrast',
'style' => array(
'border' => array(
'width' => '2px',
'style' => 'solid',
),
),
),
'expected_class' => 'wp-calendar-table has-border-color has-contrast-border-color',
'expected_style' => 'border-style:solid;border-width:2px;',
),
'uniform per-side border' => array(
'attributes' => array(
'style' => array(
'border' => array(
'top' => array(
'width' => '2px',
'color' => '#111111',
'style' => 'solid',
),
'right' => array(
'width' => '2px',
'color' => '#111111',
'style' => 'solid',
),
'bottom' => array(
'width' => '2px',
'color' => '#111111',
'style' => 'solid',
),
'left' => array(
'width' => '2px',
'color' => '#111111',
'style' => 'solid',
),
),
),
),
// Per-side colours do not add has-border-color; only flat borderColor / border.color do.
'expected_class' => 'wp-calendar-table',
'expected_style' => 'border-top-width:2px;border-top-color:#111111;border-top-style:solid;border-right-width:2px;border-right-color:#111111;border-right-style:solid;border-bottom-width:2px;border-bottom-color:#111111;border-bottom-style:solid;border-left-width:2px;border-left-color:#111111;border-left-style:solid;',
),
'single-side border' => array(
'attributes' => array(
'style' => array(
'border' => array(
'top' => array(
'width' => '2px',
'color' => '#111111',
'style' => 'solid',
),
),
),
),
'expected_class' => 'wp-calendar-table',
'expected_style' => 'border-top-width:2px;border-top-color:#111111;border-top-style:solid;',
),
);
}

/**
* Borders and colors are applied on the table; cells stay free of inline styles
* and support classes. Empty pad cells from get_calendar() may still have class="pad".
*
* @covers ::gutenberg_render_block_core_calendar
*/
public function test_render_does_not_apply_inline_styles_to_cells() {
$block = new WP_Block(
array(
'blockName' => 'core/calendar',
'attrs' => array(
'style' => array(
'border' => array(
'width' => '3px',
'color' => '#111111',
'style' => 'dashed',
),
'color' => array(
'text' => '#123456',
'background' => '#abcdef',
),
),
),
)
);

$processor = new WP_HTML_Tag_Processor( $block->render() );
while ( $processor->next_tag() ) {
$tag = $processor->get_tag();
if ( 'TH' === $tag || 'TD' === $tag ) {
$this->assertNull( $processor->get_attribute( 'style' ) );
$class = $processor->get_attribute( 'class' );
if ( null !== $class ) {
$this->assertSame( 'pad', $class );
}
}
}
}
}
Loading
Loading