Skip to content
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

Matrix block enhancements: options for compact instructions and field collections #6346

Closed
watershed opened this issue Jul 8, 2020 · 3 comments
Labels
authoring ✍️ features related to author experience enhancement improvements to existing features matrix 🕶️ features related to Matrix fields
Milestone

Comments

@watershed
Copy link

watershed commented Jul 8, 2020

Big fan of Matrix blocks, but they can easily become spatially extravagant when a block requires a large number of fields. Here’s a couple of ways that could optionally be mitigated at the system designer's discretion:

  1. Assign a compact mode to instructions, so that they present and behave like the i symbol does for Assets field instructions:
    • My thought is that this should be a global setting for the field, not a per block type setting
  2. Assign contiguous block fields to a layout collection so that they are wrapped by a containing <div> with a collection name:
    • This would facilitate modern layout techniques such as display:flex or display:grid within custom Control Panel CSS, as opposed to having to use more flaky techniques like float:left
    • Consider, for example:
      • A sequence of horizontally compact date, time and dropdown fields.
      • Because they have no wrapper element other than the block's div.fields, they have to be floated left of each other within a media query, and then the following field have that float cleared.
      • Whereas because field types such as checkbox groups have a wrapper for their options, these can be elegantly laid out with display:flex.
      • Image attached illustrates some example spatially compact field layout. The first row of 4 fields uses float:left with margins. It works but offends my sensibilities! The ‘People data to show’ row exploits the existing container with…
.matrixblock[data-type="item"] .checkbox-group {
    display: grid;
    grid-template-columns: repeat(5, max-content);
    grid-gap: 1.5em;
}

matrix-fields-laid-out-with-custom-styles

@ShaneHudson
Copy link

I have no preference for how this is achieved but the size/sameness of every matrix has been one of its few weaknesses so something like this would be very welcome!

@watershed
Copy link
Author

Re suggestion 2…

Using the Control Panel CSS plugin, I’ve managed to effectively lay out a Matrix field’s blocks with CSS Grid template areas (snapshot of Sass source and desired outcome attached). With that technique, there's plenty that can be done with the existing .fields > .field structure. So I think my second request above for a layout collection is redundant.


My first request for compact field instructions remains on my wish list though.


custom-control-panel-sass-snapshot

11-field-matrix-block-laid-out-with-css-grid

brandonkelly added a commit that referenced this issue Jul 15, 2020
@brandonkelly
Copy link
Member

Just added the ability to customize the widths of Matrix sub-fields for the next Craft 3.5 release, similar to how normal fields’ widths can be customized (see #2644 (comment)).

A Matrix Configuration setting, showing three fields with width selectors

A Matrix block with fields that have custom widths

The idea for a compact UI mode is covered by #3407, so you can subscribe to that issue to follow along with progress.

@brandonkelly brandonkelly added authoring ✍️ features related to author experience enhancement improvements to existing features and removed enhancement labels Jul 15, 2020
@brandonkelly brandonkelly added this to the 3.5 milestone Jul 15, 2020
@brandonkelly brandonkelly added the matrix 🕶️ features related to Matrix fields label Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authoring ✍️ features related to author experience enhancement improvements to existing features matrix 🕶️ features related to Matrix fields
Projects
None yet
Development

No branches or pull requests

3 participants