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
Svelteで作るページビルダー
Search
Childhooooo
December 07, 2019
Programming
0
240
Svelteで作るページビルダー
Childhooooo
December 07, 2019
Tweet
Share
More Decks by Childhooooo
See All by Childhooooo
JavaScriptを使わない(Phoenix LiveViewの紹介)
childhooooo
0
840
DDD by Functional programming with TypeScript
childhooooo
2
2k
Other Decks in Programming
See All in Programming
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
310
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
630
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
480
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
510
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
590
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
430
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.1k
イベント駆動で成長して委員会
happymana
1
270
Outline View in SwiftUI
1024jp
1
290
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.1k
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.5k
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Building an army of robots
kneath
302
42k
Embracing the Ebb and Flow
colly
84
4.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
390
Happy Clients
brianwarren
97
6.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
2k
Docker and Python
trallard
40
3.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
42
2.2k
Transcript
SvelteͰ࡞ΔϖʔδϏϧμʔ Gunma.web #37
େా෦ߊ ϩέοτ -> Web
ಘҙͳ͜ͱ ϋΠϘʔϧΛ࡞Δ͜ͱ
ۤखͳ͜ͱ λΠϐϯά
1. ίʔυ͕গͳͦ͏ʹݟ͑ͨSvelteͰ 2. ϖʔδϏϧμʔΛ࡞Δ
1. Svelteʹ͍ͭͯ
Svelteͱ ɾReactVue.jsͬΆ͍ϑϩϯτΤϯυϑϨʔϜϫʔΫ ɾHTMLʗJavaScriptʗCSSΛੜ͢ΔίϯύΠϥ ɾԾDOMΛ͍͡ΔΑ͏ͳϥϯλΠϜϥΠϒϥϦͰͳ͍ ɾϕϯνϚʔΫͰReactͷ35ഒɺVue.jsͷ50ഒ͍Β͍͠
Vue.jsͱͷൺֱ ʢ୯ҰϑΝΠϧίϯϙʔωϯτʣ
<template> <main class=”index”> <h1>ݟग़͠</h1> <p>ຊจ</p> <Block :content=”content”/> </main> </template> <script>
import Block from ‘...’ export default { components: { Block }, data() { return { content: ‘’ }... Vue.js
<template> <main class=”index”> <h1>ݟग़͠</h1> <p>ຊจ</p> <Block :content=”content”/> </main> </template> <script>
import Block from ‘...’ export default { components: { Block }, data() { return { content: ‘’ }... ɾςϯϓϨʔτλάͷԼʹ1ͭͷࢠཁૉ ɾexport default { … } ɾϓϩύςΟΛdataؔͰఆٛ ɾ༻ίϯϙʔωϯτΛͯ͢એݴ etc... Vue.js
<h1>ݟग़͠</h1> <p>ຊจ</p> <Block {content}/> <script> import Block from ‘...’; export
let content; </script> Svelte
<h1>ݟग़͠</h1> <p>ຊจ</p> <Block {content}/> <script> import Block from ‘...’; export
let content; </script> Svelte ɾ࠷ݶͷHTMLλά ɾίϯϙʔωϯτimport͢Δ͚ͩ ɾϓϩύςΟมͱͯ͠એݴ͢Δ͚ͩ
{#if show} <Preview></Preview> {/if} <script> import Preview from '...'; export
let componentId; let show = true; $: ((id) => { show = false; setTimeout(() => show = true, 0); })(componentId); </script> Svelte
{#if show} <Preview></Preview> {/if} <script> import Preview from '///'; export
let componentId; let show = true; $: ((id) => { show = false; setTimeout(() => show = true, 0); })(componentId); </script> Svelte ɾҙਤͨ͠λΠϛϯάͰॳظԽͰ͖ͣɺ ɹҰ෦ແཧΓ࠶ඳը͢Δඞཁ͕͋ͬͨ ɾDOMΛ·Δ͝ͱॻ͖͑Δॲཧ͕࿈ଓ ɹͨ͠ͷಈ͖͕Πέͯͳ͍
None
Vue.jsʢͨͿΜReactʣ ϥϯλΠϜϥΠϒϥϦͳͷͰϞδϡʔϧΛ͔ͬ͠Γఆٛ ͠ͳ͚ΕͳΒͣهड़͕໘ɻ Svelte ੜDOMΛ͍͡Δͷ͕Πέͯͳ͍ɻ
2. ϖʔδϏϧμʔ͍ͭͯ
࠷ۙ͜Μͳͷ͋Γ·͕͢
ߴػೳ͗͢Δʢࢲʹʣ
ॊೈੑѱʢࢲʹʣ
ॊೈੑѱ ɾόϥόϥʹͳΓ͕ͪͳ༨ന ɾ༧ଌ͠ʹ͍͘Ϩεϙϯγϒ࣌ͷಈ͖ ɾѲ͖͠Εͳ͍ઃఆ߲ ɾ݁ہඞཁʹͳΔHTML&CSSͷࣝ ɾඍௐʹ͔͔Δ࣌ؒ
ࣗ༝ͷϖʔδϏϧμʔΛ࡞ͬͯΈͨ
ηΫγϣϯΛॎʹ SECTION SECTION
ίϯϙʔωϯτΛԣʹ COMPONENT COMPONENT COMPONENT SECTION
ηΫγϣϯΛॎʹ
ίϯϙʔωϯτΛԣʹ
σϞ
Eruda͍͢͝
<div class={{class}} id={{id}}> <p>{{ຊจ:content:text=αϯϓϧ}}</p> </div> <style> .{{class}} { position: relative;
} .{{id}} p { font-size: {{αΠζ:size:rem=1.2}}rem; } </style>