How can I define grid template area for portrait mode? [Help Required]
See original GitHub issueI want to define a template-area for a component for portrait mode. Creating an issue as I dont know where to ask for help.
I can’t understand how to define the template area for this kind of breakpoint from the documentation.
I tried both areasPortrait
and areasOrientationPortrait
Is it possible this way of do I have to manage it programmatically?
eg:
const areas = `
media text
`;
const areasPortrait=`
media
text
`;
<Composition areas={areas} areasPortrait={areasPortrait} areasOrientationPortrait={areasPortrait}>
{({ Media, Text }) => (
<>
<Media />
<Text />
</>
)}
<Composition/>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Grid template areas - CSS: Cascading Style Sheets | MDN
We can also define an area by giving it a name and then specify the location of that area in the value of...
Read more >How To Use a CSS Grid Template Area & Why It Can Save ...
With a CSS grid template area, you set the width in a single command and then the placements of the grid cells —...
Read more >Take Portrait mode photos with your iPhone camera
Open Camera, then select Portrait mode. Follow the tips onscreen to frame your subject in the yellow portrait box. Drag the Portrait Lighting...
Read more >CSS Grid Layout Module Level 2 - W3C
This CSS module defines a two-dimensional grid-based layout system, optimized for user interface design. In the grid layout model, the children ...
Read more >How to build CSS grid layouts in 2021 — Web design tutorial
CSS grid is quickly becoming a web design standard, and has been adopted by Apple for grid -based layouts and galleries, by Slack...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having though about this problem, I’m yet not sure what would be the expected behavior.
To illustrate, let’s replace
areas
withareasLg
.In isolation that means “render the
left
area only on large devices and up”. So it won’t get rendered on xs, sm, and md screen sizes. Now let’s addareasPortrait
to the mix:areasPortrait
imply thatleft
andright
areas will get rendered only on portrait orientation of the device. Which, in most cases, would be a smaller screen size thanlg
breakpoint describes. This makes two responsive props declaring contradictory behavior toward the same area.Current solution
@noushad-pp since this behavior needs to be carefully designed, and I don’t wish to block your development, I can suggest another way to tackle portrait orientation. Instead of declaring the
areasPortrait
prop, use theuseResponsiveValue
hook:That means to leave out the portrait from the areas declaration and treat it as an extra scenario during rendering. I understand this is not ideal, as you may not be able to target the conditional widget with CSS Grid properties in its fullest extent.
Also, please, feel free to voice what your expectations would be, so we could shape the behavior together. Thanks!
Hi, @noushad-pp. That’s the right place to ask.
By default, responsive props in Atomic Layout use Bootstrap 4 breakpoints (xs, sm, md, lg, xl). As you may already know, those are described using media queries targeting a device’s width. This means that by default there is no behavior to target a device’s orientation.
In order to assign responsive props based on device’s orientation, you would have to create such breakpoint manually using
Layout.configure()
and itsbreakpoints
property:By doing so, you create your custom responsive props suffix called
portrait
. CallingLayout.configure()
makes all Atomic Layout’s components aware of your suffix automatically.Whenever you suffix a prop name with that suffix a prop value will be applied only when the media query is met (in our case when
orientation
isportrait
):I hope this explanation helps. Let me know if you still have any questions.
Please update to
atomic-layout@0.9.9
to be able to importdefaultOptions
from the package. This would dramatically simplify the declaration of custom breakpoints. Thanks.