From 5e6c2c3c3fb8328a7eb2903b905506852fcf737d Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Mon, 1 Jul 2024 13:48:20 -0700 Subject: [PATCH] Put the new item preview in a Turbo frame Nice, gotta say, this is a pretty neat way of making things feel more app-y! There's some missing pieces here about like, loading state etc, but the vibes are pretty good, and the implementation was dead-easy! --- app/views/items/show.html.haml | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 014a9940..3fce6e3c 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -13,26 +13,27 @@ how we handle zones. Until then, these items will be very buggy, sorry! -%outfit-viewer - %outfit-pet-appearance - = outfit_viewer_layers @pet_layers - %outfit-item-appearance - = outfit_viewer_layers @item_layers += turbo_frame_tag "item-preview" do + %outfit-viewer + %outfit-pet-appearance + = outfit_viewer_layers @pet_layers + %outfit-item-appearance + = outfit_viewer_layers @item_layers -= form_for item_path(@item), method: :get, class: "species-color-picker", - data: {"is-valid": @preview_error.nil?} do |f| - - if @preview_error == :pet_type_does_not_exist - %span.error-icon{title: "We haven't seen this kind of pet before."} ⚠️ - - elsif @preview_error == :no_item_data - %span.error-icon{title: "We haven't seen this item on this pet before."} ⚠️ + = form_for item_path(@item), method: :get, class: "species-color-picker", + data: {"is-valid": @preview_error.nil?} do |f| + - if @preview_error == :pet_type_does_not_exist + %span.error-icon{title: "We haven't seen this kind of pet before."} ⚠️ + - elsif @preview_error == :no_item_data + %span.error-icon{title: "We haven't seen this item on this pet before."} ⚠️ - = select_tag "preview[color_id]", - options_from_collection_for_select(Color.funny.alphabetical, - "id", "human_name", @selected_preview_pet_type.color_id) - = select_tag "preview[species_id]", - options_from_collection_for_select(Species.alphabetical, - "id", "human_name", @selected_preview_pet_type.species_id) - = submit_tag "Go", name: nil + = select_tag "preview[color_id]", + options_from_collection_for_select(Color.funny.alphabetical, + "id", "human_name", @selected_preview_pet_type.color_id) + = select_tag "preview[species_id]", + options_from_collection_for_select(Species.alphabetical, + "id", "human_name", @selected_preview_pet_type.species_id) + = submit_tag "Go", name: nil - unless @contributors_with_counts.empty? #item-contributors