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

管理画面向けUIコンポーネントの設計 - Web componentsでフレームワーク非依存を目指す

管理画面向けUIコンポーネントの設計 - Web componentsでフレームワーク非依存を目指す

「UIT × Bonfire Front-end Meetup #1」での発表資料です。
https://uit.connpass.com/event/300284/

More Decks by LINEヤフーTech (LY Corporation Tech)

Other Decks in Technology

Transcript

  1. ؅ཧը໘ͷ։ൃͷಛ௃ w ͦΕͳΓʹେن໛ w  ߦ7VFϑΝΠϧ ݸ+4ϑΝΠϧ ݸ w ػೳ͕ଟذʹΘͨΔ͕ɺ֤ػೳͷར༻ස౓͸·ͪ·ͪ

    w ಛఆͷϢʔβʔʹ͚ͩඞཁͳ؅ཧը໘͕ͨ͘͞Μ͋ΔΠϝʔδ ࠷খͷ࿑ྗͰɺͦͷը໘ͷॏཁ౓ʹ߹Θͤͨ ΫΦϦςΟͰ6*Λ࣮૷͢Δ͜ͱΛॏࢹ
  2. ҠߦͷऔΓ૊Έ w ݕ౼ͷ݁Ռ5BJMXJOEΛ࠾༻͠ɺঃʑʹҠߦ͍ͯ͘͜͠ͱʹ w #PPUTUSBQͷDMBTT໊͕5BJMXJOEͷ΋ͷͱॏෳ😩 w ΍Ήͳ͘5BJMXJOEͷQSF fi YΛ༗ޮԽ AMEAΛ෇༩

    <div class="ld-flex ld-items-start ld-mx-200 ld-my-600"> <div class="ld-w-[130px] ld-h-[130px] ld-bg-gray-200"> <img class="ld-max-w-full ld-max-h-full" /> ...
  3. ;BH

  4. -JU޲͚ͷϔϧύʔΛ༻ҙ͢Δ͜ͱͰ໰୊ͳ͘ಈ࡞ import * as checkbox from '@zag-js/checkbox'; import { useController

    } from 'haunted'; import { html } from 'lit'; import { MachineController, applyProps, createElement } from '~util'; export const Checkbox = createElement((element) => { const machine = useController( (host) => new MachineController(host, checkbox) ); const api = machine.connect(); return html` <label ${applyProps(api.rootProps)}> <div class="checkbox" ${applyProps(api.controlProps)}></div> <input ${applyProps(api.hiddenInputProps)} /> <span ${applyProps(api.labelProps)}> <slot></slot> </span> </label> `; });
  5. ιʔείʔυ͔ΒQSPQTTMPUTFNJUTͷܕΛநग़ import { defineComponentEmits, defineComponentProps, defineComponentSlots, } from '~util'; export

    const tagName = 'my-checkbox'; export const props = defineComponentProps<{ checked: boolean; }>({ checked: false, }); export const slots = defineComponentSlots<{ default: () => void; }>(); export const emit = defineComponentEmits<{ changed: boolean | 'indeterminate'; }>(); { "schemaVersion": "1.0.0", "modules": [ { "kind": "javascript-module", "declarations": [ { "kind": "class", "customElement": true, "tagName": "my-checkbox", "attributes": [ { "name": "checked", "fieldName": "checked", "type": { "text": "boolean" }, "default": "false" } ], "slots": [], "events": [ { "name": "changed", "type": { "text": "CustomEvent<boolean | \"indeterminate\">" }
  6. ໰୊ͳ͘3FBDU7VF͔Βར༻Ͱ͖ΔΑ͏ʹʂ <MyCheckbox :checked="checked" @changed="..."> ... </MyCheckbox> <MyCheckbox checked={checked} onChanged={...}> ...

    </MyCheckbox> { "schemaVersion": "1.0.0", "modules": [ { "kind": "javascript-module", "declarations": [ { "kind": "class", "customElement": true, "tagName": "my-checkbox", "attributes": [ { "name": "checked", "fieldName": "checked", "type": { "text": "boolean" }, "default": "false" } ], "slots": [], "events": [ { "name": "changed", "type": { "text": "CustomEvent<boolean | \"indeterminate\">" } 7VF 3FBDU