Plugins are able to extend Craft and embrace the existing UI nicely. While I'm comfortable extending it in many ways, I don't feel like I could clearly explain to somebody else how the grid system works on the back end and have recently seen a few CP UIs rendered on larger screens (2400px+) that suggest that I may not fully understand how it behaves between devices.
After you extend the CP layout:
{% extends "_layouts/cp" %}
You can build a grid using grid
, item
, and pane
classes and various attributes. Here is an example with likely too many attributes just to put several of them out there into the discussion:
<div class="grid first" data-max-cols="3">
<div class="item" data-position="left" data-min-colspan="2" data-max-colspan="3">
<div id="fields" class="pane">
...
</div>
</div>
<div class="item" data-position="right" data-colspan="1">
<div class="pane meta">
...
</div>
</div>
</div>
Here are a few of the questions I wonder about while working with the grid:
- How many columns does the grid support?
- Are there any considerations to keep in mind as our plugin's UI adjusts to mobile layouts or big screens with high resolutions?
- How do
data-position="left"
anddata-position="right"
work? When do we need to use them? - How do the
data-colspan
attributes work? Are there defaults in place fordata-colspan
,data-min-colspan
,data-max-colspan
? - Are there any other features of the grid I'm overlooking or leaving out?