]> _ Git - pmi.git/commitdiff
wip #3505 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 Mar 2020 15:43:52 +0000 (16:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 Mar 2020 15:43:52 +0000 (16:43 +0100)
app/Providers/AppServiceProvider.php
package.json
resources/js/app.js
resources/js/components/CartAdd.vue [deleted file]
resources/js/components/ProductsFilters.vue
resources/views/components/cart-add.blade.php [new file with mode: 0644]
resources/views/pages/product-detail.blade.php
resources/views/partials/product-link.blade.php

index da285a9cbbe6d28386682aebc62f444d7b7b790c..0c9d8819e1bacc1a12f67283da2b691419223208 100644 (file)
@@ -54,6 +54,7 @@ class AppServiceProvider extends ServiceProvider
             BladeX::component('components.map-link'); // <map-link address="..."> ... </map-link>
             BladeX::component('components.phone-link'); // <phone-link number="012345"> ... </phone-link>
             BladeX::component('components.text-block'); // <text-block> ... </text-block>
+            BladeX::component('components.cart-add')->tag('cart-add'); // <cart-add id="1234"> ... </cart-add>
         } catch (\Exception $e) {
 
         }
index ed72d3d885f8f4855f6ac1a45e1e60a4adcec75b..c93b5897709892d238379e58f2d9d2c41fa755bc 100644 (file)
@@ -33,7 +33,7 @@
         "modernizr-webpack-plugin": "^1.0.7",
         "polyfill-array-includes": "^2.0.0",
         "popper.js": "^1.12",
-        "portal-vue": "^2.1.5",
+        "portal-vue": "^2.1.7",
         "resolve-url-loader": "^2.3.1",
         "rupture": "^0.7.1",
         "stylus": "github:acidjazz/stylus#dev",
index 4158d8481c1df853d5356b7a7b4c5ebcf1ee7edf..8bad322539edee78535fe19cc51b3e5f03b46e73 100644 (file)
@@ -8,6 +8,7 @@ require('./bootstrap');
 require('./menu');
 require('../../vendor/cubist/cms-back/src/public/emailobfuscator/emailobfuscator');
 require('element-closest');
+window.$ = require('cash-dom');
 
 // Polyfill CSS Vars for older browsers
 // This is only partly useful because we need to update CSS variables
@@ -179,3 +180,15 @@ function checkScroll() {
 }
 
 checkScroll();
+
+$(document).on('click', 'button.cart-add', function () {
+    $(this).addClass('btn-no-hover').addClass('bg-navy');
+    $(this).find('.add').addClass('opacity-0');
+    $(this).find('.added').show();
+    var id = parseInt($(this).attr('data-product-id'));
+    eventBus.$emit('add-item', {
+        id: id,
+        quantity: 1,
+    });
+});
+
diff --git a/resources/js/components/CartAdd.vue b/resources/js/components/CartAdd.vue
deleted file mode 100644 (file)
index 140e893..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<template>
-    <button class="btn" @click="addToCart" :class="{'btn-no-hover bg-navy' : isAdded }" :disabled="isAdded">
-        <span class="btn-text relative">
-            <span :class="{'opacity-0': isAdded}">
-                <slot></slot>
-            </span>
-            <span class="absolute top-0 left-0 w-full h-full flex items-center justify-center" v-if="isAdded">
-                <slot name="success-message"></slot>
-            </span>
-        </span>
-    </button>
-</template>
-
-<script>
-
-    export default {
-        name: "CartAdd",
-
-        props: {
-            productId: {
-                type: Number,
-                required: true,
-            }
-        },
-
-        data() {
-            return {
-                isAdded: false,
-            };
-        },
-
-        methods: {
-            addToCart() {
-                console.warn(':)');
-                eventBus.$emit('add-item', {
-                    id: this.productId,
-                    quantity: 1,
-                });
-                this.isAdded = true;
-            }
-        }
-    }
-</script>
-
-<style scoped>
-
-</style>
index 334d42a0729a1ce1f6a1ac7cdbd3e501f75a1b7c..9d5f48ae4fd807d881e3eddc69bf8f1c6d7cf8cf 100644 (file)
             <!-- Product Grid -->
             <div class="grid grid-cols-auto grid-gap-lg products-grid mt-6 sm:mt-2">
                 <template v-for="product in products" v-if="productVisible(product.id)">
-                    <div v-html="product.html"></div>
+                    <div v-html="product.html" @click="productLoaded(product.id)"></div>
                 </template>
             </div>
 
     import 'ie-array-find-polyfill'
     import 'es7-object-polyfill'
     import VueSlider from 'vue-slider-component' // See vue-slider.styl for CSS
-    import CartAdd from "./CartAdd";
 
 
     export default {
 
         components: {
-            VueSlider,
-            CartAdd
+            VueSlider
         },
 
         props: {
                 if (child.tag) { // Ensure it's a tag and not an empty text element
                     let product = child.elm;
                     let ID = parseInt(product.dataset.productId);
-
                     this.products.push({id: ID, html: product.outerHTML});
                 }
             });
                 return Object.values(this.matches.hits).includes(id)
             },
 
+            productLoaded(id) {
+                console.log(id + ' loaded');
+            },
+
             removeFilter(filterID, optionID) {
                 let index = this.filters[filterID].indexOf(optionID);
 
diff --git a/resources/views/components/cart-add.blade.php b/resources/views/components/cart-add.blade.php
new file mode 100644 (file)
index 0000000..54fe378
--- /dev/null
@@ -0,0 +1,10 @@
+<button data-product-id="{{ $id }}" class="btn cart-add">
+        <span class="btn-text relative">
+            <span class="add">
+               {{ __('Ajouter à ma sélection') }}
+            </span>
+            <span class="added absolute top-0 left-0 w-full h-full flex items-center justify-ce hidden">
+                @svg('tick', 'w-4 mr-3 inline absolute left-0') <span class="relative" style="top:-15%">{{ __('Produit ajouté') }}</span>
+            </span>
+        </span>
+</button>
index 75be0b8726f57c5d185b2f60c003277d8562909f..1cc2c8725da9e983a1088821a577e60884adf7d6 100644 (file)
 
 
                 @if(config('features.quote'))
-                    <cart-add :product-id="{{ $product->id }}" class="align-middle">
-                        {{ __('Ajouter à ma sélection') }}
-
-                        <template v-slot:success-message>
-                            @svg('tick', 'w-4 mr-3') {{ __('Produit ajouté') }}
-                        </template>
-                    </cart-add>
-
-                    <span data-tooltip="{{__('Ajoutez un ou plusieurs produits à votre sélection, ajustez les quantités et obtenez un devis.')}}"
+                    <cart-add :id="$product->id"></cart-add>
+                    <span
+                        data-tooltip="{{__('Ajoutez un ou plusieurs produits à votre sélection, ajustez les quantités et obtenez un devis.')}}"
                         class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-6">?</span>
                 @endif
 
index cf176701b7142c339841cb9353a384c7e3fcf33e..d7172452120810fedb5d26841cf1d398c07dfa77 100644 (file)
         </h3>
         <div class="product-highlights text-sm">
             @if(config('features.quote'))
-                <cart-add :product-id="{{ $product->id }}" class="align-middle">
-                    {{ __('Ajouter à ma sélection') }}
-                    <template v-slot:success-message>
-                        @svg('tick', 'w-4 mr-3') {{ __('Produit ajouté') }}
-                    </template>
-                </cart-add>
+                <cart-add :id="$product->id"></cart-add>
             @endif
         </div>
         <div class="links mt-4">