Skip to content

Commit

Permalink
Merge pull request #51 from thelia/feat/checkout
Browse files Browse the repository at this point in the history
Feat/checkout
  • Loading branch information
leanormandon authored Aug 29, 2024
2 parents 731875e + 861bd41 commit fb758ce
Show file tree
Hide file tree
Showing 28 changed files with 5,815 additions and 2,329 deletions.
17 changes: 11 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"root": true,
"parser": "@babel/eslint-parser",
"extends": [
"react-app",
"plugin:storybook/recommended"
]
"root": true,
"parser": "@babel/eslint-parser",
"extends": [
"react-app"
],
"rules": {
"semi": [
2,
"always"
]
}
}
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const config: StorybookConfig = {
alias: {
...config.resolve?.alias,
'@components': path.resolve(__dirname, '../components'),
'@react': path.resolve(__dirname, '../react-components'),
'@icons': path.resolve(__dirname, '../assets/icons')
}
};
Expand Down
7 changes: 2 additions & 5 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
// any CSS you import will output into a single css file (app.css in this case)
import '../components/base.css';


import HeaderScript from '../components/Layout/Header/Header.js';
import MobileDrawer from "./js/mobileDrawer";
import filterSelectFunction from "../components/Molecules/Filters/FilterSelect/FilterSelect";
import {quantityButton} from "../components/Molecules/Button/button";
import {slider} from "./js/slider";
import ProductGallery from "../components/Layout/ProductGallery/ProductGallery";
import {quantityButton} from "@components/Molecules/Button/button";
import {slider} from "@js/slider";

function main() {
document.body.classList.remove('no-js');
Expand All @@ -23,7 +21,6 @@ function main() {
filterSelectFunction();
quantityButton();
slider();
ProductGallery();
}

document.addEventListener('DOMContentLoaded', () => {
Expand Down
14 changes: 14 additions & 0 deletions assets/js/mobileDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default function MobileDrawer() {
const toggleDrawers = document.querySelectorAll('[data-drawer-toggle]');
const closeDrawers = document.querySelectorAll('[data-drawer-close]');
const drawers = document.querySelectorAll('.MobileDrawer');
const drawerOptions = document.querySelectorAll('.FilterSelect-option');

toggleDrawers.forEach(function (drawer) {
drawer.addEventListener('click', () => {
Expand All @@ -14,7 +15,10 @@ export default function MobileDrawer() {
});
closeDrawers.forEach(function (drawer) {
drawer.addEventListener('click', () => {
console.log({drawer});
const parent = drawer.closest('.MobileDrawer');
console.log({parent});

if (!parent) return;
closeDrawer(parent);
});
Expand All @@ -37,6 +41,14 @@ export default function MobileDrawer() {
}
});
});
drawerOptions.forEach(function (option) {
option.addEventListener('click', function () {
const parentDrawer = option.closest('.MobileDrawer');
if (parentDrawer) {
closeDrawer(parentDrawer);
}
});
});
}

function openDrawer(currentDrawer) {
Expand All @@ -56,5 +68,7 @@ function toggleOverlay(open) {
document.body.prepend(div);
return;
}

console.log('close overlays');
document.querySelector('.MobileDrawer-overlay').remove();
}
3 changes: 3 additions & 0 deletions assets/js/routes/checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Checkout from '@react/Layout/Checkout';

Checkout();
5 changes: 5 additions & 0 deletions assets/js/routes/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ProductGallery from "@components/Layout/ProductGallery/ProductGallery";
import PseSelectorRoot from "@react/Layout/PseSelector/PseSelector";

ProductGallery();
PseSelectorRoot();
1 change: 1 addition & 0 deletions assets/js/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function slider() {
isDown = false;
slider.classList.remove('active');
}

function move(e, pageX, slider)
{
if (!isDown) return;
Expand Down
3 changes: 3 additions & 0 deletions changelog-checkout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog Checkout

- Reprise de la structure générale de CHR
23 changes: 23 additions & 0 deletions checkout.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends 'base.html.twig' %}

{% block title %}
Tunnel d'achat
{% endblock %}

{% block javascripts %}
{{ encore_entry_script_tags('checkout') }}
{% endblock %}

{% block header %}
{% include '@components/Layout/Header/HeaderCheckout.twig' %}
{% endblock %}
{% block body %}
{% set products = resources('/api/front/products', {'productCategories.category.id':1, itemsPerPage:3}) %}
<div id="Checkout"></div>
<div class="bg-theme-lighter">
{% include '@components/Layout/CrossSelling/CrossSelling.twig' with {products: products, title: 'Consultés récemment'} %}
</div>
{% endblock %}
{% block footer %}
{% include '@components/Layout/Footer/FooterCheckout.twig' %}
{% endblock %}
2 changes: 1 addition & 1 deletion components/Layout/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default () => {

const btn = document.getElementById('toggleMenu');

btn.addEventListener('click', () =>
btn?.addEventListener('click', () =>
document.getElementById('Menu').classList.toggle('is-open')
);
};
Expand Down
16 changes: 16 additions & 0 deletions components/Layout/ProductGallery/ProductGallery.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

{% set images = resources('/api/front/product_images', {'product.id':productId}) %}
{% if images %}
{% set imgId = images|first.id %}
{% endif %}

<ul class="absolute top-0 left-0 md:transform-none hidden -translate-x-full lg:translate-x-0 sm:block">
{% for image in images %}
<li class="ProductGallery-item cursor-pointer{% if loop.index== 1 %} is-active{% endif %}">
<img class="ProductGallery-thumbnail" data-image-id="{{ image.id }}" src="{{ "/legacy-image-library/product_image_"~image.id~"/full/%5E*!92,92/0/default.webp"}}" loading="lazy" />
</li>
{% endfor %}
</ul>
<div>
<img id="MainImage" src="{{ imgId ? "/legacy-image-library/product_image_"~imgId~"/full/%5E*!594,594/0/default.webp" : "@assets/images/placeholder2.webp"}}" loading="lazy" alt="{{ attr('product', 'title') }}"/>
</div>
1 change: 1 addition & 0 deletions components/Layout/ProductGallery/test.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Toto</p>
11 changes: 11 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module '*.svg' {
import * as React from 'react';

export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>;
}
interface Window {
PSES: import('@react/Layout/PseSelector/PseSelector.types').PSE[];
ATTRIBUTES: import('@react/Layout/PseSelector/PseSelector.types').Attribute[];
}
Loading

0 comments on commit fb758ce

Please sign in to comment.