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
53
phpitfalls - cologne
davidbadura
0
190
PostCSS Mythbusting
davidbadura
1
230
Other Decks in Technology
See All in Technology
10倍の生産性を実現するAI駆動並列エージェントのすべて
kumaiu
5
1.4k
小さくはじめるSLI/SLO ~育てながら組織に定着させる実践知~ / Starting Small with SLI/SLOs: Building Adoption Through Continuous Growth
nari_ex
7
1.8k
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
690
Claude Code×Terraform IaC テンプレート駆動開発
itouhi
1
510
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
9
750
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
390
MIERUNE JCT 発表資料「宇宙から伊能忠敬ごっこ」
syuchimu
0
210
MCP Appsを作ってみよう
iwamot
PRO
4
560
日本 Fintech 未来予測レポート 2027〜2028年(オリジナル版)
8maki
0
2k
AAIFに入ってみた ~内から見えるコミュニティ動向~
sato4
0
180
あなたの AI ワークスペースに、 専門コーダーを連れてくる - Amazon Quick Desktop 最新情報
kawaji_scratch
1
130
ポケモンの型をTypeScriptの型システムで表現してみた
subroh0508
0
370
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
ラッコキーワード サービス紹介資料
rakko
1
3.6M
Designing for humans not robots
tammielis
254
26k
Crafting Experiences
bethany
1
180
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
Automating Front-end Workflow
addyosmani
1370
210k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
BBQ
matthewcrist
89
10k
Statistics for Hackers
jakevdp
799
230k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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!/>