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

Hotwire的な設計を追求して「Web紙芝居」に行き着いた話

Yasuko Ohba
October 28, 2023

 Hotwire的な設計を追求して「Web紙芝居」に行き着いた話

Kaigi on Rails 2023での「Hotwire的な設計を追求して「Web紙芝居」に行き着いた話」のトーク資料です。

Yasuko Ohba

October 28, 2023
Tweet

More Decks by Yasuko Ohba

Other Decks in Technology

Transcript

  1. ը໘ঢ়ଶΛ"ˠ#ʹม͑Δํ๏Λ બͿͨΊͷϑϩʔνϟʔτ Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕

    ཁૉʹ·ͱ·Δʁ 5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ ෦඼త ը໘త
  2. ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ

    ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ $MJDL ΫϦοΫͨ͠Β ৄࡉΤϦΞ͕දࣔ͞ΕΔ ˞༧Ίશ෦࢓ࠐΉબ୒ࢶ΋ߟ͑ΒΕ·͕͢ɺຊτʔΫͷओࢫʹ͸ؔ܎ͳ͍ͨΊ৮Ε·ͤ Μɻৄࡉදࣔͷίετ͕૬౰ߴ͍ͱ͔ɺҰཡͷදࣔྔ͕ଟ͍ͳͲͷཧ༝ͰͦΕΛબ୒͠ͳ ͍ɺৄࡉ৘ใΛ݅ͱΔͨΊͷΞΫγϣϯ͸ผʹ༻ҙ͢Δͱ͍͏લఏͰฉ͍͍ͯͩ͘͞ɻ
  3. ͍·ίί Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ

    5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ
  4. ख๏ܾఆʂ Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ

    5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ
  5. ෦඼తΞϓϩʔνͷઃܭྫ JOEFY ΞΫγϣϯ ৄࡉදࣔͷ͜ͱ͚ͩΛ΍Δʂ ੹຿͕੾Γ෼͚ΒΕ͍ͯͯඒ͍͠ʂ Ұཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐

    ɹɾɾɾɾ ΞΠςϜͷ ৄࡉΤϦΞ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ $MJDL TIPX ΞΫγϣϯ JUFNT JUFNT QBHF
  6. ίʔυྫ def index @items = Item.all end def show @item

    = Item.find(params[:id]) end .row .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame turbo-frame#itemDetailFrame …ৄࡉදࣔ… JUFNT@DPOUSPMMFSSC JOEFYIUNMTMJN TIPXIUNMTMJN ී௨ͷ$36%ͷܗͰը໘ʹຒΊࠐΊͯΩϨΠ
  7. ͍·ίί Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ

    5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ
  8. ख๏ܾఆʂ Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ

    5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ
  9. 8FCࢴࣳډͷઃܭྫ JOEFY ΞΫγϣϯ ࢴࣳډͷʮ࣍ͷຕʯΛఏڙʂ ੹຿͕෼͔Ε͓ͯΒͣɺటष͍ Ұཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐

    ɹɾɾɾɾ ΞΠςϜͷ ৄࡉΤϦΞ͕ ։͍͍ͯΔҰཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ TIPX ΞΫγϣϯ JUFNT QBHF $MJDL JUFNT QBHF
  10. .row .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame - if @item …ৄࡉදࣔ… .row

    .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame def index prepare_items end def show @item = Item.find(params[:id]) prepare_items render action: :index end private def prepare_items @items = Item.all end ίʔυྫ JUFNT@DPOUSPMMFSSC JOEFYIUNMTMJN TIPXIUNMTMJN ৑௕͕͋͞Δ
  11. ෦඼తͳΞϓϩʔνͷઃܭ JOEFY ΞΫγϣϯ Ұཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷ

    ৄࡉΤϦΞ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ $MJDL TIPX ΞΫγϣϯ JUFNT JUFNT QBHF ༻ҙͯ͋͠ΔৄࡉΤϦΞΛ UVSCPGSBNFཁૉʹͯ͠ ಺༰Λྲྀ͠ࠐ΋͏ʂ
  12. ࠶ܝɿίʔυྫ def index @items = Item.all end def show @item

    = Item.find(params[:id]) end .row .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame turbo-frame#itemDetailFrame …ৄࡉදࣔ… JUFNT@DPOUSPMMFSSC JOEFYIUNMTMJN TIPXIUNMTMJN ී௨ͷ$36%ͷܗͰը໘ʹຒΊࠐΊͯΩϨΠ
  13. ཁ๬ᶃৄࡉΛ։͍͍ͯΔΞΠςϜΛҰཡ ಺Ͱ෼͔Γ΍͍ͨ͘͢͠ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ

    ɾɾɾɾɾɾ ϦϯΫ͕ΫϦοΫ͞ΕͨΒ +4ͰσβΠϯม͑Α͏ ৄࡉดͨ͡ͱ͖΋ +4ͰσβΠϯม͑Α͏ ·͋ɺ4UJNVMVTॻ͔͘
  14. ෆࣗ༝͞Λײ͍ͯ͘͡ 5VSCP'SBNFTͷ৔߹ ܾΊͨΤϦΞͷ֎΋ߋ৽͠Α͏ͱ͢Δͱ 
 ్୺ʹ໘౗ʹͳΔ τϨʔυΦϑͷ͋Δબ୒Λ͠ͳ͚Ε͹ͳΒͳ͍ ಘΔ΋ͷ ࣦ͏΋ͷ ࢓༷Λଥڠ ʢৄࡉΤϦΞʹܯࠂදࣔʣ

    ੹຿ͷ෼཭ ʢগ͠ଥڠʣ ࢓༷ͷ࣮ݱ 5VSCP4USFBNTʹ มߋ ࢓༷ͷ࣮ݱ ੹຿ͷ෼཭ +4Ͱผ్ܯࠂΛग़͢ ੹຿ͷ෼཭ ։ൃ଎౓ɾอकੑ
  15. 8FCࢴࣳډͷઃܭ JOEFY ΞΫγϣϯ Ұཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷ

    ৄࡉΤϦΞ͕ ։͍͍ͯΔҰཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ TIPX ΞΫγϣϯ JUFNT QBHF $MJDL JUFNT QBHF ৄࡉΤϦΞΛUVSCPGSBNFʹ͢Δ 4IPXΞΫγϣϯҰཡ ৄࡉ
  16. .row .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame - if @item …ৄࡉදࣔ… .row

    .col-6 …Ұཡදࣔ… .col-6 turbo-frame#itemDetailFrame def index prepare_items end def show @item = Item.find(params[:id]) prepare_items render action: :index end private def prepare_items @items = Item.all end ࠶ܝɿίʔυྫ JUFNT@DPOUSPMMFSSC JOEFYIUNMTMJN TIPXIUNMTMJN ৑௕͕͋͞Δ
  17. ख๏Λ5VSCP%SJWFʹมߋ Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ

    5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ
  18. +4͕૿͑ͳ͍ .row .col-6 …ϔομ… - @items.each do |item| .row.m-1 class="#{item

    == @item ? "bg-warning" : ‘'}" ..1ߦͷදࣔ.. .col-6 - if @item …ৄࡉදࣔ… TIPXIUNMTMJN ͲͷৄࡉΛද͍͔ࣔͨ͠ ΞΫγϣϯݺͼग़࣌͠఺ͰΘ͔ΔͷͰ ͋Β͔͡ΊσβΠϯΛࢦఆ UVSCPGSBNFফͨ͠
  19. ίϯτϩʔϥͷॲཧ΋ ը໘ग़ྗ΋ڞ௨ԽͰ͖Δ JOEFY ΞΫγϣϯ Ұཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ

    ΞΠςϜͷ ৄࡉϞʔμϧ͕ ։͍͍ͯΔҰཡը໘ ɹΞΠςϜ̍ ɹΞΠςϜ̎ ɹΞΠςϜ̏ ɹΞΠςϜ̐ ɹɾɾɾɾ ΞΠςϜͷৄࡉ ɾɾɾɾɾɾ ɾɾɾɾɾɾ ɾɾɾɾɾɾ TIPX ΞΫγϣϯ JUFNT QBHF JUFNT QBHF ҰཡΛग़͢४ උ NFUIPE Ұཡ෦෼ QBSUJBM
  20. ෦඼తΞϓϩʔν ʢಛʹ൚༻ίϯϙʔωϯτࢦ޲ʣ 8FCࢴࣳډ ΞΫγϣϯΛ ԿͰ෼͚Δͷ͔ ओͳ੹຿ ը໘ͷঢ়ଶ ඒ͠͞ ੹຿ͷ෼͔Εํ ը໘ঢ়ଶʢ63-ʣͷ

    ෼͔Εํ ՝୊ ը໘ʢ+4ʣͰͷ ੍ޚ͕େม ॲཧͷॏෳ ՝୊΁ͷରࡦ 41"ʹ͢Δ ɾТɾA  ίϯτϩʔϥ૚ͱ QBSUJBMςϯϓϨʔτΛ ߏ଄Խɾڞ௨Խ ॲཧ଎౓ͷ޻෉ ΧϦΧϦʹ%3:ʹͰ͖Δʂ3VCZͳΒʂ ύʔϚωϯτϦϯΫͱ޷૬ੑ
  21. ը໘ঢ়ଶΛ"ˠ#ʹม͑Δํ๏Λ બͿͨΊͷϑϩʔνϟʔτ Ͱ͖Δ ओʹ(&5 ࢖͏ ·ͱ·Δ ·ͱ·Βͳ͍ #͸୯ಠͰ ΞΫηεͰ͖Δʁ มߋՕॴ͕

    ཁૉʹ·ͱ·Δʁ 5VSCP'SBNFT 5VSCP%SJWF 8FC 4PDLFU 5VSCP4USFBNT ࢖Θͳ͍ Ͱ͖ͳ͍ 1045 (&5PS1045 มߋՕॴ͕ ཁૉʹ·ͱ·Δʁ ·ͱ·Βͳ͍ ·ͱ·Δ ը໘త