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,136 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = [
|
5
|
+
'submit',
|
6
|
+
'option',
|
7
|
+
'form',
|
8
|
+
'addToWishlist',
|
9
|
+
'desktopMediaGallery',
|
10
|
+
'productDetails',
|
11
|
+
'spinnerTemplate',
|
12
|
+
'addToWaitlistForm'
|
13
|
+
]
|
14
|
+
static values = {
|
15
|
+
noCache: Boolean,
|
16
|
+
frameName: String,
|
17
|
+
optionsParamName: String,
|
18
|
+
requiredOptions: Array,
|
19
|
+
selectedVariantDisabled: Boolean,
|
20
|
+
variantFromOptionsDisabled: Boolean,
|
21
|
+
keepOptionsOpen: Boolean,
|
22
|
+
url: String,
|
23
|
+
disabled: Boolean
|
24
|
+
}
|
25
|
+
|
26
|
+
initialize() {
|
27
|
+
this.submitTargetHTML = this.submitTarget.innerHTML
|
28
|
+
}
|
29
|
+
|
30
|
+
connect() {
|
31
|
+
const selectedOptions = new Set()
|
32
|
+
this.optionTargets.forEach((option) => {
|
33
|
+
if (option.checked) {
|
34
|
+
selectedOptions.add(option.dataset.optionId)
|
35
|
+
}
|
36
|
+
})
|
37
|
+
const requiredOptions = new Set(this.requiredOptionsValue)
|
38
|
+
|
39
|
+
this.notSelectedOptions = [...requiredOptions].filter((x) => !selectedOptions.has(x))
|
40
|
+
if (this.notSelectedOptions.length) {
|
41
|
+
this.submitTargets.forEach((button) => button.addEventListener('click', this.showNotSelectedOptions))
|
42
|
+
}
|
43
|
+
if (this.hasAddToWishlistTarget && this.variantFromOptionsDisabledValue && this.notSelectedOptions.length === 0) {
|
44
|
+
this.addToWishlistTarget.disabled = true
|
45
|
+
}
|
46
|
+
|
47
|
+
if (this.hasDesktopMediaGalleryTarget && this.hasProductDetailsTarget) {
|
48
|
+
if (this.desktopMediaGalleryTarget.offsetHeight > 800) {
|
49
|
+
this.productDetailsTarget.classList.add('sticky')
|
50
|
+
const navHeight = document.querySelector('header.sticky')?.offsetHeight || 0
|
51
|
+
this.productDetailsTarget.style.top = `${navHeight}px`
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
this.formTarget.addEventListener('submit', this.disableSubmitButton)
|
56
|
+
this.submitTargets.forEach((button) => button.addEventListener('turbo-stream-form:submit-end', this.enableForm))
|
57
|
+
}
|
58
|
+
|
59
|
+
disconnect() {
|
60
|
+
this.submitTargets.forEach((button) => button.removeEventListener('click', this.showNotSelectedOptions))
|
61
|
+
}
|
62
|
+
|
63
|
+
showNotSelectedOptions = (e) => {
|
64
|
+
e.preventDefault()
|
65
|
+
|
66
|
+
this.notSelectedOptions.forEach((option, index) => {
|
67
|
+
const fieldSetElement = this.element.querySelector(`[data-option-id="${option}"]`)
|
68
|
+
if (index === 0) {
|
69
|
+
const toggleElement = fieldSetElement.querySelector('[data-controller="dropdown"]')
|
70
|
+
if (toggleElement) {
|
71
|
+
toggleElement.dataset.dropdownOpenValue = true
|
72
|
+
e.stopImmediatePropagation()
|
73
|
+
}
|
74
|
+
fieldSetElement.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' })
|
75
|
+
}
|
76
|
+
})
|
77
|
+
|
78
|
+
this.keepOptionsOpenValue = true
|
79
|
+
}
|
80
|
+
|
81
|
+
// reload turbo frame when option is selected
|
82
|
+
updateVariant(_event) {
|
83
|
+
this.submitTarget.disabled = true
|
84
|
+
|
85
|
+
const selectedOptions = []
|
86
|
+
|
87
|
+
this.optionTargets.forEach((option) => {
|
88
|
+
if (option.checked) {
|
89
|
+
selectedOptions.push(`${option.dataset.optionId}:${option.value}`)
|
90
|
+
}
|
91
|
+
})
|
92
|
+
|
93
|
+
const url = new URL(this.urlValue.length ? this.urlValue : window.location.href)
|
94
|
+
if (this.optionsParamNameValue?.length) {
|
95
|
+
url.searchParams.append(this.optionsParamNameValue, selectedOptions.join(','))
|
96
|
+
} else {
|
97
|
+
url.searchParams.append('options', selectedOptions.join(','))
|
98
|
+
}
|
99
|
+
|
100
|
+
if (this.noCacheValue) {
|
101
|
+
url.searchParams.append('no_cache', true)
|
102
|
+
}
|
103
|
+
|
104
|
+
if (this.frameNameValue?.length) {
|
105
|
+
Array.from(document.querySelectorAll(`turbo-frame#${this.frameNameValue}`)).forEach((frame) =>
|
106
|
+
frame.setAttribute('src', url)
|
107
|
+
)
|
108
|
+
} else {
|
109
|
+
window.Turbo.visit(url, { frame: 'main-product' })
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
disabledValueChanged() {
|
114
|
+
if (this.disabledValue) {
|
115
|
+
this.submitTarget.disabled = true
|
116
|
+
this.submitTarget.innerHTML = this.spinnerTemplateTarget.innerHTML
|
117
|
+
} else {
|
118
|
+
this.submitTarget.innerHTML = this.submitTargetHTML
|
119
|
+
this.submitTarget.disabled = false
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
disableSubmitButton = () => {
|
124
|
+
this.disabledValue = true
|
125
|
+
}
|
126
|
+
|
127
|
+
changeCartToken = (e) => {
|
128
|
+
if (this.tokenInput) {
|
129
|
+
this.tokenInput.value = e.detail.cartToken
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
enableForm = () => {
|
134
|
+
this.disabledValue = false
|
135
|
+
}
|
136
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = [ 'quantity', 'increase', 'decrease' ]
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
if (this.quantity <= 1) this.disableButton(this.decreaseTarget)
|
8
|
+
}
|
9
|
+
|
10
|
+
get quantity() {
|
11
|
+
return parseInt(this.quantityTarget.value) || 1
|
12
|
+
}
|
13
|
+
|
14
|
+
get maxQuantity() {
|
15
|
+
return parseInt(this.quantityTarget.max) || 9999
|
16
|
+
}
|
17
|
+
|
18
|
+
set quantity(value) {
|
19
|
+
this.quantityTarget.value = parseInt(value) || 1
|
20
|
+
}
|
21
|
+
|
22
|
+
increase() {
|
23
|
+
if (this.quantity < this.maxQuantity) this.quantity = this.quantity + 1
|
24
|
+
if (this.quantity > 1) this.enableButton(this.decreaseTarget)
|
25
|
+
if (this.quantity == this.maxQuantity && this.increaseTarget.type != 'submit') this.disableButton(this.increaseTarget)
|
26
|
+
}
|
27
|
+
|
28
|
+
decrease() {
|
29
|
+
if (this.quantity > 1) this.quantity = this.quantity - 1
|
30
|
+
if (this.quantity == 1 && this.decreaseTarget.type != 'submit') this.disableButton(this.decreaseTarget)
|
31
|
+
if (this.quantity < this.maxQuantity) this.enableButton(this.increaseTarget)
|
32
|
+
}
|
33
|
+
|
34
|
+
disableButton(button) {
|
35
|
+
button.setAttribute('disabled', 'disabled')
|
36
|
+
button.classList.add('opacity-50', 'cursor-not-allowed')
|
37
|
+
}
|
38
|
+
|
39
|
+
enableButton(button) {
|
40
|
+
button.removeAttribute('disabled')
|
41
|
+
button.classList.remove('opacity-50', 'cursor-not-allowed')
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import { get } from '@rails/request.js'
|
3
|
+
import debounce from 'spree/core/helpers/debounce'
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static targets = ['input']
|
7
|
+
static values = {
|
8
|
+
url: String
|
9
|
+
}
|
10
|
+
|
11
|
+
connect() {
|
12
|
+
this.debouncedQuerySuggestions = debounce(this.querySuggestions)
|
13
|
+
this.inputTarget.addEventListener('input', this.debouncedQuerySuggestions)
|
14
|
+
this.openSearchButton = document.querySelector('#open-search')
|
15
|
+
this.openSearchButton.addEventListener('click', this.show)
|
16
|
+
|
17
|
+
this.searchSuggestionsContainer = document.querySelector('#search-suggestions')
|
18
|
+
this.searchSuggestionsContent = this.searchSuggestionsContainer.querySelector('#search-suggestions-content')
|
19
|
+
this.loadingHTML = this.searchSuggestionsContainer.querySelector('template#loading').innerHTML
|
20
|
+
Turbo.StreamActions[`search-suggestions:close`] = this.remoteClose(this)
|
21
|
+
}
|
22
|
+
|
23
|
+
remoteClose = (controller) => {
|
24
|
+
return function () {
|
25
|
+
controller.hide()
|
26
|
+
}
|
27
|
+
}
|
28
|
+
disconnect() {
|
29
|
+
delete Turbo.StreamActions[`search-suggestions:close`]
|
30
|
+
this.hide()
|
31
|
+
this.inputTarget.removeEventListener('input', this.debouncedQuerySuggestions)
|
32
|
+
this.openSearchButton.removeEventListener('click', this.show)
|
33
|
+
}
|
34
|
+
hide = () => {
|
35
|
+
this.searchSuggestionsContainer.style.display = 'none'
|
36
|
+
}
|
37
|
+
clear = () => {
|
38
|
+
this.searchSuggestionsContent.innerHTML = ''
|
39
|
+
this.searchSuggestionsContent.classList.remove(...this.searchSuggestionsContent.dataset.showClass.split(' '))
|
40
|
+
this.searchSuggestionsContent.classList.add('hidden')
|
41
|
+
this.element.classList.remove(...this.element.dataset.showClass.split(' '))
|
42
|
+
}
|
43
|
+
show = () => {
|
44
|
+
this.searchSuggestionsContainer.style.display = 'block'
|
45
|
+
this.inputTarget.focus()
|
46
|
+
const oldInputValue = this.inputTarget.value
|
47
|
+
this.inputTarget.value = ''
|
48
|
+
this.inputTarget.value = oldInputValue
|
49
|
+
}
|
50
|
+
querySuggestions = async () => {
|
51
|
+
if (this.inputTarget.value.length >= 3 && this.inputTarget.value.trim().length) {
|
52
|
+
this.searchSuggestionsContent.innerHTML = this.loadingHTML
|
53
|
+
this.searchSuggestionsContent.classList.remove('hidden')
|
54
|
+
this.searchSuggestionsContent.classList.add(...this.searchSuggestionsContent.dataset.showClass.split(' '))
|
55
|
+
this.element.classList.add(...this.element.dataset.showClass.split(' '))
|
56
|
+
await get(`${this.urlValue}?q=${this.inputTarget.value}`, {
|
57
|
+
responseKind: 'turbo-stream'
|
58
|
+
})
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['input', 'item']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.inputTarget.addEventListener('input', this.filter)
|
8
|
+
}
|
9
|
+
|
10
|
+
disconnect() {
|
11
|
+
this.inputTarget.removeEventListener('input', this.filter)
|
12
|
+
}
|
13
|
+
|
14
|
+
filter = () => {
|
15
|
+
const query = this.inputTarget.value.toLowerCase()
|
16
|
+
this.itemTargets.forEach((el) => {
|
17
|
+
const text = el.dataset.text.toLowerCase()
|
18
|
+
if (text.includes(query)) {
|
19
|
+
el.classList.remove('hidden')
|
20
|
+
} else {
|
21
|
+
el.classList.add('hidden')
|
22
|
+
}
|
23
|
+
})
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { Slideover } from 'tailwindcss-stimulus-components'
|
2
|
+
import { lockScroll, unlockScroll } from 'spree/core/helpers/scroll_lock'
|
3
|
+
export default class extends Slideover {
|
4
|
+
connect() {
|
5
|
+
Turbo.StreamActions[`${this.identifier}:open`] = this.remoteOpen(this)
|
6
|
+
super.connect()
|
7
|
+
}
|
8
|
+
|
9
|
+
disconnect() {
|
10
|
+
super.disconnect()
|
11
|
+
delete Turbo.StreamActions[`${this.identifier}:open`]
|
12
|
+
}
|
13
|
+
|
14
|
+
remoteOpen(controller) {
|
15
|
+
return function () {
|
16
|
+
if (this.target === controller.overlayTarget.id) {
|
17
|
+
controller.openValue = true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
_show() {
|
23
|
+
const headerController = this.application.getControllerForElementAndIdentifier(this.element, 'header')
|
24
|
+
headerController?.freeze() // If there is a header controller, freeze it, so it doesn't move when the slideover opens
|
25
|
+
|
26
|
+
super._show()
|
27
|
+
|
28
|
+
// Don't scroll the background when slideover is open
|
29
|
+
lockScroll()
|
30
|
+
}
|
31
|
+
|
32
|
+
_hide() {
|
33
|
+
const headerController = this.application.getControllerForElementAndIdentifier(this.element, 'header')
|
34
|
+
headerController?.unfreeze()
|
35
|
+
|
36
|
+
super._hide()
|
37
|
+
// Restore the background scroll
|
38
|
+
unlockScroll()
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ['stickyButton', 'fixedButton']
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
if (!this.hasFixedButtonTarget) return
|
8
|
+
|
9
|
+
this.handleScroll()
|
10
|
+
|
11
|
+
const header = document.querySelector('header.sticky')
|
12
|
+
|
13
|
+
this.navHeight = header ? header.offsetHeight : 0
|
14
|
+
window.addEventListener('scroll', this.handleScroll, true)
|
15
|
+
}
|
16
|
+
|
17
|
+
disconnect() {
|
18
|
+
window.removeEventListener('scroll', this.handleScroll)
|
19
|
+
}
|
20
|
+
|
21
|
+
handleScroll = () => {
|
22
|
+
const button = this.stickyButtonTarget
|
23
|
+
const top = button.getBoundingClientRect().top
|
24
|
+
const fixedButton = this.fixedButtonTarget
|
25
|
+
|
26
|
+
if (top < this.navHeight || top > window.innerHeight) {
|
27
|
+
fixedButton.classList.remove('hidden')
|
28
|
+
} else {
|
29
|
+
fixedButton.classList.add('hidden')
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Toggle } from 'tailwindcss-stimulus-components'
|
2
|
+
import { lockScroll, unlockScroll } from 'spree/core/helpers/scroll_lock'
|
3
|
+
|
4
|
+
export default class ToggleMenu extends Toggle {
|
5
|
+
static targets = ['toggleable', 'content', 'button']
|
6
|
+
static values = ['open']
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
super.connect()
|
10
|
+
}
|
11
|
+
|
12
|
+
hide(e) {
|
13
|
+
if (this.openValue) {
|
14
|
+
super.hide(e)
|
15
|
+
this.buttonTarget.classList.remove('menu-open')
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
toggle(e) {
|
20
|
+
this.contentTarget.style.paddingBottom = `${this.contentTarget.offsetTop}px`
|
21
|
+
super.toggle(e)
|
22
|
+
if (this.openValue) {
|
23
|
+
this.buttonTarget.classList.add('menu-open')
|
24
|
+
setTimeout(() => {
|
25
|
+
lockScroll()
|
26
|
+
}, 0)
|
27
|
+
} else {
|
28
|
+
this.buttonTarget.classList.remove('menu-open')
|
29
|
+
unlockScroll()
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import { FetchRequest } from '@rails/request.js'
|
3
|
+
|
4
|
+
// This controller is needed if you have many forms that are using turbo and can be submitted in rapid succession.
|
5
|
+
// Turbo by default will cancel all the previous requests and only submit the last one,
|
6
|
+
// but server side you will still receive all the requests and process them.
|
7
|
+
// And since the request was cancelled, turbo will not process the response.
|
8
|
+
// So this may lead to desync between the UI and the server.
|
9
|
+
// GH issue: https://github.com/hotwired/turbo-rails/issues/310
|
10
|
+
// Code that causes issue: https://github.com/hotwired/turbo/blob/main/src/core/drive/navigator.js#L32
|
11
|
+
export default class extends Controller {
|
12
|
+
connect() {
|
13
|
+
this.element.addEventListener('submit', this.handleSubmit)
|
14
|
+
this.submitElements = this.element.querySelectorAll('[type="submit"]')
|
15
|
+
}
|
16
|
+
|
17
|
+
disconnect() {
|
18
|
+
this.element.removeEventListener('submit', this.handleSubmit)
|
19
|
+
}
|
20
|
+
|
21
|
+
handleSubmit = async (event) => {
|
22
|
+
event.preventDefault()
|
23
|
+
|
24
|
+
const form = event.target
|
25
|
+
const url = form.action
|
26
|
+
const method = form.method
|
27
|
+
const body = new FormData(form)
|
28
|
+
const headers = {}
|
29
|
+
|
30
|
+
const request = new FetchRequest(method, url, {
|
31
|
+
body: body,
|
32
|
+
headers: headers,
|
33
|
+
responseKind: 'turbo-stream'
|
34
|
+
})
|
35
|
+
|
36
|
+
this.submitElements.forEach((element) => {
|
37
|
+
element.disabled = true
|
38
|
+
})
|
39
|
+
form.ariaBusy = true
|
40
|
+
|
41
|
+
await request.perform()
|
42
|
+
|
43
|
+
const submitEndEvent = new Event('turbo-stream-form:submit-end')
|
44
|
+
|
45
|
+
this.submitElements.forEach((element) => {
|
46
|
+
element.disabled = false
|
47
|
+
element.dispatchEvent(submitEndEvent)
|
48
|
+
})
|
49
|
+
form.ariaBusy = false
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
// this is a super simple controller to control the state of the add to wishlist icon state
|
2
|
+
|
3
|
+
import { Controller } from '@hotwired/stimulus'
|
4
|
+
import { post, destroy } from '@rails/request.js'
|
5
|
+
export default class extends Controller {
|
6
|
+
static targets = ['add', 'remove']
|
7
|
+
static values = {
|
8
|
+
variantId: String,
|
9
|
+
}
|
10
|
+
|
11
|
+
connect() {
|
12
|
+
const wishedVariantIds = window.wishedVariantIds || [];
|
13
|
+
const variantId = this.variantIdValue;
|
14
|
+
|
15
|
+
if (wishedVariantIds.includes(variantId)) {
|
16
|
+
this.showRemoveButton();
|
17
|
+
} else {
|
18
|
+
this.showAddButton();
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
add = async (event) => {
|
23
|
+
event.preventDefault()
|
24
|
+
|
25
|
+
const body = new FormData()
|
26
|
+
body.append('wished_item[variant_id]', this.variantIdValue)
|
27
|
+
|
28
|
+
const headers = {}
|
29
|
+
|
30
|
+
const response = await post('/account/wishlist/wished_items', {
|
31
|
+
body: body,
|
32
|
+
headers: headers,
|
33
|
+
responseKind: 'turbo-stream'
|
34
|
+
})
|
35
|
+
if (response.ok) {
|
36
|
+
this.showRemoveButton();
|
37
|
+
} else {
|
38
|
+
console.error('Error adding item to wishlist');
|
39
|
+
window.alert('Error adding item to wishlist');
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
remove = async (event) => {
|
44
|
+
event.preventDefault()
|
45
|
+
|
46
|
+
const headers = {}
|
47
|
+
|
48
|
+
const response = await destroy(`/account/wishlist/wished_items/${this.variantIdValue}`, {
|
49
|
+
headers: headers,
|
50
|
+
responseKind: 'turbo-stream'
|
51
|
+
})
|
52
|
+
if (response.ok) {
|
53
|
+
this.showAddButton();
|
54
|
+
} else {
|
55
|
+
console.error('Error removing item from wishlist');
|
56
|
+
window.alert('Error removing item from wishlist');
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
showAddButton() {
|
61
|
+
this.addTarget.classList.remove('hidden');
|
62
|
+
this.removeTarget.classList.add('hidden');
|
63
|
+
}
|
64
|
+
|
65
|
+
showRemoveButton() {
|
66
|
+
this.addTarget.classList.add('hidden');
|
67
|
+
this.removeTarget.classList.remove('hidden');
|
68
|
+
}
|
69
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
const controllerAttribute = "data-controller"
|
2
|
+
|
3
|
+
// This function is based on `lazyLoadControllersFrom` function from Stimulus.
|
4
|
+
// https://github.com/hotwired/stimulus-rails/blob/main/app/assets/javascripts/stimulus-loading.js
|
5
|
+
// We need to slightly modify it to fit our needs, mostly to make allow list of controllers to be loaded and to use manifest when controller is not in the controllers directory.
|
6
|
+
// More information about what is `manifest` and what are `controllers` can be found in the `application.js` file.
|
7
|
+
|
8
|
+
export function lazyLoadControllersFromManifest(controllers, under, application, manifest = {}, element = document) {
|
9
|
+
lazyLoadExistingControllers(controllers, under, application, manifest, element)
|
10
|
+
lazyLoadNewControllers(controllers, under, application, manifest, element)
|
11
|
+
}
|
12
|
+
|
13
|
+
function lazyLoadExistingControllers(controllers, under, application, manifest, element) {
|
14
|
+
queryControllerNamesWithin(element).forEach(controllerName => {
|
15
|
+
if (controllers.includes(controllerName)) {
|
16
|
+
loadController(controllerName, under, application, manifest)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
)
|
20
|
+
}
|
21
|
+
|
22
|
+
function lazyLoadNewControllers(controllers, under, application, manifest, element) {
|
23
|
+
new MutationObserver((mutationsList) => {
|
24
|
+
for (const { attributeName, target, type } of mutationsList) {
|
25
|
+
switch (type) {
|
26
|
+
case "attributes": {
|
27
|
+
if (attributeName == controllerAttribute && target.getAttribute(controllerAttribute)) {
|
28
|
+
extractControllerNamesFrom(target).forEach(controllerName => {
|
29
|
+
if (controllers.includes(controllerName)) {
|
30
|
+
loadController(controllerName, under, application, manifest)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
)
|
34
|
+
}
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
|
38
|
+
case "childList": {
|
39
|
+
lazyLoadExistingControllers(controllers, under, application, manifest, target)
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}).observe(element, { attributeFilter: [controllerAttribute], subtree: true, childList: true })
|
45
|
+
}
|
46
|
+
|
47
|
+
function queryControllerNamesWithin(element) {
|
48
|
+
return Array.from(element.querySelectorAll(`[${controllerAttribute}]`)).map(extractControllerNamesFrom).flat()
|
49
|
+
}
|
50
|
+
|
51
|
+
function extractControllerNamesFrom(element) {
|
52
|
+
return element.getAttribute(controllerAttribute).split(/\s+/).filter(content => content.length)
|
53
|
+
}
|
54
|
+
|
55
|
+
function loadController(name, under, application, manifest) {
|
56
|
+
if (canRegisterController(name, application)) {
|
57
|
+
import(controllerFilename(name, under, manifest))
|
58
|
+
.then(module => registerController(name, module, application))
|
59
|
+
.catch(error => console.error(`Failed to autoload controller: ${name}`, error))
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
function controllerFilename(name, under, manifest) {
|
64
|
+
if (manifest && manifest[name]) {
|
65
|
+
return manifest[name]
|
66
|
+
}
|
67
|
+
return `${under}/${name.replace(/--/g, "/").replace(/-/g, "_")}_controller`
|
68
|
+
}
|
69
|
+
|
70
|
+
function registerController(name, module, application) {
|
71
|
+
if (canRegisterController(name, application)) {
|
72
|
+
application.register(name, module.default)
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
function canRegisterController(name, application) {
|
77
|
+
return !application.router.modulesByIdentifier.has(name)
|
78
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
const FLASH_CLASSES = {
|
2
|
+
notice: ['alert-notice'],
|
3
|
+
success: ['alert-success'],
|
4
|
+
error: ['alert-error']
|
5
|
+
}
|
6
|
+
|
7
|
+
export default function showFlashMessage(messageText, type = 'notice') {
|
8
|
+
const flashesContainer = document.querySelector('#flashes')
|
9
|
+
const flashTemplate = document.querySelector('#flashMessage')
|
10
|
+
|
11
|
+
// prevent alerts duplication
|
12
|
+
flashesContainer.querySelectorAll('.flash-message').forEach(el => {
|
13
|
+
if (el.textContent === messageText) {
|
14
|
+
el.closest('[data-controller="alert"]').querySelector('[data-action="alert#close"]').click()
|
15
|
+
}
|
16
|
+
})
|
17
|
+
|
18
|
+
const newFlash = flashTemplate.content.cloneNode(true)
|
19
|
+
newFlash.querySelector('.flash-message').textContent = messageText
|
20
|
+
newFlash
|
21
|
+
.querySelector('[data-controller="alert"]')
|
22
|
+
.classList.add(...FLASH_CLASSES[type])
|
23
|
+
|
24
|
+
flashesContainer.appendChild(newFlash)
|
25
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Spree
|
2
|
+
class ColorNames
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def colors
|
7
|
+
@colors ||= Rails.cache.fetch('color_names', expires_in: 1.day) do
|
8
|
+
file_path = File.join(Spree::Storefront::Engine.root, 'vendor', 'colornames.json')
|
9
|
+
|
10
|
+
if File.exist?(file_path)
|
11
|
+
JSON.parse(File.read(file_path))
|
12
|
+
else
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def colors_cache
|
19
|
+
@colors_cache ||= colors.inject({}) do |hash, color|
|
20
|
+
hash[color['name'].downcase] = color
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_by_name(name)
|
26
|
+
colors_cache[name.downcase]
|
27
|
+
end
|
28
|
+
|
29
|
+
def split_by_color_name(name)
|
30
|
+
multi_color_regex = /(\s+and\s+|\s*-\s*|\s*&\s*|\s*\+\s*|\s*\/\s*)/
|
31
|
+
name.gsub(multi_color_regex, ',').split(',').map(&:strip)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
class Contact < MailForm::Base
|
3
|
+
attribute :name, validate: true
|
4
|
+
attribute :email, validate: /\A([\w.%+\-]+)@([\w\-]+\.)+(\w{2,})\z/i
|
5
|
+
attribute :message, validate: true
|
6
|
+
attribute :customer_support_email, validate: :customer_support_email_bug?
|
7
|
+
|
8
|
+
def headers
|
9
|
+
{
|
10
|
+
subject: 'Contact Us',
|
11
|
+
to: customer_support_email.to_s,
|
12
|
+
from: %("#{name}" <#{email}>)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def customer_support_email_bug?
|
17
|
+
errors.add(:customer_support_email, 'is not there') if customer_support_email.nil? || customer_support_email.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](key)
|
21
|
+
send(key)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|