npm install container-queryContainerQuery
==============
A common problem in responsive design is the layout being depedent on the width
of the media (i.e. a media query) as opposed to the width of the host container
(i.e. a container query).
For example, let's say you have a book list, and you want it to be one column in
a small width, then two, then four columns as the width of the content area grows.
Great, if you control the entire screen. But what if the list is put into the sidebar.
Now, even though the screen maybe large, the width for the book list is small.
So we need a tool to be able to define breakpoints relative to the container
and not to the screen.
Introducing, ContainerQuery, where you can define breakpoint names on a container
and then apply style, props or className depending on the current width of the
container. For example:
``jsx`
className-medium="book col-6"
className-large="book col-3"
src={require('../images/Dune.jpg')}
title="Dune" />
className-medium="book col-6"
className-large="book col-3"
src={require('../images/ChildrenOfDune.jpg')}
title="Children of Dune" />
...
Will check to see how much space it's given, turn that into a breakpoint name (e.g. small,medium or large) and then set the className of the children of the component
based on that value.
You can also set styles:
`jsx`
style-medium={{width:'50%'}}
style-large={{width:'25%'}}
src={require('../images/Dune.jpg')}
title="Dune" />
style-medium={{width:'50%'}}
style-large={{width:'25%'}}
src={require('../images/ChildrenOfDune.jpg')}
title="Children of Dune" />
In this case we are setting the width as a style based on the current breakpointbreakpoints
as defined by the object.
You can also set properties:
`jsx`
props-medium={{size:'medium'}}
props-large={{size:'large'}}
src={require('../images/Dune.jpg')}
title="Dune" />
If your component, in this case, knows how to interpret size in some meaningful way.
And, of course, you can use any combination of these.
You are also free to name the breakpoints however you choose.
For something even easier you can use a columns-based helper class like so:
`jsx`
at-small={1} at-medium={2} at-large={4}>
title="Dune" />
title="Children of Dune" />
Which sets width in the style of all of the children using the number of columnsat-{breakpoint}
defined in the props in the ContainerQuery.Columns` component.
Please see DEVELOPMENT
Please see CONTRIBUTING