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
Riot.jsでSemanticUIを使ってみる
Search
Nobuki Inoue
June 23, 2018
Programming
600
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Riot.jsでSemanticUIを使ってみる
Nobuki Inoue
June 23, 2018
More Decks by Nobuki Inoue
See All by Nobuki Inoue
Webサービスを作ってみて気づいたこと
black_trooper
0
500
10年使ったDBFluteに思う事
black_trooper
0
540
UI Component 作ってますか?
black_trooper
1
570
Other Decks in Programming
See All in Programming
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
450
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
190
Flow は今どうなっているか
mizdra
PRO
0
530
Foundation Models frameworkで画像分析
ryodeveloper
1
610
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
450
What's New in Android 2026
veronikapj
0
260
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
220
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
690
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
Go 1.27 における memory allocation の高速化
andpad
0
180
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
290
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
790
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
490
The Curse of the Amulet
leimatthew05
2
14k
New Earth Scene 8
popppiees
3
2.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Automating Front-end Workflow
addyosmani
1369
210k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
25k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
200
Statistics for Hackers
jakevdp
799
230k
Transcript
Riot.js で Semantic UI を使ってみる 2018/06/23 【第2回】React (JSフレームワーク他)x ビアバッシュ 初心者勉強会
HELLO! 井上 暢己(いのうえ のぶき) @black_trooper フリーのWebエンジニア フロントエンドとサーバサイドどっちもやって ます。 2
Riot.jsとは ▸ コンポーネントベースのUIライブラリ ▸ 関連するHTMLとJavaScriptをまとめて再 利用可能なコンポーネントを作っていく ▸ 標準のHTMLに近い構文で書ける 3 <app>
<h1>{ opts.title }</h1> <p>{ message }</p> <script> this.message = "hogehoge"; </script> </app>
SemanticUI とは ▸ クラス名に意味を持たせたCSSフレーム ワーク ▸ 名詞、語順、複数形などの構文を用いて いるので直感的 ▸ JavaScriptも含んでいる
4 <div class="ui three buttons"> <button class="ui active button">1</button> <button class="ui button">2</button> <button class="ui button">3</button> </div>
やってみる 5 <div class="ui radio checkbox"> <input type="radio" name="radio" ref="radio1"
value="1"> <label>Radio choice1</label> </div> <div class="ui radio checkbox"> <input type="radio" name="radio" ref="radio2" value="2"> <label>Radio choice2</label> </div> <script> // checkboxの初期化 $('.ui.checkbox').checkbox() // radioの値を取得する const getRadioValue = () => { return this.refs.radio1.checked ? this.refs.radio1.value : (this.refs.radio2.checked ? this.refs.radio2.value : null) } // radioの値をセットする const setRadioValue = value => { if (this.refs.radio1.value == value) { this.refs.radio1.checked = true } else if (this.refs.radio2.value == value) { this.refs.radio2.checked = true } } </script> Radio HTMLに書くことが多いなぁ Riot.js の ref でアクセスすると大変なことに
やってみる 6 <div class="ui selection dropdown"> <input type="hidden" ref="gender"> <i
class="dropdown icon"></i> <div class="default text">Gender</div> <div class="menu"> <div each="{item in dropdownItems}" data-value="{item.value}" class="item" >{item.label}</div> </div> </div> <script> // dropdownの初期化 $('.ui.dropdown').dropdown() this.dropdownItems = [ { value : 1, label : 'Male' }, { value : 2, label : 'Female' } ] // dropdownの値を取得する const getDropdownValue = () => { return this.refs.gender.value } // dropdownの値をセットする const setDropdownValue = value => { this.refs.gender.value = value } </script> Dropdown hidden に値がセットされる hidden の値を書き換えただけなので dropdown の表示はかわらない
思ったよりつらい・・・ Semantic UI 用のコンポーネントも見つからないし困ったな 7
どこにも無いなら作るしかない! 自分専用で作ってもいいけど、どうせなら npm に公開してしまえー 8
Semantic UI Riot を作りまし た https://github.com/black-tr ooper/semantic-ui-riot Place your screenshot
here 9
<su-radio-group ref="radio"> <su-radio value="1">Radio choice1</su-radio> <su-radio value="2">Radio choice2</su-radio> </su-radio-group> <script>
const getRadioValue = () => { return this.refs.radio.value } </script> Radio 10 <div class="ui radio checkbox"> <input type="radio" name="radio" ref="radio1" value="1"> <label>Radio choice1</label> </div> <div class="ui radio checkbox"> <input type="radio" name="radio" ref="radio2" value="2"> <label>Radio choice2</label> </div> <script> // checkboxの初期化 $('.ui.checkbox').checkbox() // radioの値を取得する const getRadioValue = () => { return this.refs.radio1.checked ? this.refs.radio1.value : (this.refs.radio2.checked ? this.refs.radio2.value : null) } </script> Before After 選択されているradioの値が すんなり取得できた!
<su-dropdown items="{ dropdownItems }" ref="gender" /> <script> this.dropdownItems = [
{ value: null, label: 'Gender', default: true }, { value: 1, label: 'Male' }, { value: 2, label: 'Female' } ] alert(this.refs.gender.value ) </script> Dropdown 11 <div class="ui selection dropdown"> <input type="hidden" ref="gender"> <i class="dropdown icon"></i> <div class="default text">Gender</div> <div class="menu"> <div each="{item in dropdownItems}" data-value="{item.value}" class="item" >{item.label}</div> </div> </div> <script> $('.ui.dropdown').dropdown() // dropdownの初期化 this.dropdownItems = [ { value : 1, label : 'Male' }, { value : 2, label : 'Female' } ] alert(this.refs.gender.value) // dropdownの値を取得する </script> Before After HTMLの記述がコンパクトになった!
<su-tabset class="top tabular"> <su-tab title="First">First content</su-tab> <su-tab title="Second">Second content</su-tab> <su-tab
title="Third">Third content</su-tab> </su-tabset> Tab 12 <div class="ui top attached tabular menu"> <a class="active item" data-tab="first">First</a> <a class="item" data-tab="second">Second</a> <a class="item" data-tab="third">Third</a> </div> <div class="ui bottom attached active tab segment" data-tab="first"> First content</div> <div class="ui bottom attached tab segment" data-tab="second"> Second content</div> <div class="ui bottom attached tab segment" data-tab="third"> Third content</div> <script> // tabの初期化 $('.tabular.menu .item').tab() </script> Before After HTMLの記述がコンパクトになった!
他にも いろいろ ▸ Accordion ▸ Checkbox ▸ Datepicker ▸ Dropdown
▸ Modal ▸ Popup ▸ Radio ▸ Tab 今後も少しずつですが追加していきます。 13
まとめ ▸ Riot.js は標準のHTMLに近い感覚で書ける ところが ▸ Semantic UI は直感的なクラス名なので何を しているかが分かりやすい
▸ Semantic UI Riot を作ったので使ってみてく ださい ▸ 自分専用のツールであっても、公開すれば誰 かの役に立つかも! 14 https://github.com/black-trooper/semantic-ui-riot
15 THANKS! ご清聴ありがとうございました。