spree_storefront 5.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.md +13 -0
- data/Rakefile +15 -0
- data/app/assets/config/spree_storefront_manifest.js +6 -0
- data/app/assets/stylesheets/storefront_page_builder.css +51 -0
- data/app/controllers/concerns/spree/cart_methods.rb +40 -0
- data/app/controllers/concerns/spree/locale_urls.rb +23 -0
- data/app/controllers/concerns/spree/password_protected.rb +17 -0
- data/app/controllers/concerns/spree/theme_concern.rb +29 -0
- data/app/controllers/spree/account/addresses_controller.rb +16 -0
- data/app/controllers/spree/account/base_controller.rb +20 -0
- data/app/controllers/spree/account/newsletter_controller.rb +34 -0
- data/app/controllers/spree/account/orders_controller.rb +34 -0
- data/app/controllers/spree/account/profile_controller.rb +23 -0
- data/app/controllers/spree/account/store_credits_controller.rb +23 -0
- data/app/controllers/spree/account/wished_items_controller.rb +45 -0
- data/app/controllers/spree/addresses_controller.rb +101 -0
- data/app/controllers/spree/checkout_controller.rb +365 -0
- data/app/controllers/spree/contacts_controller.rb +46 -0
- data/app/controllers/spree/digital_links_controller.rb +48 -0
- data/app/controllers/spree/home_controller.rb +5 -0
- data/app/controllers/spree/line_items_controller.rb +96 -0
- data/app/controllers/spree/newsletter_subscribers_controller.rb +43 -0
- data/app/controllers/spree/order_status_controller.rb +32 -0
- data/app/controllers/spree/orders_controller.rb +104 -0
- data/app/controllers/spree/page_sections_controller.rb +17 -0
- data/app/controllers/spree/pages_controller.rb +13 -0
- data/app/controllers/spree/password_controller.rb +21 -0
- data/app/controllers/spree/policies_controller.rb +17 -0
- data/app/controllers/spree/posts_controller.rb +76 -0
- data/app/controllers/spree/products_controller.rb +99 -0
- data/app/controllers/spree/search_controller.rb +39 -0
- data/app/controllers/spree/seo_controller.rb +25 -0
- data/app/controllers/spree/settings_controller.rb +68 -0
- data/app/controllers/spree/store_controller.rb +247 -0
- data/app/controllers/spree/taxonomies_controller.rb +30 -0
- data/app/controllers/spree/taxons_controller.rb +46 -0
- data/app/controllers/spree/wishlists_controller.rb +19 -0
- data/app/finders/spree/storefront/variant_finder.rb +80 -0
- data/app/helpers/spree/analytics_helper.rb +28 -0
- data/app/helpers/spree/cart_helper.rb +48 -0
- data/app/helpers/spree/checkout_analytics_helper.rb +77 -0
- data/app/helpers/spree/checkout_helper.rb +58 -0
- data/app/helpers/spree/filters_helper.rb +180 -0
- data/app/helpers/spree/fonts_helper.rb +58 -0
- data/app/helpers/spree/orders_helper.rb +7 -0
- data/app/helpers/spree/page_helper.rb +67 -0
- data/app/helpers/spree/posts_helper.rb +42 -0
- data/app/helpers/spree/products_helper.rb +205 -0
- data/app/helpers/spree/storefront_helper.rb +86 -0
- data/app/helpers/spree/storefront_locale_helper.rb +42 -0
- data/app/helpers/spree/theme_helper.rb +244 -0
- data/app/helpers/spree/turbo_helper.rb +13 -0
- data/app/helpers/spree/turbo_stream_actions_helper.rb +13 -0
- data/app/helpers/spree/wishlist_helper.rb +7 -0
- data/app/javascript/spree/storefront/application.js +156 -0
- data/app/javascript/spree/storefront/controllers/accordion_controller.js +25 -0
- data/app/javascript/spree/storefront/controllers/account_nav_controller.js +10 -0
- data/app/javascript/spree/storefront/controllers/card_validation_controller.js +103 -0
- data/app/javascript/spree/storefront/controllers/carousel_controller.js +44 -0
- data/app/javascript/spree/storefront/controllers/cart_controller.js +10 -0
- data/app/javascript/spree/storefront/controllers/checkout_address_book_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/checkout_delivery_controller.js +39 -0
- data/app/javascript/spree/storefront/controllers/checkout_promotions_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/checkout_summary_controller.js +46 -0
- data/app/javascript/spree/storefront/controllers/clear_input_controller.js +23 -0
- data/app/javascript/spree/storefront/controllers/copy_input_controller.js +19 -0
- data/app/javascript/spree/storefront/controllers/dropdown_controller.js +14 -0
- data/app/javascript/spree/storefront/controllers/header_controller.js +33 -0
- data/app/javascript/spree/storefront/controllers/infinite_scroll_controller.js +31 -0
- data/app/javascript/spree/storefront/controllers/lightbox_controller.js +138 -0
- data/app/javascript/spree/storefront/controllers/mobile_nav_controller.js +17 -0
- data/app/javascript/spree/storefront/controllers/modal_controller.js +15 -0
- data/app/javascript/spree/storefront/controllers/no_ui_slider_controller.js +55 -0
- data/app/javascript/spree/storefront/controllers/pdp_desktop_gallery_controller.js +28 -0
- data/app/javascript/spree/storefront/controllers/plp_variant_picker_controller.js +151 -0
- data/app/javascript/spree/storefront/controllers/product_form_controller.js +136 -0
- data/app/javascript/spree/storefront/controllers/quantity_picker_controller.js +43 -0
- data/app/javascript/spree/storefront/controllers/search_suggestions_controller.js +61 -0
- data/app/javascript/spree/storefront/controllers/searchable_list_controller.js +25 -0
- data/app/javascript/spree/storefront/controllers/slideover_controller.js +40 -0
- data/app/javascript/spree/storefront/controllers/sticky_button_controller.js +32 -0
- data/app/javascript/spree/storefront/controllers/toggle_menu_controller.js +32 -0
- data/app/javascript/spree/storefront/controllers/turbo_stream_form_controller.js +51 -0
- data/app/javascript/spree/storefront/controllers/wished_item_controller.js +69 -0
- data/app/javascript/spree/storefront/helpers/lazy_load_controllers_with_manifest.js +78 -0
- data/app/javascript/spree/storefront/helpers/show_flash_message.js +25 -0
- data/app/models/spree/color_names.rb +35 -0
- data/app/models/spree/contact.rb +24 -0
- data/app/presenters/spree/colors_preview_styles_presenter.rb +84 -0
- data/app/presenters/spree/featured_product_presenter.rb +42 -0
- data/app/presenters/spree/mega_nav_presenter.rb +55 -0
- data/app/views/devise/passwords/edit.html.erb +22 -0
- data/app/views/devise/passwords/new.html.erb +16 -0
- data/app/views/devise/registrations/_form.html.erb +21 -0
- data/app/views/devise/registrations/edit.html.erb +24 -0
- data/app/views/devise/registrations/new.html.erb +27 -0
- data/app/views/devise/sessions/new.html.erb +25 -0
- data/app/views/devise/shared/_links.html.erb +22 -0
- data/app/views/layouts/spree/checkout.html.erb +58 -0
- data/app/views/layouts/spree/password.html.erb +34 -0
- data/app/views/layouts/spree/storefront.html.erb +38 -0
- data/app/views/spree/account/wished_items/create.turbo_stream.erb +8 -0
- data/app/views/spree/account/wished_items/destroy.turbo_stream.erb +20 -0
- data/app/views/spree/addresses/destroy.turbo_stream.erb +1 -0
- data/app/views/spree/addresses/edit.html.erb +57 -0
- data/app/views/spree/addresses/new.html.erb +71 -0
- data/app/views/spree/checkout/_address.html.erb +153 -0
- data/app/views/spree/checkout/_button_processing.html.erb +7 -0
- data/app/views/spree/checkout/_coupon_code.html.erb +55 -0
- data/app/views/spree/checkout/_credit_card.html.erb +12 -0
- data/app/views/spree/checkout/_delivery.html.erb +70 -0
- data/app/views/spree/checkout/_line_item.html.erb +26 -0
- data/app/views/spree/checkout/_line_items.html.erb +7 -0
- data/app/views/spree/checkout/_missing_all_line_items.html.erb +17 -0
- data/app/views/spree/checkout/_missing_line_items.html.erb +28 -0
- data/app/views/spree/checkout/_payment.html.erb +35 -0
- data/app/views/spree/checkout/_payment_methods.html.erb +72 -0
- data/app/views/spree/checkout/_payment_sources.html.erb +24 -0
- data/app/views/spree/checkout/_quick_checkout.html.erb +1 -0
- data/app/views/spree/checkout/_sidebar.html.erb +34 -0
- data/app/views/spree/checkout/_store_credit.html.erb +21 -0
- data/app/views/spree/checkout/_summary.html.erb +116 -0
- data/app/views/spree/checkout/_user_account.html.erb +9 -0
- data/app/views/spree/checkout/apply_coupon_code.turbo_stream.erb +45 -0
- data/app/views/spree/checkout/apply_store_credit.turbo_stream.erb +19 -0
- data/app/views/spree/checkout/edit.html.erb +98 -0
- data/app/views/spree/checkout/payment/_check.html.erb +0 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +74 -0
- data/app/views/spree/checkout/payment/_store_credit.html.erb +13 -0
- data/app/views/spree/checkout/remove_coupon_code.turbo_stream.erb +34 -0
- data/app/views/spree/checkout/remove_store_credit.turbo_stream.erb +19 -0
- data/app/views/spree/checkout/update.turbo_stream.erb +25 -0
- data/app/views/spree/home/index.html.erb +1 -0
- data/app/views/spree/line_items/create.turbo_stream.erb +13 -0
- data/app/views/spree/line_items/destroy.turbo_stream.erb +11 -0
- data/app/views/spree/line_items/update.turbo_stream.erb +10 -0
- data/app/views/spree/newsletter_subscribers/create.turbo_stream.erb +7 -0
- data/app/views/spree/order_status/new.html.erb +16 -0
- data/app/views/spree/page_sections/show.html.erb +3 -0
- data/app/views/spree/pages/show.html.erb +1 -0
- data/app/views/spree/password/show.html.erb +1 -0
- data/app/views/spree/posts/index.html.erb +1 -0
- data/app/views/spree/posts/related_products.html.erb +7 -0
- data/app/views/spree/posts/show.html.erb +1 -0
- data/app/views/spree/products/index.html.erb +1 -0
- data/app/views/spree/products/index.turbo_stream.erb +1 -0
- data/app/views/spree/products/related.html.erb +3 -0
- data/app/views/spree/products/show.html.erb +1 -0
- data/app/views/spree/search/show.html.erb +6 -0
- data/app/views/spree/search/show.turbo_stream.erb +1 -0
- data/app/views/spree/search/suggestions.turbo_stream.erb +8 -0
- data/app/views/spree/seo/robots.text.erb +31 -0
- data/app/views/spree/seo/sitemap.xml.erb +25 -0
- data/app/views/spree/shared/_fonts.html.erb +14 -0
- data/app/views/spree/shared/_head.html.erb +36 -0
- data/app/views/spree/shared/_load_more_products.turbo_stream.erb +7 -0
- data/app/views/spree/shared/_product_listing_page.html.erb +11 -0
- data/app/views/spree/shared/_products.html.erb +1 -0
- data/app/views/spree/taxonomies/show.html.erb +1 -0
- data/app/views/spree/taxons/show.html.erb +1 -0
- data/app/views/spree/taxons/show.turbo_stream.erb +1 -0
- data/app/views/spree/waitlists/create.turbo_stream.erb +9 -0
- data/app/views/themes/default/kaminari/storefront/_first_page.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_gap.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_last_page.html.erb +8 -0
- data/app/views/themes/default/kaminari/storefront/_next_page.html.erb +13 -0
- data/app/views/themes/default/kaminari/storefront/_page.html.erb +10 -0
- data/app/views/themes/default/kaminari/storefront/_paginator.html.erb +27 -0
- data/app/views/themes/default/kaminari/storefront/_prev_page.html.erb +13 -0
- data/app/views/themes/default/spree/account/_account_nav.html.erb +46 -0
- data/app/views/themes/default/spree/account/_order.html.erb +39 -0
- data/app/views/themes/default/spree/account/_orders.html.erb +16 -0
- data/app/views/themes/default/spree/account/addresses/_address.html.erb +42 -0
- data/app/views/themes/default/spree/account/addresses/index.html.erb +28 -0
- data/app/views/themes/default/spree/account/newsletter/_newsletter_settings.html.erb +13 -0
- data/app/views/themes/default/spree/account/newsletter/edit.html.erb +16 -0
- data/app/views/themes/default/spree/account/newsletter/update.html.erb +1 -0
- data/app/views/themes/default/spree/account/orders/index.html.erb +24 -0
- data/app/views/themes/default/spree/account/orders/show.html.erb +22 -0
- data/app/views/themes/default/spree/account/profile/edit.html.erb +36 -0
- data/app/views/themes/default/spree/account/store_credits/_store_credit_event.html.erb +29 -0
- data/app/views/themes/default/spree/account/store_credits/index.html.erb +31 -0
- data/app/views/themes/default/spree/checkout/_footer.html.erb +10 -0
- data/app/views/themes/default/spree/checkout/complete.html.erb +84 -0
- data/app/views/themes/default/spree/contacts/new.html.erb +23 -0
- data/app/views/themes/default/spree/orders/_cart.html.erb +14 -0
- data/app/views/themes/default/spree/orders/_empty.html.erb +11 -0
- data/app/views/themes/default/spree/orders/_line_item.html.erb +47 -0
- data/app/views/themes/default/spree/orders/_line_item_quantity.html.erb +11 -0
- data/app/views/themes/default/spree/orders/_summary.html.erb +41 -0
- data/app/views/themes/default/spree/orders/edit.html.erb +18 -0
- data/app/views/themes/default/spree/orders/show.html.erb +6 -0
- data/app/views/themes/default/spree/page_sections/_announcement_bar.html.erb +10 -0
- data/app/views/themes/default/spree/page_sections/_custom_code.html.erb +5 -0
- data/app/views/themes/default/spree/page_sections/_featured_product.html.erb +136 -0
- data/app/views/themes/default/spree/page_sections/_featured_taxon.html.erb +116 -0
- data/app/views/themes/default/spree/page_sections/_featured_taxons.html.erb +71 -0
- data/app/views/themes/default/spree/page_sections/_footer.html.erb +62 -0
- data/app/views/themes/default/spree/page_sections/_header.html.erb +166 -0
- data/app/views/themes/default/spree/page_sections/_image_banner.html.erb +57 -0
- data/app/views/themes/default/spree/page_sections/_image_with_text.html.erb +66 -0
- data/app/views/themes/default/spree/page_sections/_main_password_footer.html.erb +64 -0
- data/app/views/themes/default/spree/page_sections/_main_password_header.html.erb +54 -0
- data/app/views/themes/default/spree/page_sections/_newsletter.html.erb +47 -0
- data/app/views/themes/default/spree/page_sections/_page_title.html.erb +7 -0
- data/app/views/themes/default/spree/page_sections/_post_details.html.erb +19 -0
- data/app/views/themes/default/spree/page_sections/_post_grid.html.erb +11 -0
- data/app/views/themes/default/spree/page_sections/_product_details.html.erb +102 -0
- data/app/views/themes/default/spree/page_sections/_product_grid.html.erb +52 -0
- data/app/views/themes/default/spree/page_sections/_related_products.html.erb +15 -0
- data/app/views/themes/default/spree/page_sections/_rich_text.html.erb +18 -0
- data/app/views/themes/default/spree/page_sections/_taxon_banner.html.erb +37 -0
- data/app/views/themes/default/spree/page_sections/_taxon_grid.html.erb +103 -0
- data/app/views/themes/default/spree/page_sections/_video.html.erb +27 -0
- data/app/views/themes/default/spree/page_sections/nav/_desktop.html.erb +49 -0
- data/app/views/themes/default/spree/page_sections/nav/_mobile.html.erb +136 -0
- data/app/views/themes/default/spree/policies/show.html.erb +11 -0
- data/app/views/themes/default/spree/posts/_json_ld.html.erb +20 -0
- data/app/views/themes/default/spree/posts/_pagination.html.erb +1 -0
- data/app/views/themes/default/spree/posts/_post.html.erb +13 -0
- data/app/views/themes/default/spree/products/_add_to_cart_button.html.erb +58 -0
- data/app/views/themes/default/spree/products/_add_to_waitlist.html.erb +36 -0
- data/app/views/themes/default/spree/products/_add_to_wishlist.html.erb +33 -0
- data/app/views/themes/default/spree/products/_breadcrumbs.html.erb +23 -0
- data/app/views/themes/default/spree/products/_color_picker.html.erb +19 -0
- data/app/views/themes/default/spree/products/_color_swatches.html.erb +61 -0
- data/app/views/themes/default/spree/products/_details.html.erb +55 -0
- data/app/views/themes/default/spree/products/_featured_image.html.erb +37 -0
- data/app/views/themes/default/spree/products/_filters.html.erb +45 -0
- data/app/views/themes/default/spree/products/_json_ld.html.erb +38 -0
- data/app/views/themes/default/spree/products/_json_ld_list.html.erb +9 -0
- data/app/views/themes/default/spree/products/_json_ld_variant.html.erb +10 -0
- data/app/views/themes/default/spree/products/_label.html.erb +26 -0
- data/app/views/themes/default/spree/products/_media_gallery.html.erb +94 -0
- data/app/views/themes/default/spree/products/_price.html.erb +59 -0
- data/app/views/themes/default/spree/products/_product.html.erb +62 -0
- data/app/views/themes/default/spree/products/_quantity_selector.html.erb +32 -0
- data/app/views/themes/default/spree/products/_returns_policy_modal.html.erb +22 -0
- data/app/views/themes/default/spree/products/_show_more_button.html.erb +8 -0
- data/app/views/themes/default/spree/products/_sort.html.erb +45 -0
- data/app/views/themes/default/spree/products/_swiper.html.erb +85 -0
- data/app/views/themes/default/spree/products/_tags.html.erb +0 -0
- data/app/views/themes/default/spree/products/_variant_options.html.erb +71 -0
- data/app/views/themes/default/spree/products/_variant_picker.html.erb +50 -0
- data/app/views/themes/default/spree/products/filters/_availability.html.erb +32 -0
- data/app/views/themes/default/spree/products/filters/_colors.html.erb +23 -0
- data/app/views/themes/default/spree/products/filters/_generic.html.erb +75 -0
- data/app/views/themes/default/spree/products/filters/_price.html.erb +35 -0
- data/app/views/themes/default/spree/products/filters/_taxons.erb +78 -0
- data/app/views/themes/default/spree/search/_suggestions.html.erb +92 -0
- data/app/views/themes/default/spree/settings/show.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_account_pane.html.erb +28 -0
- data/app/views/themes/default/spree/shared/_address.html.erb +35 -0
- data/app/views/themes/default/spree/shared/_cart_icon.html.erb +13 -0
- data/app/views/themes/default/spree/shared/_cart_pane.html.erb +38 -0
- data/app/views/themes/default/spree/shared/_css_variables.html.erb +54 -0
- data/app/views/themes/default/spree/shared/_custom_head.html.erb +0 -0
- data/app/views/themes/default/spree/shared/_error_messages.html.erb +9 -0
- data/app/views/themes/default/spree/shared/_error_messages_without_base_attribute.html.erb +15 -0
- data/app/views/themes/default/spree/shared/_flash.html.erb +16 -0
- data/app/views/themes/default/spree/shared/_flashes.html.erb +10 -0
- data/app/views/themes/default/spree/shared/_json_ld.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_line_item_options.html.erb +18 -0
- data/app/views/themes/default/spree/shared/_logo.html.erb +42 -0
- data/app/views/themes/default/spree/shared/_meta_tags.html.erb +45 -0
- data/app/views/themes/default/spree/shared/_order_details.html.erb +106 -0
- data/app/views/themes/default/spree/shared/_order_line_item.html.erb +65 -0
- data/app/views/themes/default/spree/shared/_order_shipment.html.erb +71 -0
- data/app/views/themes/default/spree/shared/_search.html.erb +32 -0
- data/app/views/themes/default/spree/shared/_title.html.erb +3 -0
- data/app/views/themes/default/spree/shared/_wishlist_icon.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_account.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_arrow-left.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_arrow-right.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_bell.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_cart.html.erb +10 -0
- data/app/views/themes/default/spree/shared/icons/_cart_48.html.erb +6 -0
- data/app/views/themes/default/spree/shared/icons/_check.html.erb +4 -0
- data/app/views/themes/default/spree/shared/icons/_chevron.html.erb +15 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_down.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_right.html.erb +15 -0
- data/app/views/themes/default/spree/shared/icons/_chevron_up.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_close.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_cross.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_delete.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_delivery.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_disabled.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_edit.html.erb +3 -0
- data/app/views/themes/default/spree/shared/icons/_facebook.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_filter.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_heart.html.erb +12 -0
- data/app/views/themes/default/spree/shared/icons/_info.html.erb +7 -0
- data/app/views/themes/default/spree/shared/icons/_instagram.html.erb +18 -0
- data/app/views/themes/default/spree/shared/icons/_lock.html.erb +13 -0
- data/app/views/themes/default/spree/shared/icons/_menu.html.erb +10 -0
- data/app/views/themes/default/spree/shared/icons/_minus.html.erb +5 -0
- data/app/views/themes/default/spree/shared/icons/_pinch.html.erb +6 -0
- data/app/views/themes/default/spree/shared/icons/_pinterest.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_plus.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_return.html.erb +11 -0
- data/app/views/themes/default/spree/shared/icons/_search.html.erb +17 -0
- data/app/views/themes/default/spree/shared/icons/_spinner.html.erb +1 -0
- data/app/views/themes/default/spree/shared/icons/_spotify.html.erb +8 -0
- data/app/views/themes/default/spree/shared/icons/_tiktok.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_twitter.html.erb +16 -0
- data/app/views/themes/default/spree/shared/icons/_youtube.html.erb +9 -0
- data/app/views/themes/default/spree/shared/icons/_zoom.html.erb +10 -0
- data/app/views/themes/default/spree/wishlists/_no_wished_items.html.erb +10 -0
- data/app/views/themes/default/spree/wishlists/_wished_item.html.erb +38 -0
- data/app/views/themes/default/spree/wishlists/show.html.erb +17 -0
- data/config/i18n-tasks.yml +176 -0
- data/config/importmap.rb +22 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/heroicon.rb +10 -0
- data/config/locales/en.yml +76 -0
- data/config/routes.rb +88 -0
- data/lib/generators/spree/storefront/install/install_generator.rb +45 -0
- data/lib/generators/spree/storefront/install/templates/application.tailwind.css +1760 -0
- data/lib/generators/spree/storefront/install/templates/dev +16 -0
- data/lib/generators/spree/storefront/install/templates/tailwind.config.js +128 -0
- data/lib/generators/spree/storefront/theme/templates/model.rb.tt +12 -0
- data/lib/generators/spree/storefront/theme/theme_generator.rb +41 -0
- data/lib/spree/storefront/configuration.rb +11 -0
- data/lib/spree/storefront/engine.rb +51 -0
- data/lib/spree/storefront/testing_support/capybara_utils.rb +13 -0
- data/lib/spree/storefront.rb +16 -0
- data/lib/spree_storefront.rb +1 -0
- data/vendor/colornames.json +1 -0
- data/vendor/javascript/@kanety--stimulus-accordion.js +4 -0
- data/vendor/javascript/@stimulus-components--carousel.js +4 -0
- data/vendor/javascript/card-validator.js +4 -0
- data/vendor/javascript/credit-card-type.js +4 -0
- data/vendor/javascript/headroom.js.js +19 -0
- data/vendor/javascript/nouislider.js +4 -0
- data/vendor/javascript/photoswipe--dist--photoswipe-lightbox.esm.js.js +667 -0
- data/vendor/javascript/photoswipe.js +1675 -0
- data/vendor/javascript/stimulus-read-more.js +4 -0
- data/vendor/javascript/stimulus-scroll-to.js +4 -0
- data/vendor/javascript/swiper--bundle.js +4 -0
- metadata +567 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['shippingList', 'shippingRate', 'submit']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
document.addEventListener('turbo:submit-end', _event => {
|
8
|
+
this.enableShippingRates();
|
9
|
+
this.submitTarget.disabled = false
|
10
|
+
});
|
11
|
+
}
|
12
|
+
|
13
|
+
update() {
|
14
|
+
this.disableShippingRates();
|
15
|
+
this.submitTarget.disabled = true
|
16
|
+
|
17
|
+
// https://discuss.hotwired.dev/t/form-submit-with-turbo-streams-response-without-redirect/3290
|
18
|
+
const oldAction = this.element.getAttribute("action")
|
19
|
+
this.element.action = this.element.action + '?do_not_advance=true'
|
20
|
+
Turbo.navigator.submitForm(this.element)
|
21
|
+
this.element.action = oldAction
|
22
|
+
}
|
23
|
+
|
24
|
+
enableShippingRates() {
|
25
|
+
this.shippingListTarget.classList.remove('opacity-50');
|
26
|
+
this.shippingListTarget.classList.remove('cursor-wait');
|
27
|
+
this.shippingRateTargets.forEach((shippingRate) => {
|
28
|
+
shippingRate.style.pointerEvents = 'auto';
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
disableShippingRates() {
|
33
|
+
this.shippingListTarget.classList.add('opacity-50');
|
34
|
+
this.shippingListTarget.classList.add('cursor-wait');
|
35
|
+
this.shippingRateTargets.forEach((shippingRate) => {
|
36
|
+
shippingRate.style.pointerEvents = 'none';
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['promotionEmailField']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.element.addEventListener(
|
8
|
+
'submit',
|
9
|
+
this.copyEmailFieldToForm.bind(this)
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
disconnect() {
|
14
|
+
this.element.removeEventListener(
|
15
|
+
'submit',
|
16
|
+
this.copyEmailFieldToForm.bind(this)
|
17
|
+
)
|
18
|
+
}
|
19
|
+
|
20
|
+
copyEmailFieldToForm(e) {
|
21
|
+
const userEmailField = document.getElementById(
|
22
|
+
'order_ship_address_attributes_email'
|
23
|
+
)
|
24
|
+
if (userEmailField) {
|
25
|
+
this.promotionEmailFieldTarget.value = userEmailField.value
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = [
|
5
|
+
'container',
|
6
|
+
'content',
|
7
|
+
'wrapper',
|
8
|
+
'line_items',
|
9
|
+
'coupon_area'
|
10
|
+
]
|
11
|
+
|
12
|
+
onCouponResize() {
|
13
|
+
this.line_itemsTarget.style.maxHeight = `${window.innerHeight - this.coupon_areaTarget.offsetHeight - 20}px`
|
14
|
+
}
|
15
|
+
|
16
|
+
connect() {
|
17
|
+
var wrapper = this.wrapperTarget
|
18
|
+
var summary = this.containerTarget
|
19
|
+
var content = this.contentTarget
|
20
|
+
var couponArea = this.coupon_areaTarget
|
21
|
+
|
22
|
+
summary.style.height = content.offsetHeight + 'px'
|
23
|
+
wrapper.classList.toggle('summary-folded', true)
|
24
|
+
|
25
|
+
this.observer = new ResizeObserver(function () {
|
26
|
+
summary.style.height = content.offsetHeight + 'px'
|
27
|
+
})
|
28
|
+
|
29
|
+
this.couponObserver = new ResizeObserver(this.onCouponResize.bind(this))
|
30
|
+
|
31
|
+
window.addEventListener('resize', this.onCouponResize.bind(this))
|
32
|
+
|
33
|
+
this.observer.observe(content)
|
34
|
+
this.couponObserver.observe(couponArea)
|
35
|
+
}
|
36
|
+
|
37
|
+
disconnect() {
|
38
|
+
if (this.observer) {
|
39
|
+
this.observer.disconnect()
|
40
|
+
}
|
41
|
+
if (this.couponObserver) {
|
42
|
+
this.couponObserver.disconnect()
|
43
|
+
}
|
44
|
+
window.removeEventListener('resize', this.onCouponResize.bind(this))
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['input', 'button']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.inputTarget.addEventListener('input', this.toggleButton)
|
8
|
+
}
|
9
|
+
|
10
|
+
clear() {
|
11
|
+
this.inputTarget.value = ''
|
12
|
+
this.inputTarget.focus()
|
13
|
+
this.toggleButton()
|
14
|
+
}
|
15
|
+
|
16
|
+
toggleButton = () => {
|
17
|
+
if (this.inputTarget.value.trim().length) {
|
18
|
+
this.buttonTarget.classList.remove('hidden')
|
19
|
+
} else {
|
20
|
+
this.buttonTarget.classList.add('hidden')
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['input', 'copyButton']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.copyButtonTarget.addEventListener('click', this.copyText.bind(this))
|
8
|
+
}
|
9
|
+
|
10
|
+
disconnect() {
|
11
|
+
this.copyButtonTarget.removeEventListener('click', this.copyText.bind(this))
|
12
|
+
}
|
13
|
+
|
14
|
+
async copyText() {
|
15
|
+
this.inputTarget.select()
|
16
|
+
this.inputTarget.setSelectionRange(0, 99999)
|
17
|
+
await navigator.clipboard.writeText(this.inputTarget.value)
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Dropdown } from 'tailwindcss-stimulus-components'
|
2
|
+
|
3
|
+
export default class extends Dropdown {
|
4
|
+
hide(event) {
|
5
|
+
let containsTarget = this.element.contains(event.target)
|
6
|
+
if (this.element.getRootNode() instanceof ShadowRoot) {
|
7
|
+
const trueTarget = event.composedPath()[0]
|
8
|
+
containsTarget = this.element.contains(trueTarget)
|
9
|
+
}
|
10
|
+
if (event.target.nodeType && containsTarget === false && this.openValue) {
|
11
|
+
this.openValue = false
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import Headroom from 'headroom.js'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = ['header']
|
6
|
+
|
7
|
+
connect() {
|
8
|
+
this.headroom = new Headroom(this.element, {
|
9
|
+
offset: 200,
|
10
|
+
onNotTop: () => {
|
11
|
+
if (this.element.classList.contains('header-logo-centered'))
|
12
|
+
this.element
|
13
|
+
.querySelector('body:not(.inside-page-builder) .header-nav-container #header-logo')
|
14
|
+
?.classList?.add('lg:sr-only')
|
15
|
+
},
|
16
|
+
onTop: () => {
|
17
|
+
if (this.element.classList.contains('header-logo-centered'))
|
18
|
+
this.element
|
19
|
+
.querySelector('body:not(.inside-page-builder) .header-nav-container #header-logo')
|
20
|
+
?.classList?.remove('lg:sr-only')
|
21
|
+
}
|
22
|
+
})
|
23
|
+
this.headroom.init()
|
24
|
+
}
|
25
|
+
|
26
|
+
freeze() {
|
27
|
+
this.headroom.freeze()
|
28
|
+
}
|
29
|
+
|
30
|
+
unfreeze() {
|
31
|
+
this.headroom.unfreeze()
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import { get } from '@rails/request.js'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static values = { offset: String }
|
6
|
+
initialize() {
|
7
|
+
this.intersectionObserver = new IntersectionObserver(this.checkIntersection, { rootMargin: this.offsetValue })
|
8
|
+
}
|
9
|
+
|
10
|
+
connect() {
|
11
|
+
this.intersectionObserver.observe(this.element)
|
12
|
+
}
|
13
|
+
|
14
|
+
disconnect() {
|
15
|
+
this.intersectionObserver.unobserve(this.element)
|
16
|
+
}
|
17
|
+
|
18
|
+
checkIntersection = async (entries) => {
|
19
|
+
for (const entry of entries) {
|
20
|
+
if (entry.isIntersecting) {
|
21
|
+
await this.loadMore()
|
22
|
+
break
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
async loadMore() {
|
28
|
+
this.element.disabled = true
|
29
|
+
await get(this.element.src, { responseKind: 'turbo-stream' })
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import PhotoSwipeLightbox from 'photoswipe/lightbox'
|
3
|
+
|
4
|
+
const closeSVG = `
|
5
|
+
<svg class="pswp__icn" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
6
|
+
<path d="M3.00029 3L21 20.9688M3 21L20.9997 3.03115" stroke="black" stroke-width="1.5"/>
|
7
|
+
</svg>`
|
8
|
+
const arrowPrevSVG = `
|
9
|
+
<svg class="pswp__icn" width="24" height="24" viewBox="0 0 32 32" fill="none">
|
10
|
+
<path d="M2 16H30M2 16L16 2M2 16L16 30" stroke="black" stroke-width="1.5"/>
|
11
|
+
</svg>`
|
12
|
+
const arrowNextSVG = `
|
13
|
+
<svg class="pswp__icn" width="24" height="24" viewBox="0 0 32 32" fill="none">
|
14
|
+
<path d="M30 16H2M30 16L16 2M30 16L16 30" stroke="black" stroke-width="1.5"/>
|
15
|
+
</svg>`
|
16
|
+
|
17
|
+
function isTouchDevice() {
|
18
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0
|
19
|
+
}
|
20
|
+
export default class extends Controller {
|
21
|
+
connect() {
|
22
|
+
this.addPhotoSwipeStyles()
|
23
|
+
|
24
|
+
const lightbox = new PhotoSwipeLightbox({
|
25
|
+
gallery: this.element,
|
26
|
+
children: 'a',
|
27
|
+
bgOpacity: 1.0,
|
28
|
+
initialZoomLevel: 'fit',
|
29
|
+
secondaryZoomLevel: 1,
|
30
|
+
pswpModule: () => import('photoswipe'),
|
31
|
+
closeSVG,
|
32
|
+
arrowPrevSVG,
|
33
|
+
arrowNextSVG,
|
34
|
+
arrowPrev: true,
|
35
|
+
arrowNext: true,
|
36
|
+
preload: [1, 4] // https://photoswipe.com/options/#preload
|
37
|
+
})
|
38
|
+
|
39
|
+
lightbox.on('firstUpdate', () => {
|
40
|
+
if (isTouchDevice() && this.pinchToZoomEl) {
|
41
|
+
this.pinchToZoomEl.style.display = 'flex'
|
42
|
+
}
|
43
|
+
})
|
44
|
+
|
45
|
+
lightbox.on('pointerUp', () => {
|
46
|
+
if (this.pinchToZoomEl) this.pinchToZoomEl.style.display = 'none'
|
47
|
+
})
|
48
|
+
|
49
|
+
lightbox.on('uiRegister', function () {
|
50
|
+
lightbox.pswp.ui.registerElement({
|
51
|
+
name: 'bulletsIndicator',
|
52
|
+
className: 'pswp__bullets-indicator',
|
53
|
+
appendTo: 'wrapper',
|
54
|
+
onInit: (el, pswp) => {
|
55
|
+
const bullets = []
|
56
|
+
let bullet
|
57
|
+
let prevIndex = -1
|
58
|
+
const itemsCount = pswp.getNumItems()
|
59
|
+
|
60
|
+
if (itemsCount <= 1) {
|
61
|
+
return
|
62
|
+
}
|
63
|
+
|
64
|
+
for (let i = 0; i < itemsCount; i++) {
|
65
|
+
bullet = document.createElement('div')
|
66
|
+
bullet.className = 'pswp__bullet'
|
67
|
+
bullet.onclick = (e) => {
|
68
|
+
pswp.goTo(bullets.indexOf(e.target))
|
69
|
+
}
|
70
|
+
el.appendChild(bullet)
|
71
|
+
bullets.push(bullet)
|
72
|
+
}
|
73
|
+
|
74
|
+
pswp.on('change', () => {
|
75
|
+
if (prevIndex >= 0) {
|
76
|
+
bullets[prevIndex].classList.remove('pswp__bullet--active')
|
77
|
+
}
|
78
|
+
bullets[pswp.currIndex].classList.add('pswp__bullet--active')
|
79
|
+
prevIndex = pswp.currIndex
|
80
|
+
})
|
81
|
+
}
|
82
|
+
})
|
83
|
+
|
84
|
+
lightbox.pswp.ui.registerElement({
|
85
|
+
name: 'pagination',
|
86
|
+
className: 'pswp__pagination',
|
87
|
+
appendTo: 'wrapper',
|
88
|
+
onInit: (el, pswp) => {
|
89
|
+
const itemsCount = pswp.getNumItems()
|
90
|
+
|
91
|
+
if (itemsCount <= 1) {
|
92
|
+
return
|
93
|
+
}
|
94
|
+
|
95
|
+
const currentEl = document.createElement('span')
|
96
|
+
currentEl.className = 'pswp__pagination--current'
|
97
|
+
currentEl.innerHTML = String(pswp.currIndex + 1).padStart(2, '0')
|
98
|
+
|
99
|
+
const allEl = document.createElement('span')
|
100
|
+
allEl.className = 'pswp__pagination--all'
|
101
|
+
allEl.innerHTML = String(itemsCount).padStart(2, '0')
|
102
|
+
|
103
|
+
el.appendChild(currentEl)
|
104
|
+
el.appendChild(document.createTextNode('/'))
|
105
|
+
el.appendChild(allEl)
|
106
|
+
|
107
|
+
pswp.on('change', () => {
|
108
|
+
currentEl.innerHTML = String(pswp.currIndex + 1).padStart(2, '0')
|
109
|
+
})
|
110
|
+
}
|
111
|
+
})
|
112
|
+
})
|
113
|
+
|
114
|
+
lightbox.init()
|
115
|
+
}
|
116
|
+
|
117
|
+
get pinchToZoomEl() {
|
118
|
+
let pinchToZoom = document.querySelector('#pinch-to-zoom')
|
119
|
+
if (this.element.getRootNode() instanceof ShadowRoot) {
|
120
|
+
pinchToZoom = this.element.getRootNode().querySelector('#pinch-to-zoom')
|
121
|
+
}
|
122
|
+
|
123
|
+
return pinchToZoom
|
124
|
+
}
|
125
|
+
|
126
|
+
addPhotoSwipeStyles() {
|
127
|
+
if (document.getElementById('photoswipe-styles')) {
|
128
|
+
return
|
129
|
+
}
|
130
|
+
|
131
|
+
const link = document.createElement('link')
|
132
|
+
link.id = 'photoswipe-styles'
|
133
|
+
link.rel = 'stylesheet'
|
134
|
+
link.href = 'https://esm.sh/photoswipe@5.4.4/dist/photoswipe.css'
|
135
|
+
link.onerror = () => console.error('Failed to load PhotoSwipe CSS')
|
136
|
+
document.head.appendChild(link)
|
137
|
+
}
|
138
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['submenuContainer']
|
5
|
+
|
6
|
+
openSubmenu(e) {
|
7
|
+
const template = e.target.querySelector('template')
|
8
|
+
if (template) {
|
9
|
+
this.submenuContainerTarget.innerHTML = template.innerHTML
|
10
|
+
this.element.style.setProperty('--tw-translate-x', '-100vw')
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
closeSubmenu() {
|
15
|
+
this.element.style.setProperty('--tw-translate-x', null)
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Modal } from 'tailwindcss-stimulus-components'
|
2
|
+
|
3
|
+
export default class extends Modal {
|
4
|
+
static values = {
|
5
|
+
opened: Boolean
|
6
|
+
}
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
super.connect()
|
10
|
+
|
11
|
+
if (this.openedValue) {
|
12
|
+
super.open({preventDefault: () => {}, target: { blur: () => {}}})
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import noUiSlider from 'nouislider'
|
2
|
+
import { Controller } from '@hotwired/stimulus'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static values = {
|
6
|
+
range: Array,
|
7
|
+
start: Array
|
8
|
+
}
|
9
|
+
|
10
|
+
static targets = ['slider', 'minInput', 'maxInput']
|
11
|
+
|
12
|
+
connect() {
|
13
|
+
if (this.sliderTarget.noUiSlider) {
|
14
|
+
this.sliderTarget.noUiSlider.destroy()
|
15
|
+
}
|
16
|
+
|
17
|
+
const slider = noUiSlider.create(this.sliderTarget, {
|
18
|
+
start: this.startValue,
|
19
|
+
connect: true,
|
20
|
+
step: 1,
|
21
|
+
range: {
|
22
|
+
min: [this.rangeValue[0]],
|
23
|
+
max: [this.rangeValue[1]]
|
24
|
+
}
|
25
|
+
})
|
26
|
+
this.wasSliderChanged = Array(this.startValue.length).fill(false)
|
27
|
+
|
28
|
+
slider.on('update', (values, handle) => {
|
29
|
+
if (!this.wasSliderChanged[handle] && parseFloat(values[handle]) === this.rangeValue[handle]) {
|
30
|
+
this.wasSliderChanged[handle] = true
|
31
|
+
return
|
32
|
+
}
|
33
|
+
|
34
|
+
if (handle) {
|
35
|
+
this.maxInputTarget.value = parseFloat(values[handle]).toFixed(0)
|
36
|
+
} else {
|
37
|
+
this.minInputTarget.value = parseFloat(values[handle]).toFixed(0)
|
38
|
+
}
|
39
|
+
})
|
40
|
+
|
41
|
+
this.minInputTarget.addEventListener('change', (event) => {
|
42
|
+
slider.set([event.currentTarget.value, null])
|
43
|
+
})
|
44
|
+
|
45
|
+
this.maxInputTarget.addEventListener('change', (event) => {
|
46
|
+
slider.set([null, event.currentTarget.value])
|
47
|
+
})
|
48
|
+
}
|
49
|
+
|
50
|
+
disconnect() {
|
51
|
+
if (this.sliderTarget.noUiSlider) {
|
52
|
+
this.sliderTarget.noUiSlider.destroy()
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import Swiper from 'swiper/bundle'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = ['imagesSlider', 'imagesSliderPagination', 'imagesThumbsSlider', 'prevArrow', 'nextArrow']
|
6
|
+
connect() {
|
7
|
+
const thumbsSwiper = new Swiper(this.imagesThumbsSliderTarget, {
|
8
|
+
spaceBetween: 4,
|
9
|
+
direction: 'vertical',
|
10
|
+
slidesPerView: 'auto',
|
11
|
+
freeMode: { enabled: true, sticky: true },
|
12
|
+
watchSlidesProgress: true,
|
13
|
+
watchOverflow: true
|
14
|
+
})
|
15
|
+
new Swiper(this.imagesSliderTarget, {
|
16
|
+
slidesPerView: 1,
|
17
|
+
pagination: {
|
18
|
+
el: this.hasImagesSliderPaginationTarget ? this.imagesSliderPaginationTarget : undefined
|
19
|
+
},
|
20
|
+
thumbs: { swiper: thumbsSwiper, autoScrollOffset: 2 },
|
21
|
+
watchOverflow: true,
|
22
|
+
navigation: {
|
23
|
+
prevEl: this.prevArrowTarget,
|
24
|
+
nextEl: this.nextArrowTarget
|
25
|
+
}
|
26
|
+
})
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['featuredImageContainer', 'colorsContainer', 'priceContainer', 'link', 'addToWishlist']
|
5
|
+
connect() {
|
6
|
+
this.canPreview = false
|
7
|
+
this.resetSelectedValues()
|
8
|
+
if (this.hasColorsContainerTarget && this.hasFeaturedImageContainerTarget) {
|
9
|
+
this.saveOriginalPreview()
|
10
|
+
this.setFeaturedImageHeight() // Set the height of the featured image container to prevent layout shift
|
11
|
+
this.colorsContainerTarget.addEventListener('mouseleave', this.restoreOriginalPreview)
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
disconnect() {
|
16
|
+
this.canPreview = false
|
17
|
+
this.resetSelectedValues()
|
18
|
+
if (this.hasColorsContainerTarget && this.hasFeaturedImageContainerTarget) {
|
19
|
+
this.restoreOriginalPreview()
|
20
|
+
this.colorsContainerTarget.removeEventListener('mouseleave', this.restoreOriginalPreview)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
resetSelectedValues() {
|
25
|
+
this.selectedVariantFeaturedImageHTML = null
|
26
|
+
this.selectedVariantPriceHTML = null
|
27
|
+
this.selectedAddToWishlistHTML = null
|
28
|
+
}
|
29
|
+
|
30
|
+
showMoreColors(e) {
|
31
|
+
e.preventDefault()
|
32
|
+
|
33
|
+
const colors = [...this.colorsContainerTarget.children]
|
34
|
+
colors.forEach((child) => {
|
35
|
+
child.style.display = 'flex'
|
36
|
+
})
|
37
|
+
|
38
|
+
e.target.style.display = 'none'
|
39
|
+
}
|
40
|
+
|
41
|
+
redirectToVariant(e) {
|
42
|
+
const el = e.target.closest('[data-variant-id]')
|
43
|
+
const url = new URL(this.linkTarget.href)
|
44
|
+
url.searchParams.set('variant_id', el.dataset.variantId)
|
45
|
+
Turbo.visit(url)
|
46
|
+
}
|
47
|
+
|
48
|
+
handlePreview(e) {
|
49
|
+
if (window.matchMedia('(pointer: coarse)').matches) return
|
50
|
+
|
51
|
+
this.preview(e.target)
|
52
|
+
}
|
53
|
+
|
54
|
+
preview(target) {
|
55
|
+
if (!this.canPreview) return
|
56
|
+
|
57
|
+
const featuredImageTemplate = target.querySelector('template[data-featured-image-template]')
|
58
|
+
|
59
|
+
if (featuredImageTemplate) {
|
60
|
+
this.setFeaturedImageHTML(featuredImageTemplate.innerHTML)
|
61
|
+
} else {
|
62
|
+
this.restoreOriginalImage()
|
63
|
+
}
|
64
|
+
|
65
|
+
const priceTemplate = target.querySelector('template[data-price-template]')
|
66
|
+
if (priceTemplate) {
|
67
|
+
this.setPriceHTML(priceTemplate.innerHTML)
|
68
|
+
} else {
|
69
|
+
this.restoreOriginalPrice()
|
70
|
+
}
|
71
|
+
|
72
|
+
const addToWishlistTemplate = target.querySelector('template[data-add-to-wishlist-template]')
|
73
|
+
if (addToWishlistTemplate) {
|
74
|
+
this.setAddToWishlistHTML(addToWishlistTemplate.innerHTML)
|
75
|
+
} else {
|
76
|
+
this.restoreOriginalAddToWishlist()
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
saveOriginalPreview() {
|
81
|
+
this.originalFeaturedImageHTML = this.featuredImageContainerTarget.innerHTML
|
82
|
+
this.originalPriceHTML = this.priceContainerTarget.innerHTML
|
83
|
+
this.originalAddToWishlistHTML = this.addToWishlistTarget.innerHTML
|
84
|
+
}
|
85
|
+
|
86
|
+
restoreOriginalPreview = () => {
|
87
|
+
if (this.selectedVariantFeaturedImageHTML) {
|
88
|
+
this.setFeaturedImageHTML(this.selectedVariantFeaturedImageHTML)
|
89
|
+
} else {
|
90
|
+
this.restoreOriginalImage()
|
91
|
+
}
|
92
|
+
if (this.selectedVariantPriceHTML) {
|
93
|
+
this.setPriceHTML(this.selectedVariantPriceHTML)
|
94
|
+
} else {
|
95
|
+
this.restoreOriginalPrice()
|
96
|
+
}
|
97
|
+
if (this.selectedAddToWishlistHTML) {
|
98
|
+
this.setAddToWishlistHTML(this.selectedAddToWishlistHTML)
|
99
|
+
} else {
|
100
|
+
this.restoreOriginalAddToWishlist()
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
restoreOriginalImage() {
|
105
|
+
this.setFeaturedImageHTML(this.originalFeaturedImageHTML)
|
106
|
+
}
|
107
|
+
|
108
|
+
restoreOriginalPrice() {
|
109
|
+
this.setPriceHTML(this.originalPriceHTML)
|
110
|
+
}
|
111
|
+
|
112
|
+
restoreOriginalAddToWishlist() {
|
113
|
+
this.setAddToWishlistHTML(this.originalAddToWishlistHTML)
|
114
|
+
}
|
115
|
+
|
116
|
+
setPriceHTML(html) {
|
117
|
+
if (this.priceContainerTarget.innerHTML !== html) {
|
118
|
+
this.priceContainerTarget.innerHTML = html
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
setFeaturedImageHTML(html) {
|
123
|
+
if (this.featuredImageContainerTarget.innerHTML !== html) {
|
124
|
+
this.featuredImageContainerTarget.innerHTML = html
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
setAddToWishlistHTML(html) {
|
129
|
+
if (this.addToWishlistTarget.innerHTML !== html) {
|
130
|
+
this.addToWishlistTarget.innerHTML = html
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
setFeaturedImageHeight() {
|
135
|
+
const featuredImage = this.featuredImageContainerTarget.querySelector('img')
|
136
|
+
if (featuredImage) {
|
137
|
+
if (featuredImage.complete) {
|
138
|
+
this.featuredImageContainerTarget.style.height = `${this.featuredImageContainerTarget.offsetHeight}px`
|
139
|
+
this.canPreview = true
|
140
|
+
} else {
|
141
|
+
featuredImage.onload = () => {
|
142
|
+
this.featuredImageContainerTarget.style.height = `${this.featuredImageContainerTarget.offsetHeight}px`
|
143
|
+
// Disable preview if the image is not loaded - this prevents layout shift
|
144
|
+
this.canPreview = true
|
145
|
+
}
|
146
|
+
}
|
147
|
+
} else {
|
148
|
+
this.canPreview = true
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|