Repository navigation
Calendar: Add border support - #64345
shail-mehta wants to merge 74 commits into
Conversation
|
Size Change: +3.49 kB (+0.04%) Total Size: 7.92 MB 📦 View Changed
|
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR!
My feeling is that, like with the Table block, border support should be reflected on the cells rather than the block itself.
Border support for the Table block works as follows:
e1789fcbbad75a414ef78ed6f107f1f7.mp4
This may require some complex modifications to achieve, but the source for the Table block should help.
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thank you for working on this one @shail-mehta 👍
I'm wondering if the Calendar block might need a more nuanced approach to how it adopts border support.
If the block simply adopts border support and applies the styles to the block's wrapper, it might also need spacing support (at least padding).
The block currently uses the currentColor for the calendar's inner borders. As a user, I'd probably expect any border color selections I make to apply there.
Another question is whether the border should be around the header and navigation links or just the calendar's table. When the outer border is the same color as the inner borders and there is no padding between the calendar and the outer border, it looks like the border width is uneven due to the two borders coming together.
Given the varied questions, I think it would be great to get some design feedback here. I've taken the liberty of adding that label to this PR.
|
Thank you @t-hamano and @aaronrobertshaw for the Feedback. I will work on this PR and address the suggested changes. |
|
Not that there is an ongoing effort to make the editor component markup consistent with the frontend, and once that refactoring is complete, it may be easier to tackle this PR: #60763 |
d621577 to
c48efc9
Compare
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for picking this back up @shail-mehta 👍
I have Applied feedback changes.
I'm not sure all the suggestions have been resolved. Some aspects were still open for discussion, e.g. border around the block or around the cells only. Could the block have a setting added allowing the border to be applied to the block wrapper or the cells?
Additionally, if the border is applied to the cells I don't think any user would expect the borders not to collapse.
The border around the empty placeholder cell before the start, or after the end, date of the month probably shouldn't happen too if the calendar doesn't have a outer border.
The last thought that comes to mind after a quick glance is the border radius application for calendar cells seems clunky. If there's a border and you make the border-collapse separate it just looks odd. I could see a use case though for border radius on the cells if the cells have a background color and spacing around them.
This comes back to my earlier thoughts that the adoption of borders here might also need some related efforts to add better support for spacing.
Curious to see what others, in particular those with design chops, think about this direction.
Agree with this suggestion - I'll defer to the design eagles, but personally I'd expect to be able to control the cell borders, which might mean we need to decouple text color somehow. Some blocks are just tricky this way 😄 |
|
@fcoveram thanks for bringing your expertise to this one 🙇 The problem here is the Calendar block is an old legacy block that even uses server side rendering. So backward compatibility becomes a major issue.
A lot of this points to a complete overhaul for the block. In the meantime, we probably need a middle ground for what styles can be supported via block supports and how they can be applied, imperfect as that application might be on the current version of the block. |
|
Thank you all for the feedback. I'll update this PR. |
987b992 to
9d61caa
Compare
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for the updates @shail-mehta 👍
This is close.
✅ Existing calendars still match trunk
✅ Global Styles per-side borders land on the outer edge
✅ The earlier test, PHPStan and changelog failures are fixed
Thick edges and rows
The doubling in @t-hamano's "border color only" example is a bug in this PR.
- A colour-only border gets a default
solidstyle, so thetabledraws its own 3px edge over the 1px cells. Global Styles stays 1px. - The
border-stylerule also stylesthead,tbodyandtr, so any style draws 3px lines between rows.
RTL
- Block borders: wrapping the edge loop in
/*rtl:begin:rename*/fixes the RTL stylesheet. - Global Styles: the
rightandleftselectors pick by DOM order, so a right border draws inside the grid. Adding:dir(rtl)variants would fix it.
|
Thanks for the feedback @t-hamano and @aaronrobertshaw I will work on this. |
8cd702b to
1c314a9
Compare
Prevent the table from drawing a medium outer edge when only border color or style is set, and flip left/right edges correctly in RTL for block and Global Styles borders.
|
Thanks @aaronrobertshaw 👍 I've updated the PR for the remaining points:
Happy for another look when you get a chance. |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for the updates @shail-mehta 👍
This is very close.
✅ Colour-only and style-only borders are now 1px, with no thick row lines
✅ RTL block and Global Styles side borders land on the correct edge (tested with a Hebrew site)
✅ Calendars without border settings still match trunk
Per-side colour or style only
A side with only a colour or style still draws a 3px edge. A top colour alone gives the table a 3px top edge. The same Global Styles value stays 1px.
The 1px rule only covers values set on all sides. Adding the same rule per side inside the edge loop fixes it, in RTL too:
table[style*="border-#{$edge}-color"],
table[style*="border-#{$edge}-style"] {
&:not([style*="border-#{$edge}-width"]) {
border-#{$edge}-width: 1px;
}
}|
Thanks @aaronrobertshaw - Added the per-side 1px rule inside the edge loop for color/style-only sides, without changing the existing all-sides rule. |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for the updates @shail-mehta 👍
The per-side fix works. One small thing left.
✅ A colour-only or style-only side is now 1px, in LTR and RTL (tested with a Hebrew site)
✅ Row lines, RTL block borders and RTL Global Styles borders still hold
✅ Calendars without borders render the same HTML as trunk
Radius from theme.json lands on the cells
On trunk, a theme.json or Global Styles radius for the Calendar rounds the block's outer box. With this PR the border.root selector sends the radius to every cell. The header cells then show rounded grey corners.
Adding "radius": ".wp-block-calendar" to selectors.border should keep the radius off the cells.
|
Thanks @aaronrobertshaw 🙇
|
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for the updates 👍
Borders now mostly work for blocks, Global Styles, style variations and RTL, but two issues remain.
A block border style resets the Global Styles width
With a 4px width in Global Styles, picking only a dashed style on a block drops every cell to 1px. The border-style rule also passes the table's width to the cells.
Radius
A theme.json radius goes to the wrapper, while a block radius lands on the table. Global Styles and block styles need to apply to the same element.
Neither rounds anything yet, because the table collapses its borders. On trunk, a theme.json border with a radius draws a rounded outline, so those themes now get a square grid.
Rounding the grid needs separate borders and a radius on the four corner cells. I'd suggest leaving radius for a follow-up, as the Table block does.
|
@shail-mehta To be direct about the process: I've now reviewed this PR nearly ten times. Most of what each round finds could have been caught in a self-review before asking for re-review. Radius not rounding anything suggests the last changes weren't tested on screen. The PR description should also have basic before and after screenshots. Keeping those updated would also facilitate catching basic regressions or bugs. Review time is limited for everyone, so we need to be careful of shifting the burden of development onto reviewers. After each iteration could you please:
If you use an AI tool, the prompt below covers what I try to check each round. You might also be able to utilise requesting Copilot reviews on your PRs too. More targeted example for this PR |
|
Thanks @aaronrobertshaw 🙇 I've addressed the two remaining points:
ScreenshotsGlobal Styles 4px
Global Styles 4px + dashed style on the block
Width only
Top border only
Radius
Happy to adjust further if anything still looks off. |
|
@shail-mehta As per the comment above, there were three things asked for before the next re-review was requested. They have not happened.
The fixes and the reply request came within about an hour of that comment. Tough to complete a full self-review, in that time when this has lots of edge cases. I'm not able to keep finding these sorts of bugs on each round. My plate is quite full with other reviews and feature work, after 10 reviews, I will need to shift focus onto other areas. Please work through every step of the earlier comment, update the PR description/screenshots etc, and post its summary before asking for another review. The example AI prompt will be a friend to both me and you 🙂 |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
After the latest updates:
✅ The dashed block style now keeps the Global Styles width
✅ Border radius is out of this PR
❓ PR description is still missing screenshots etc.
❓ There's a bug with width-only block instance styles
A block border width only drops the Global Styles style
With a dashed Global Styles border, setting only a border width on the block turns every cell solid.
The cells inherit their style from the table, which falls back to solid. Per-side Global Styles styles are likely affected too.
Radius
Could we add "radius": false to __experimentalBorder? It records that radius is left out on purpose.
PR description
- State the scope: border radius is deliberately out of scope, and spacing and block gap are not added.
- Add the before and after screenshots, and keep them current.














What?
Add border support to the Calendar block.
Borders apply to the table; cells inherit color, style, and width (same pattern as the Table block). Text and background colors remain skip-serialized on the table (#42029) so month navigation links are not affected. Global Styles border rules target
th/tdviaselectors.border.Part of #43247
Why?
The Calendar block has no border controls. Because it is a legacy server-rendered block, styles must be applied carefully so existing sites keep their default cell borders and colors.
How?
__experimentalBorderwith skip-serialization, and apply instance border/color styles on the calendartablein PHP.caption.:where()so theme resets do not wipe them, while Global Styles can still override.$gray-300/currentColorborder-color fallbacks for backward compatibility.blockGapsupport in this PR.Testing Instructions
currentColorwhen no border color is set.td { border: none }— default calendar cell borders should still show.Use Of AI Tools
Yes (Cursor assisted with screenshots; manually verified by me)
Summary by CodeRabbit