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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Rahul Kadyan
October 28, 2017
Programming
0
89
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
380
New Vue. New Compiler. Let's Unpack
znck
4
2.6k
Head first into composition API
znck
0
190
Future of Vue – JSFoo VueDay 2019
znck
0
550
React to Vue: why and how?
znck
0
87
Choosing Vue.js
znck
0
75
Other Decks in Programming
See All in Programming
ThorVG Viewer In VS Code
nors
0
760
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1.1k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
690
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
180
CSC307 Lecture 09
javiergs
PRO
1
830
今から始めるClaude Code超入門
448jp
7
8.5k
2026年 エンジニアリング自己学習法
yumechi
0
130
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
Oxlintはいいぞ
yug1224
5
1.3k
AI時代の認知負荷との向き合い方
optfit
0
150
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
55
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Darren the Foodie - Storyboard
khoart
PRO
2
2.3k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Chasing Engaging Ingredients in Design
codingconduct
0
110
Paper Plane
katiecoart
PRO
0
46k
Leo the Paperboy
mayatellez
4
1.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
430
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