Skip to content

Card styling/UX improvements #16983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 2, 2025
Merged

Conversation

brandonkelly
Copy link
Member

@brandonkelly brandonkelly commented Mar 29, 2025

Description

Cards, chips, and inline-editable Matrix blocks are now styled more consistently:

  • Each have a consistent background color (either gray or based on the entry type color), with a subtle 1px border around it, and subtle box shadow.
  • Cards and inline-editable Matrix blocks have titlebars that have a slightly darker background color, which include the icon and entry type name (if applicable) on the left, and action items on the right.
  • Card thumbnails are now styled more consistently with large chips, and are now right-aligned, so card content lines up regardless of whether there’s a thumbnail.

Various element cards and chips

A couple UX improvements are included as well:

  • Nested element cards’ titles are no longer hyperlinked. Instead, an edit button is included in the toolbar, which opens the slideout editor. Command/Ctrl-clicking on an edit button opens the element’s edit page in a new window (if it has one).
  • Card body text is now user-selectable.

Related issues

Copy link

linear bot commented Mar 29, 2025

@brandonkelly brandonkelly force-pushed the feature/cms-1367-improve-card-stylingux branch from 233d0fe to aa78de3 Compare March 30, 2025 21:18
@iainhenderson
Copy link

Brilliant thanks @brandonkelly

Copy link
Contributor

@i-just i-just left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few of issues that I noticed:

  • when you create a new nested entry in a matrix field (view mode cards) for an existing or brand new root entry, once the nested entry is saved, you can’t use the actions menu (3 dots); the edit icon triggers two edit slideouts, reordering doesn’t seem to work (via diamond icon); once you reload the page (or save the root entry), all of the above starts working as expected
  • matrix in cards view mode (with the standard title field), when you duplicate a nested entry via actions menu > duplicate, it shows the title as hyperlinked; if you reload, the hyperlink is gone; same with copy and paste; this doesn’t happen when duplicating in the element index view mode;
  • if you’ve chosen to show Entry Type in the card and you’re logged in as a non-admin, the Entry Type name is hyperlinked, but you don’t have permissions to edit Entry Types; maybe it would be best not to hyperlink it for non-admins?
  • if we’re hyperlinking the Entry Type in the card, should we also hyperlink the Section (to link to the Section’s settings)?
  • on the element index page in table view mode, there seems to be a large gap between the last item on the list and the footer

BTW, I love that you can click on the name of the entry type to edit it straight away (e.g. from the field edit page).

Once released, the CKEditor should be updated so that we don’t show the edit button and don’t hyperlink the title in the nested element cards.

@brandonkelly
Copy link
Member Author

brandonkelly commented Mar 31, 2025

Thanks @i-just!

  • when you create a new nested entry in a matrix field (view mode cards) for an existing or brand new root entry, once the nested entry is saved, you can’t use the actions menu (3 dots); the edit icon triggers two edit slideouts, reordering doesn’t seem to work (via diamond icon); once you reload the page (or save the root entry), all of the above starts working as expected

Good catch. Looks like I introduced that in fd65d23 for #16893, so fixed on the 5.7 branch.

  • matrix in cards view mode (with the standard title field), when you duplicate a nested entry via actions menu > duplicate, it shows the title as hyperlinked; if you reload, the hyperlink is gone; same with copy and paste; this doesn’t happen when duplicating in the element index view mode;

Fixed!

  • if you’ve chosen to show Entry Type in the card and you’re logged in as a non-admin, the Entry Type name is hyperlinked, but you don’t have permissions to edit Entry Types; maybe it would be best not to hyperlink it for non-admins?

Doh, yeah. Updated all components’ getCpEditUrl() methods to return null for non-admins.

  • if we’re hyperlinking the Entry Type in the card, should we also hyperlink the Section (to link to the Section’s settings)?

Agreed. Updated section attributes to render as chips.

  • on the element index page in table view mode, there seems to be a large gap between the last item on the list and the footer

Are you referring to the 24px top margin on the footer? If so that’s intentional and hasn’t changed in 5.7 or this PR.

The top margin of the control panel footer

Once released, the CKEditor should be updated so that we don’t show the edit button and don’t hyperlink the title in the nested element cards.

Yep. Actually it would be safe to update now. The instance config passed to app/render-elements just needs to include:

showEditButton: false,
hyperlink: false,

Those values will just be ignored if running < 5.7.

@i-just
Copy link
Contributor

i-just commented Mar 31, 2025

Thanks!

Looks like the edit icon still opens up two slideouts (when you create a new nested entry in a matrix field (view mode cards) for an existing or brand new root entry).

Are you referring to the 24px top margin on the footer? If so that’s intentional and hasn’t changed in 5.7 or this PR.

I meant the space between the last item and the footer. It looks about 15px taller on this PR vs 5.x branch. I measured the space between the bottom of the title and the start of the footer, and it’s around 30px on 5.x and 45px on this branch. (The #footer margin-block is 9px on 5.x and 5.7 and 24px on this branch.)

5.x
Screenshot 2025-03-31 at 13 34 28

this branch
Screenshot 2025-03-31 at 13 35 28

Yep. Actually it would be safe to update now. The instance config passed to app/render-elements just needs to include

Yup, I already have it done locally :) I’ll PR it at some point today.

Copy link
Contributor

@brianjhanson brianjhanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a bit I tried to figure out if we could make matrix blocks and cards share the same rendering path, but it looked like that was a bigger job than was worth taking on right now.

@thupsi
Copy link

thupsi commented Mar 31, 2025

Hi! I've noticed some bugs with the new styles:

image

  1. The active tab in the "Row" block has a white background, instead of a yellow tint.
  2. The "Column" blocks, having no color set, are inheriting the yellow shade for their titlebar.
  3. The text in those blocks also inherits the text color from the parent "Row" block, so it's not gray but dark brown/yellow instead (might not be immediately noticeable in the screenshot).

In addition to the above I would like to make a proposal to add "White" to the available colors for entry types. Since the default now is implicitly "Gray", it would enable keeping the palette muted but have visual grouping and hierarchy by lightness as opposed to color, like in the example bellow:

image

@brandonkelly
Copy link
Member Author

Looks like the edit icon still opens up two slideouts (when you create a new nested entry in a matrix field (view mode cards) for an existing or brand new root entry).

@i-just Doh, missed that. Fixed now!

  • The active tab in the "Row" block has a white background, instead of a yellow tint.
  • The "Column" blocks, having no color set, are inheriting the yellow shade for their titlebar.
  • The text in those blocks also inherits the text color from the parent "Row" block, so it's not gray but dark brown/yellow instead (might not be immediately noticeable in the screenshot).

@thupsi Thanks for testing! Fixed.

[ci skip]
@brandonkelly brandonkelly merged commit dcbc02e into 5.7 Apr 2, 2025
@brandonkelly brandonkelly deleted the feature/cms-1367-improve-card-stylingux branch April 2, 2025 03:26
@thupsi
Copy link

thupsi commented Apr 2, 2025

@brandonkelly I found another small CSS color bug. Text in CKEditor fields inherits the text color of the containing block:
image

@brandonkelly
Copy link
Member Author

@thupsi Thanks, posted that on CKEditor’s repo: craftcms/ckeditor#390

@iamtompickering
Copy link

iamtompickering commented Apr 13, 2025

@brandonkelly not sure if it's just me being a bit picky (apologies if I am!), but the font sizing of Blocks as inline-editable blocks feels a little off now to me. I made a few minor CSS changes using a CP CSS plugin to make a few adjustments.

Before:
CleanShot 2025-04-13 at 15 27 06@2x

CleanShot 2025-04-13 at 15 38 49@2x

After:
CleanShot 2025-04-13 at 15 43 52@2x

CleanShot 2025-04-13 at 15 39 53@2x

The sizing adjustments I made feel a little more in keeping with the spacing of everything else around it in my opinion. Just thought I'd share my opinions, hope that's okay!

@brandonkelly
Copy link
Member Author

@iamtompickering Thank for the feedback. I prefer the smaller font size for entry type labels, as a way to set it apart from the tab labels, but I agree the tightened-up inline-editable blocks looks a bit better. So just made that change for the next release. (ea36d22)

@iamtompickering
Copy link

iamtompickering commented Apr 15, 2025

@brandonkelly completely fair and understand the logic behind it! I'm sure I'll learn to love the smaller font size!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants