Trying to keep the DOM DRY, does Roots provide a server-side function for calling content depending on screen size? Applying Bootstrap’s hidden-xs and visible-xs classes are not optimal since both blocks of content will be loaded into the DOM. Using <div class="hidden-xs">…</div>, for example, sets the element to display:none. However, the content is still loaded regardless. And from my understanding, applying visibility:hidden isn’t effective either.
Here’s what I want to happen—
If small screen display this block using Bootstrap’s media object:
We don’t have anything like this built-in to Roots. It would be a project in and of itself, and is certainly beyond the scope of a starter theme.
A PHP solution is a bad idea. It would need javascript/jQuery to get the viewport/screen size anyway, and a server side solution would prevent caching.
You can accomplish your goal with one content block using LESS if you omit the Bootstrap classes from your markup. The only thing you can’t do is change the thumbnail size so you would need to load both and hide one at each breakpoint. Although if you’re loading both you’re probably better off just loading the larger one and scaling its size down at the lower breakpoint.
Thanks for the feedback! I wasn’t sure if it could be accomplished, in general. But, sacrificing caching isn’t up for debate, so I’ll repurpose my styles or use Bootstrap’s visible-* and/or hidden-* classes on 2 different content blocks.
If you keep the Bootstrap classes in your markup then you will end up repeating yourself. LESS will do what you need without the need for repetitive markup.
Thanks again for the terrific feedback. They’re both great suggestions in their own right.
@Foxaii As I’m familiar with Foundation, I was hoping Bootstrap would include something like Foundation’s Interchange.
I’ll have to revisit loading partials via ajax based on breakpoint.
@cfx You’re a step ahead of me. The thought hadn’t crossed my mind. I’m so caught up on utilizing Bootstrap class names because I’m thinking about the person who will we managing this site that I forget to think for myself.
I use Bootstrap Sass. Since Bootstrap’s docs are entirely written in Less, I’ll have to look at the variables and mixins more closely.