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
Collocation in Modern Web
Search
Rahul Kadyan
October 28, 2017
Programming
0
35
Collocation in Modern Web
Notes on using collocation in modern web applications.
Rahul Kadyan
October 28, 2017
Tweet
Share
More Decks by Rahul Kadyan
See All by Rahul Kadyan
Inversion of Control in a Vue Application
znck
0
320
New Vue. New Compiler. Let's Unpack
znck
4
2.5k
Head first into composition API
znck
0
120
Future of Vue – JSFoo VueDay 2019
znck
0
480
React to Vue: why and how?
znck
0
38
Choosing Vue.js
znck
0
28
Other Decks in Programming
See All in Programming
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.3k
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
900
CSC509 Lecture 13
javiergs
PRO
0
110
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
CSC509 Lecture 11
javiergs
PRO
0
180
Functional Event Sourcing using Sekiban
tomohisa
0
100
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.3k
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
受け取る人から提供する人になるということ
little_rubyist
0
250
Arm移行タイムアタック
qnighy
0
340
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Designing Experiences People Love
moore
138
23k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
We Have a Design System, Now What?
morganepeng
50
7.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Unsuck your backbone
ammeep
668
57k
Transcript
Collocation in Modern Web
DO WE WRITE PROGRAMS
<!doctype html> <html> <head> <style> .title { color: red; }
</style> </head> <body> <h1 class="title"> </h1> <script> document.querySelector('.title') .innerHTML = 'Collocation' </script> </body> </html> index.html
+ src + components - header.js - header.css - nav.js
- nav.css - app.js - app.css
Modern Web Apps
C o l l o c a t i o
n & R e a c t
import React, { Component } from 'react' export default class
Header extends Component { render () { return ( <header className='my-header'> {this.children} </header> ) } } header.jsx
.my-header { margin: 16px; font-size: 1.5rem; color: black; } header.css
import React, { Component } from 'react' import StyleSheet from
'some-css-in-js' const styles = StyleSheet.create({ header: { margin: '16px', fontSize: '16px', color: 'black' } }) export default class Header extends Component { render () { return ( <header className={styles.header}> {this.children} </header> ) } } header.jsx
header.jsx import React, { Component } from 'react' import style
from 'some-css-in-js' const myHeader = style` margin: 16px; font-size: 1.5rem; color: black; ` export default class Header extends Component { render () { return ( <header className={myHeader}> {this.children} </header> ) } }
C o l l o c a t i o
n & W e b C o m p o n e n t s
header.html <template id="template"> <style> .my-header { margin: 16px; font-size: 1.5rem;
color: black; } </style> <header class="my-header"> <slot> </slot> </header> </template> <script> class Header extends HTMLElement { connectedCallback () { const doc = document.currentScript.ownerDocument const template = doc.querySelector('#template') this.attachShadow({ mode: 'open' }) this.shadowRoot.appendChild( doc.importNode(template.content, true)) } } window.customElements.define('my-header', Header) </script>
C o l l o c a t i o
n & V u e
<template> <header class="my-header"> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <style> .my-header { margin: 16px; font-size: 1.5rem; color: black; } </style> header.vue
p u s h i n g e v e
n f u r t h e r
<template> <header class="my-header"> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <style> .my-header { margin: 16px; font-size: 1.5rem; color: black; } </style> header.vue
<template> <header class="my-header"> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <style scoped> .my-header { margin: 16px; font-size: 1.5rem; color: black; } </style> header.vue
header.vue <template> <header :class="$style['my-header']"> <slot /> </header> </template> <script> export
default { name: 'MyHeader' } </script> <style module> .my-header { margin: 16px; font-size: 1.5rem; color: black; } </style>
header.vue <template> <header> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <docs> # MyHeader It renders a custom header element. ... </docs>
header.vue <template> <header> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <test> import { mount } from 'vue-test-utils' test(`it renders children`, t => { const w = mount(Component, { slots: { default: '<h1>Hello World </h1>' } }) t.true(w.contains('h1')) }) </test>
header.vue <template> <header> <slot /> </header> </template> <script> export default
{ name: 'MyHeader' } </script> <story> <MyComponent /> </story> <story name="With content"> <MyComponent> <h1>DevFest 17 </h1> </MyComponent> </story>
Collocation — Review! Improved Readability Better CSS Easy Distribution Encapsulation
Single Source Static Analysis Compile-time Optimisations Style Scoping And many more…
@znck0 Twitter znck Github znck.me Website vue-bangalore Meetup
None