Upgrade to Pro — share decks privately, control downloads, hide ads and more …

「defineCustomElement」を活用した サービス共通のUIコンポーネントライブラリ

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for piyoppi piyoppi
November 21, 2023

「defineCustomElement」を活用した サービス共通のUIコンポーネントライブラリ

Avatar for piyoppi

piyoppi

November 21, 2023
Tweet

Other Decks in Programming

Transcript

  1. 「カラーミーショップ」とVue.js 5 ショップ管理画⾯ • PHP + jQuery のMPA • ショップデザイン

    / 商品管理 / 発送 など... • 2021年〜からVue.js (Custom Element)を利⽤
  2. 「カラーミーショップ」とVue.js 6 ショップ管理画⾯とVue.js • 2021〜 Vue2系 + Vue CLI Web

    Components Build ◦ https://tech.pepabo.com/2021/03/23/admin-ui-components/ • 2022〜 Vue3系 + defineCustomElement ◦ https://tech.pepabo.com/2022/10/31/colorme-vue3-migration/ • 2023〜 ペパボ共通デザインシステム「Inhouse」導⼊ ◦ https://note.com/colorme_design/n/n6e3499aa25d3
  3. Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発 8 ce-proxy ui-components .ts .css vue-application .js .ce.js

    web-application <script src=”ce-proxy.js”> <c-button> ボタン </c-button> defineCustomElement()
  4. 9 custom-elements-proxy ui-components .ts .css vue-application .js .ce.js web-application <script

    src=”ce-proxy.js”> <colorme-button> ボタン </colorme-button> defineCustomElement() • SFC(.vue)をそれぞれビルド • SFC毎に .ts & .css ファイルを公開 Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発 c-button .vue c-radio .vue c-button .vue.ts c-button .css c-radio .vue.ts c-radio .css … …
  5. ce-proxy vue-application .js .ce.js web-application <script src=”ce-proxy.js”> <colorme-button> ボタン </colorme-button>

    defineCustomElement() 10 • ui-componentsが公開するSFCを利⽤ ◦ スタイルの読み込みはViteプラグインで⾃動化している Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発 <template> <div> <c-button>ボタン</c-button> </div> </template> <script setup lang=”ts”> import CButton from “ui-components/c-button.vue” import “ui-components/c-button.css” </script>
  6. ce-proxy vue-application .js .ce.js web-application <script src=”ce-proxy.js”> <colorme-button> ボタン </colorme-button>

    defineCustomElement() 11 • defineCustomElement() を通して Custom Element化 • 属性値を Vue props にそのまま渡 せない場合の変換層としても機能 Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発 ce-proxy ui-components JSON HTML </> component Object component
  7. ce-proxy vue-application .js .ce.js web-application <script src=”ce-proxy.js”> <colorme-button> ボタン </colorme-button>

    defineCustomElement() 12 • コンポーネント毎にJavaScriptを出⼒ • 必要なコンポーネントを検索して取得 するスクリプトを同梱 ◦ よく使うコンポーネントはスクリプトに同梱してネットワー クの往復による遅延を低減 Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発 <script src=”ce-proxy.js”> <B>foo</B> <C>bar</C> ce-proxy.js C A.js A B.js B
  8. 13 • ce-proxyをロード • ui-components が公開するSFCを ce-proxyを介して利⽤できる web-application <script src=”ce-proxy.js”>

    <c-button> ボタン </c-button> Custom Element変換層の導⼊によるUIコンポーネントライブラリの開発