At Squares Conf.
Responsive WebApplicationswith Container Queries
View Slide
A talk more aboutprocess than code
BeautifulAccountingSoftware
Goal #1Evolve the design
Goal #2Support MultipleDevices
Responsive
Device-specific design anddevelopment
Designers see afeature through allplatforms
Monolithic app withaccessible templates
Ignored Mobile Web
Limited Mobile App
Each horizontal blockis considered in thecontext of the viewport
Each page can moreeasily be art directed
• No orders• One order• Less than one page oforders• Multiple pages oforders• Has Info Notifications• Tab overflow• Has WarningNotifications• Has limited access tofeatures• Has different appsinstalled
And now consider all ofthose things formultiple viewports
A single page in a webapplication can havedozens of variations
A component-basedsite has componentsrespondingly differentlyto multiple contexts
With media queries,you have to know thepossible interplay of allobjects
With containerqueries, you only haveto know the interplaywithin a single object
No spec forcontainer queries
Declare in:CSS,HTML, or JavaScript
https://github.com/ResponsiveImagesCG/cq-demos.element:media( min-width:500px ) {}https://github.com/tysonmatanich/elementQuery.element[min-width~="500px"] {background-color: #eee;}
http://elementqueries.com/@element ".element" and (min-width: 500px) {.element {background: gold;}}
https://github.com/tysonmatanich/elementQuery.element[min-width~="400px"] { }
To parse CSS, eitherneed to be on samedomain or set up CORS
https://github.com/Snugug/eq.jsdata-eq-pts="small: 400, medium: 600,large: 900"
At HTML level, requiresconsistency ofimplementation across app
We chose JavaScript
elements = [{"module": ".flex--2x1","className":"responsiveClass","minWidth": 768, "maxWidth": 1024}]
Going Responsivemeant a consistentfeature set across alldevices
New featuresautomatically havecross-device support
Went responsive inunder a month†
How the heck doyou do that in amonth?
There’s a discernibledelay in execution
It’s not about theproperties, it’s aboutthe purpose.
Tried to use gridclasses foreverything
Had to write extraclasses just to defineresponsive story
Single purposeclasses resulted inless edge cases (andless code!)
Gzip minimizesduplicate propertiesreally well
Tables are difficult
Avoid too much onthe horizontal axis
Goal #1 reframed:Allow anybody to makeproduct-wide designchanges quickly and easily
Problem:Different techstacks
Make the rightthings easy and thewrong things hard
105
Yahoo! still does acustom experienceper device
Shopify is getting ridof Container Queries
… …
.two-columns {display: flex;flex-wrap: wrap;}.col1, .col2 { flex-grow: 1; }.col1 {flex-basis: 66%;min-width: 360px;}.col2 {flex-basis: 33%;}
Button
.media-body {display: flex;flex-wrap: wrap;}
.media-content {flex-grow: 1;flex-basis: 400px;margin-right: 20px;}
.media-actions {align-self: center;margin: 20px 0;}
………
.items {display: grid;grid-template-columns:repeat(auto-fit, minmax(400px, 1fr));}
...
.box {display: flex;flex-wrap: wrap;}
.box-image {flex-grow: 1;flex-shrink: 0;flex-basis: 150px;}.box-image > img {width: 100%;object-fit: cover;}
.box-content {margin: 10px;flex-shrink: 1;flex-grow: 1;flex-basis: 60%;}
Designers shouldthink Responsivebefore they need to.
Container Queriesenable fasterdevelopment
Use techniques toavoid media orcontainer queriesaltogether
http://ricg.io
Thank you. http://snook.ca/ @snookca