Skip to content

Commit

Permalink
Cross Selling
Browse files Browse the repository at this point in the history
  • Loading branch information
leanormandon committed Jun 7, 2024
1 parent 0632e80 commit 2d7237f
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 7 deletions.
7 changes: 7 additions & 0 deletions assets/css/slider.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.slider {
cursor: grab;
user-select: none;
&:active {
cursor: grabbing;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function similarContent() {
export function slider() {
const slider = document.querySelector('.slider');
let isDown = false;
let startX;
Expand Down
39 changes: 39 additions & 0 deletions components/Layout/CrossSelling/CrossSelling.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import CrossSelling from './CrossSelling.twig';
import { slider } from '../../../assets/js/slider';

export default {
title: 'Design System/Layout/CrossSelling'
};

const standardProduct = {
productTitle: 'Nom du produit',
secondaryTitle: 'Titre secondaire',
price: '1000,00€',
promoPrice: '900,00€',
rate: 4,
isNew: true,
displayWishButton: true,
reviewCount: 12
};

const products = [];

for (let i = 0; i < 5; i++) {
products.push(standardProduct);
}

export const base = {
render: (args) => CrossSelling(args),
play: () => {
slider();
},
args: {
products,
title: 'Derniers produits consultés',
button: { href: '#', label: 'Tout voir' }
},
parameters: {
backgrounds: { default: 'grey' }
},
argTypes: {}
};
13 changes: 13 additions & 0 deletions components/Layout/CrossSelling/CrossSelling.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class='xl:container xl:mx-auto'>
<div class='h2 text-black pb-6'>{{ title }}</div>
</div>

<div class='CrossSelling slider'>
{% for product in products %}
{% include '../../Organisms/ProductCard/ProductCard.twig' with product %}
{% endfor %}
</div>

<div class='xl:container xl:mx-auto mt-5'>
{% include '../../Molecules/Button/Button.twig' with {text: button.label, href: button.href,icon_right:'chevron-right', variant:'secondary'} %}
</div>
35 changes: 35 additions & 0 deletions components/Layout/CrossSelling/crossSelling.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.CrossSelling {
display: flex;
gap: rem-convert(16px);
overflow: hidden;

.ProductCard {
flex-shrink: 0;
width: rem-convert(187px);
@screen md {
width: rem-convert(288px);
}
@screen lg {
width: rem-convert(288px);
}
}


@screen lg {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: rem-convert(24px);
cursor: initial;
.ProductCard {
width: initial;
&:active {
cursor: initial;
}
}
}

@screen xl {
@apply container mx-auto;
}

}
4 changes: 2 additions & 2 deletions components/Layout/SimilarContent/SimilarContent.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SimilarContent from './SimilarContent.twig';
import { similarContent } from './similarContent';
import { slider } from '../../../assets/js/slider';

export default {
title: 'Design System/Layout/SimilarContent'
Expand All @@ -24,7 +24,7 @@ export const base = {
button: { href: '#', label: 'Voir toutes les actualités' }
},
play: () => {
similarContent();
slider();
},
parameters: {
backgrounds: { default: 'grey' }
Expand Down
8 changes: 4 additions & 4 deletions components/Layout/SimilarContent/similarContent.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
@screen md {
flex-direction: row;
overflow: hidden;
cursor: grab;
&:active {
cursor: grabbing;
}
.SimilarContentCard {
width: 340px;
flex-shrink: 0;
Expand All @@ -20,10 +16,14 @@
cursor: initial;
.SimilarContentCard {
width: initial;
&:active {
cursor: initial;
}
}
}
@screen xl {
@apply container mx-auto;
gap: rem-convert(32px);
grid-template-columns: repeat(3, 1fr);
}

Expand Down

0 comments on commit 2d7237f

Please sign in to comment.