Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Responsive Components with ReactJS
Search
David Badura
March 21, 2017
Technology
230
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Responsive Components with ReactJS
https://github.com/DavidBadura/react-responsive-components-slides
David Badura
March 21, 2017
More Decks by David Badura
See All by David Badura
Exploring Projections and Processors in Event Sourcing
davidbadura
0
54
phpitfalls - cologne
davidbadura
0
190
PostCSS Mythbusting
davidbadura
1
230
Other Decks in Technology
See All in Technology
Data Hubグループ 紹介資料
sansan33
PRO
0
3.1k
基調講演:人とAIをつなぐIoTの今と未来 ー 「フィジカル」と「デジタル」が出会うその先へ【SORACOM Discovery 2026】
soracom
PRO
0
370
数値で見る Microsoft MVP 〜Spec Kit と GitHub Copilot Agent で作るデータ可視化ダッシュボード〜
yutakaosada
0
180
A Bag-of-Documents Model for Query Specificity
dtunkelang
0
190
Pavlokで始める電撃駆動開発
sgrsn
0
140
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
組織にどうSREを根付かせるか?〜IVRyの場合〜
abnoumaru
0
210
検索技術知識0のエンジニアが広告検索システムを内製化して運用するまで
lycorptech_jp
PRO
0
180
AI工学特論: MLOps・継続的評価
asei
11
3.1k
toio・myCobotでフィジカルAIっぽいことを行うための検討(とりあえず調査) / フィジカルAI LT(IoTLTによる開催)
you
PRO
0
180
論語・武士道・産業革命から見る かわるもの、かわらないもの
ichimichi
8
2k
大 AI 時代におけるC# の事情 ~ぶっちゃけトークを交えながら~
nenonaninu
1
610
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
170
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
590
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
330
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
520
Darren the Foodie - Storyboard
khoart
PRO
3
3.5k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
430
From π to Pie charts
rasagy
0
240
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
450
Facilitating Awesome Meetings
lara
57
7k
The agentic SEO stack - context over prompts
schlessera
0
860
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Transcript
with ReactJS <RESPONSIVE-COMPONENTS/>
DAVID BADURA Software Developer @ i22 Digitalagentur GmbH Loves ReactJS,
Symfony & Simplicity
WHAT IS REACTJS?
SKIP PLEASE
WHAT WE WANT?
1) ENCAPSULATED COMPONENTS
2) RESPONSIVE LAYOUTS
WE WANT MORE Performance Simplicity Pizza ...
BUT FOCUS ON
WHAT WE HAVE?
MEDIA QUERY .image { height: 200px; } @media (min-width: 500px)
{ .image { width: 200px; float: left; } } @media (min-width: 600px) { .top .image { width: 200px; float: left; } .image { width: 280px; float: none; } }
None
None
None
ENCAPSULATED? not really
WHAT WE REALLY WANT?
ENCAPSULATED RESPONSIVE COMPONENTS
CONTAINER QUERY .image { height: 200px; } .item:media(min-width: 460px) {
.image { width: 200px; float: left; } }
CONTAINER QUERY Container queries allow an author to control styling
based on the size of a containing element rather than the size of the user ’s viewport. - Container Queries - Editor’s Draft, 5 June 2015
NO SUPPORT IN ANY BROWSER
None
MAGIC!
import React from "react"; import {applyContainerQuery} from "react-container-query" ; import
classnames from 'classnames'; const query = { 'width-between-400-and-599' : { minWidth: 400, maxWidth: 599 }, 'width-larger-than-600' : { minWidth: 600, } }; export default applyContainerQuery(class extends React.Component { render() { return ( <div classNames={classnames(this.props.containerQuery)}> // ... </div> ); } }, query);
HOW? Never ask questions you don't want to known the
answers to
import React from "react"; import {applyContainerQuery} from "react-container-query" ; import
Slider from "./Slider"; import Grid from "./Grid"; export default applyContainerQuery(class Content extends React.Component { render() { return ( <div> {this.props.containerQuery.small ? <Slider data={this.props.data} /> : <Grid data={this.props.data} />} </div> ); } }, { 'small': { maxWidth: 599 } });
BUT HOW?
REACT-CONTAINER-QUERY Modular responsive component. With dependency on...
ELEMENT-RESIZE-DETECTOR Super-optimized cross-browser resize listener for elements.
!!! WARNING !!! For information on risks and side-effects please
read the documentaion and ask your doctor or pharmacist.
None
BUT IT WORKS! And it's super fast!
THIS FEATURE IS COMING SOON ... in one or two
years ... maybe ...
RESIZEOBSERVER ResizeObserver allows you to be notified when an element’s
content rectangle has changed its size, and react accordingly. (ResizeObserver is in Chrome 54)
const ro = new ResizeObserver( entries => { for (let
entry of entries) { const cr = entry.contentRect; console.log('Element:', entry.target); console.log(`Element size: ${cr.width}px x ${cr.height}px`); console.log(`Element padding: ${cr.top}px ; ${cr.left}px`); } }); // Observe one or multiple elements ro.observe(someElement);
QUESTIONS?
@DavidBadura
#bonn-devs https://slackinvite.me/to/bonn-devs
REFERENCES http://responsiveimagescg.github.io/container-queries https://tomhodgins.github.io/element-queries-spec/element-queries.html https://developers.google.com/web/updates/2016/10/resizeobserver https://www.sitepoint.com/responsive-web-components https://github.com/wnr/element-resize-detector https://github.com/d6u/react-container-query https://www.i22.de/
<THANKS!/>