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
56
phpitfalls - cologne
davidbadura
0
190
PostCSS Mythbusting
davidbadura
1
230
Other Decks in Technology
See All in Technology
長期運営で肥大化したExcelマスターデータの解消に向けた移行事例
gree_tech
PRO
0
100
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
190
国家プロジェクトを支える「さくらONE」 大規模LLM開発におけるGPU障害を乗り越えるクラスター運用戦略
gpuunite_official
0
220
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
20k
三人寄ればチューリング完全
puhitaku
5
2.4k
AIに持続⼒を与える 判断の⻑期記憶設計
eiei114
1
560
作って理解するCoding Agent 〜フレームワークに頼らないピュア Python での実装〜
takapy
3
880
Sets in Go
ramalho
1
1.2k
:syncing_time:
sksat
2
260
Rust×eBPFでEDRっぽいものをつくる
sunlife3
2
710
AI画像認識を活用したゲーム内決済処理検証の自動化
gree_tech
PRO
0
110
ソフトウェアサプライチェーンの構造的リスクとコンテナ環境の保護
kyohmizu
5
770
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
The Curse of the Amulet
leimatthew05
2
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Skip the Path - Find Your Career Trail
mkilby
1
190
The SEO Collaboration Effect
kristinabergwall1
1
530
Game over? The fight for quality and originality in the time of robots
wayneb77
1
250
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.8k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
950
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!/>