Development

Gutenberg Grids & Timber ++ Some CSS Grid Magic!

A grid mystery

Somehow the Grids Layout Builder for Gutenberg ist not pushing styles to the footer within a Timber theme. At least not for me.

Somehow the wp_footer action within the Grids plugin is not being executed and no grid styles are added to the footer. I am not getting any errors, but will have to investigate some more in the near future ;)

Update: It is related to the get_footer action within Grids. get_footer is used to load the appropriate footer template file, which I am not using in my Timber theme ;) So the workaround below is perfect.

Quick patch

Here a quick workaround for the theme functions.php, that does the trick for now.

  1. add_action( 'wp_footer', function(){
  2.                 if(class_exists('Grids\Core')){
  3.                         echo Grids\Core::instance()->styles();
  4.                 }
  5. }, 100 );
  6.  

Grids for WordPress, what is that?

“A layout builder is a tool that helps you creating visual structures in your page, from a simple layout made by adjacent columns, to more complex compositions.

Grids is entirely based on the WordPress block editor, which means that you’ll be able to use it together with the myriad of content blocks that developers and designers from all around the World are creating.

With Grids, we’re bringing a visual structure to the content written with the WordPress Block Editor.”
Grids: Layout builder for WordPress / Documentation / CSS-Tricks Article / A Complete Guide to Grid

Grids Example

This is using the Grids Plugin and only took a couple of minutes! I am so glad IE 11 is soon completely unsupported ;) and we can start using CSS Grid freely. Well we can, as nobody should be using IE 11 anymore!!!

On mobile its just stacked rows :)

CSS GRID: SOLVING PUZZLES

COLUMN 1
I love to solve puzzles and find epic solutions :)

CSS Grid Layout excels at dividing a page into major regions or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives.

Like tables, grid layout enables an author to align elements into columns and rows. However, many more layouts are either possible or easier with CSS grid than they were with tables.

LOVE IT!

COLUMN 2
We all love magazine-style layouts and we are getting closer to getting that :) The magic is in the detail.

For example, a grid container’s child elements could position themselves so they actually overlap another layer, similar to CSS positioned elements.

FLEX OR GRID
The basic difference between CSS Grid Layout and CSS Flexbox Layout is that flexbox was designed for layout in one dimension – either a row or a column.

Grid was designed for two-dimensional layout – rows, and columns at the same time.

COLUMN 3
I only styled the Desktop size, as a little preview. Added Custom CSS to switch areas for tablet sizes.

  • The grid properties are supported in all modern browsers.
  • An HTML element becomes a grid container when its display property is set to grid or inline-grid.
  • All direct children of the grid container automatically become grid items.
  • The spaces between each column/row are called gaps.

LET THE BATTLE BEGIN!

STAR TREK IPSUM

Unidentified vessel travelling at sub warp speed, bearing 235.7. Fluctuations in energy readings from it, Captain. All transporters off. A strange set-up, but I’d say the graviton generator is depolarized.

The dark colourings of the scrapes are the leavings of natural rubber, a type of non-conductive sole used by researchers experimenting with electricity. The molecules must have been partly de-phased by the anyon beam.

VS

STAR WARS IPSUM

Lucas ipsum dolor sit amet c-3po solo bothan qui-gon darth solo darth dantooine dagobah mustafar. Fett solo yoda r2-d2 kit obi-wan hutt amidala kenobi. Jade leia gonk lobot ahsoka darth jade skywalker organa. Utapau mara owen darth darth yavin.

Lando baba wedge darth solo skywalker ben fett. Fisto wookiee bothan antilles antilles luke kenobi. Yavin naboo kenobi jinn calamari antilles. Organa jabba skywalker gamorrean ackbar. Windu skywalker kit skywalker. Dantooine dantooine moff leia dantooine wicket amidala.

Things missing!

This is almost a perfect Gutenberg plugin and a reduced / simplified integration of CSS grid. I really think that this plugin makes Gutenberg 1000times better.

There is so much repetition of Gutenberg blocks out there, while this really addresses something new and nails it :)

There are still things missing, that are critical and would make this even more useful for certain websites:

  1. Allow to name grid areas. Would allow faster manual css modifications.
  2. Allow grid templates per breakpoint. This would make it perfectly usable in a responsive world. This is by far the most important issue!
  3. Some additional styling options would be nice, but nothing major. (Allow to adjust the grid gap …)
  4. Export the inline styles to files, that would leverage caching far better.
  5. Custom CSS integration, which allows to centralize Custom CSS for areas and sections.


Enjoy coding …

Alex

I am a full-stack developer. I love programming,  design and know my way around server architecture as well.  I would never feel complete, with one of these missing. I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest. Apart from that, I am a peace loving guy who tries to have people around him that think the same.  I truly believe in the principle: “If you help someone, someone will help you, when you need it."

Recent Posts

B&B / Hotel Booking Solutions for WordPress | 2024

BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More

2 weeks ago

WordPress Cron + WP-CLI + Ntfy

THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More

2 months ago

2024 is here and now :)

2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More

3 months ago

2023 ends and whats next !

Short look back at 2023 This has been a busy and interesting year. I am… Read More

4 months ago

cubicFUSION Grid Tweaker – Elementor Grid made easy.

Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More

5 months ago

Archaeology Travel Booth – Travel Innovation Summit 2023

Archaeology Travel is an online travel guide for people who enjoy exploring the world’s pasts.… Read More

6 months ago