Support variable grid columns for grid views style plugin

Created on 19 March 2020, over 4 years ago
Updated 27 September 2023, about 1 year ago

The grid views style currently assumes a 12 column grid, but Bootstrap's grid can have a variable number of columns and is not always 12.

The attached patch defaults the views style plugin to a 12 column grid but lets the user change it. Available column sizes are calculated based on the grid columns size.

✨ Feature request
Status

Needs review

Version

5.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jienckebd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States robbt

    The additional components of row classes on patch #4 solve the issue reported here - https://www.drupal.org/project/views_bootstrap/issues/3324207 πŸ› Row class added to all columns Active for 5.5.x -

    Also I tested this and it applied on 5.5.x but I'm not really sure that changing the grids works correctly. I think that it would make sense to take the additional code jienckebd provided and make it into a patch that could solve the other issue. I may put together a patch if I get a chance.

    I think that a better way to make columns more responsive would be to support - Row Columns - see https://getbootstrap.com/docs/5.3/layout/grid/#row-columns

    It was evidently introduced into Bootstrap with version 4.4 - https://blog.getbootstrap.com/2019/11/26/bootstrap-4-4-0/

    This is a lot cleaner in my mind for Views since it allows you to set the number of columns for each breakpoint while also providing a default aka mobile breakpoint of 1. This is what I've been using for cards - class="row row-cols-1 row-cols-md-3 row-cols-lg-5" - this would be impossible to implement with the current grid options because everything has to be divisible by 12.

    Also this should in theory work pretty well with views since all of the items will likely be of uniform width and so relying upon the row to set the number of columns is cleaner in my opinion.

    I'm not sure if this would be the best approach for the 5.4.x branch as I'm not sure if we want to impose a requirement to use 4.4.x and above but I do think it would make sense to roll out this approach for 5.5.x

    In the meantime with the row class fix patched in this approach can be done via applying a row class which is nice.

Production build 0.71.5 2024