From 2f90c82d74a7cc1363e92122049c4c6c8ba517f9 Mon Sep 17 00:00:00 2001 From: K Muller Date: Wed, 8 Apr 2026 13:59:30 +0200 Subject: [PATCH] fix: :style: 0 lint error --- .stylelintcache | 1 - .../Middlewares/HandleInertiaRequests.php | 3 +- package-lock.json | 5 +- package.json | 4 +- resources/sass/common.scss | 3 +- resources/sass/common/wysiwyg.scss | 6 +- resources/sass/front/_fonts.scss | 74 +++-- resources/sass/front/app.scss | 16 +- resources/ts/app.tsx | 1 - .../ts/back/Components/Inputs/ModelSelect.tsx | 74 ++--- .../front/Components/Base/BreadCrumbsBase.tsx | 20 +- .../Components/Base/Carousel/Carousel.tsx | 8 +- .../Base/Carousel/CarouselContent.tsx | 120 +++---- .../ts/front/Components/Base/GoToTopBase.tsx | 25 +- .../Components/Base/Inputs/FilterDropdown.tsx | 103 +++--- .../Components/Base/Inputs/SearchInput.tsx | 26 +- .../Components/Base/Inputs/SimpleCheckbox.tsx | 6 +- .../Components/Base/Inputs/SimpleImage.tsx | 294 ----------------- .../front/Components/Base/RecaptchaForm.tsx | 113 ++++--- .../Components/Base/VideoEmbedWithConsent.tsx | 65 ++-- .../front/Components/DynamicPageResolver.tsx | 8 +- .../front/Components/Theme/ActionSection.tsx | 36 ++- .../ts/front/Components/Theme/BackToHome.tsx | 10 +- .../ts/front/Components/Theme/Breadcrumbs.tsx | 10 +- .../ts/front/Components/Theme/Button.tsx | 107 ++++--- .../ts/front/Components/Theme/Container.tsx | 3 +- .../Components/Theme/CookieNoticeLink.tsx | 18 +- .../ts/front/Components/Theme/Footer.tsx | 32 +- .../ts/front/Components/Theme/GoToTop.tsx | 86 +++-- .../Components/Theme/Header/DesktopNav.tsx | 99 +++--- .../Theme/Header/GoToSearchPage.tsx | 11 +- .../front/Components/Theme/Header/Header.tsx | 29 +- .../Components/Theme/Header/MobileNav.tsx | 31 +- .../ts/front/Components/Theme/HeroImage.tsx | 22 +- resources/ts/front/Components/Theme/Image.tsx | 53 +-- .../front/Components/Theme/Inputs/Filters.tsx | 39 +-- .../ts/front/Components/Theme/ItemCard.tsx | 52 +-- .../Components/Theme/ListSectionTitle.tsx | 8 +- resources/ts/front/Components/Theme/Logo.tsx | 16 +- .../Components/Theme/NutritionalValueList.tsx | 76 +++-- .../ts/front/Components/Theme/PageHeader.tsx | 21 +- .../ts/front/Components/Theme/Section.tsx | 82 ++++- .../Theme/Sections/CarouselSection.tsx | 174 +++++++--- .../Theme/Sections/TripleColSection.tsx | 12 +- resources/ts/front/Components/Theme/Sheet.tsx | 68 ++-- .../front/Components/Theme/SocialNetworks.tsx | 115 ++++--- .../ts/front/Components/Theme/TripleCol.tsx | 45 ++- .../ts/front/Components/Theme/VideoBanner.tsx | 15 +- resources/ts/front/Layouts/AppLayout.tsx | 4 +- resources/ts/front/Pages/Commitment.tsx | 142 ++++---- .../ts/front/Pages/Contact/ContactForm.tsx | 173 +++++++--- .../ts/front/Pages/Contact/ContactUs.tsx | 11 +- resources/ts/front/Pages/Demo.tsx | 303 ++++++++++-------- .../ts/front/Pages/DynamicPageDefault.tsx | 4 +- resources/ts/front/Pages/Expertise.tsx | 185 +++++------ resources/ts/front/Pages/Gamme.tsx | 80 +++-- resources/ts/front/Pages/Home.tsx | 168 +++++----- resources/ts/front/Pages/MadeInFrance.tsx | 74 ++--- resources/ts/front/lib/carousels.tsx | 18 +- resources/ts/front/lib/constants.tsx | 30 +- .../ts/front/providers/RecaptchaProvider.tsx | 28 +- resources/ts/hooks/use-cookie-notice.tsx | 4 +- resources/ts/hooks/use-recaptcha.tsx | 2 - resources/ts/types/front.d.ts | 77 +++-- resources/ts/window.d.ts | 8 +- routes/breadcrumbs/front.php | 25 +- routes/web-front.php | 12 +- 67 files changed, 1906 insertions(+), 1687 deletions(-) delete mode 100644 .stylelintcache delete mode 100644 resources/ts/front/Components/Base/Inputs/SimpleImage.tsx diff --git a/.stylelintcache b/.stylelintcache deleted file mode 100644 index 68a7ccb2..00000000 --- a/.stylelintcache +++ /dev/null @@ -1 +0,0 @@ -[["1","2"],{"key":"3","value":"4"},{"key":"5","value":"6"},"/app/srcs/resources/sass/common.scss",{"size":59,"mtime":1773655918680,"data":"7"},"/app/srcs/resources/sass/front/app.scss",{"size":377,"mtime":1773655918680,"data":"8"},{"hashOfConfig":"9"},{"hashOfConfig":"9"},"1u1z2d5"] \ No newline at end of file diff --git a/app/Http/Middlewares/HandleInertiaRequests.php b/app/Http/Middlewares/HandleInertiaRequests.php index e8dca86b..ccba42fc 100644 --- a/app/Http/Middlewares/HandleInertiaRequests.php +++ b/app/Http/Middlewares/HandleInertiaRequests.php @@ -27,7 +27,8 @@ class HandleInertiaRequests extends Middleware $dynamicPages = []; foreach ($dynamicPageModels as $dynamicPageModel) { - $pascalCase = str_replace(' ', '', ucwords(str_replace('-', ' ', $dynamicPageModel->id_key))); + $pascalCase = + str_replace(' ', '', ucwords(str_replace('-', ' ', $dynamicPageModel->id_key))); $dynamicPages["page{$pascalCase}"] = $dynamicPageModel; } diff --git a/package-lock.json b/package-lock.json index ad1bf56c..8a2fe680 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "@dnd-kit/utilities": "^3.2.2", "@inertiajs/core": "^2.1.5", "@inertiajs/react": "^2.3.18", + "@ldc-web/cookie-notice": "^6.1.1", "@radix-ui/react-slot": "^1.2.4", "@tanstack/react-table": "^8.21.3", "@tiptap/core": "^3.21.0", @@ -65,7 +66,6 @@ }, "devDependencies": { "@headlessui/react": "^2.2.9", - "@ldc-web/cookie-notice": "^6.1.1", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", @@ -1792,8 +1792,7 @@ "node_modules/@ldc-web/cookie-notice": { "version": "6.1.1", "resolved": "https://lab.s-web.fr/api/v4/projects/50/packages/npm/@ldc-web/cookie-notice/-/@ldc-web/cookie-notice-6.1.1.tgz", - "integrity": "sha1-VzAHzvPedfR1OXVLIJXHwaWYeUA=", - "dev": true + "integrity": "sha1-VzAHzvPedfR1OXVLIJXHwaWYeUA=" }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", diff --git a/package.json b/package.json index af3d4bff..842c442b 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,9 @@ }, "devDependencies": { "@headlessui/react": "^2.2.9", - "@ldc-web/cookie-notice": "^6.1.1", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", - "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.8", "@radix-ui/react-popover": "^1.1.15", @@ -71,6 +69,8 @@ "vite-plugin-stylelint": "^6.0.4" }, "dependencies": { + "@ldc-web/cookie-notice": "^6.1.1", + "@radix-ui/react-dialog": "^1.1.15", "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", diff --git a/resources/sass/common.scss b/resources/sass/common.scss index 514f721f..71fff083 100644 --- a/resources/sass/common.scss +++ b/resources/sass/common.scss @@ -1,5 +1,4 @@ -@use "./common/wysiwyg"; - +@use './common/wysiwyg'; @tailwind base; @tailwind components; @tailwind utilities; diff --git a/resources/sass/common/wysiwyg.scss b/resources/sass/common/wysiwyg.scss index 63c746f3..14bfcd82 100644 --- a/resources/sass/common/wysiwyg.scss +++ b/resources/sass/common/wysiwyg.scss @@ -1,7 +1,7 @@ -$primaryForegroundFront: hsl(227 65% 19%); -.tiptap { +$primary-foreground-front: hsl(227deg 65% 19%); - color: $primaryForegroundFront; +.tiptap { + color: $primary-foreground-front; h2 { @apply text-4xl font-bold uppercase mb-3; diff --git a/resources/sass/front/_fonts.scss b/resources/sass/front/_fonts.scss index 8cafdad7..acb5b55d 100644 --- a/resources/sass/front/_fonts.scss +++ b/resources/sass/front/_fonts.scss @@ -1,163 +1,161 @@ /* Gotham - Black */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 900; - src: url("&/fonts/Gotham/Gotham-Black.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Black.ttf') format('truetype'); } /* Gotham - BlackItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 900; - src: url("&/fonts/Gotham/Gotham-BlackItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-BlackItalic.ttf') format('truetype'); } /* Gotham - Bold */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 700; - src: url("&/fonts/Gotham/Gotham-Bold.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Bold.ttf') format('truetype'); } /* Gotham - BoldItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 700; - src: url("&/fonts/Gotham/Gotham-BoldItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-BoldItalic.ttf') format('truetype'); } /* Gotham - Book */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 400; - src: url("&/fonts/Gotham/Gotham-Book.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Book.ttf') format('truetype'); } /* Gotham - BookItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 400; - src: url("&/fonts/Gotham/Gotham-BookItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-BookItalic.ttf') format('truetype'); } /* Gotham - Light */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 300; - src: url("&/fonts/Gotham/Gotham-Light.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Light.ttf') format('truetype'); } /* Gotham - LightItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 300; - src: url("&/fonts/Gotham/Gotham-LightItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-LightItalic.ttf') format('truetype'); } /* Gotham - Medium */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 500; - src: url("&/fonts/Gotham/Gotham-Medium.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Medium.ttf') format('truetype'); } /* Gotham - MediumItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 500; - src: url("&/fonts/Gotham/Gotham-MediumItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-MediumItalic.ttf') format('truetype'); } /* Gotham - Thin */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 100; - src: url("&/fonts/Gotham/Gotham-Thin.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Thin.ttf') format('truetype'); } /* Gotham - ThinItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 100; - src: url("&/fonts/Gotham/Gotham-ThinItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-ThinItalic.ttf') format('truetype'); } /* Gotham - Ultra */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 950; - src: url("&/fonts/Gotham/Gotham-Ultra.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-Ultra.ttf') format('truetype'); } /* Gotham - UltraItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 950; - src: url("&/fonts/Gotham/Gotham-UltraItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-UltraItalic.ttf') format('truetype'); } /* Gotham - Xlight */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: normal; font-weight: 200; - src: url("/fonts/Gotham/Gotham-XLight.ttf") format("truetype"); + src: url('/fonts/Gotham/Gotham-XLight.ttf') format('truetype'); } /* Gotham - XLightItalic */ @font-face { font-display: swap; - font-family: "Gotham"; + font-family: Gotham; font-style: italic; font-weight: 200; - src: url("&/fonts/Gotham/Gotham-XLightItalic.ttf") format("truetype"); + src: url('&/fonts/Gotham/Gotham-XLightItalic.ttf') format('truetype'); } - -// DELIUS /* Delius - Regular */ @font-face { font-display: swap; - font-family: "Delius"; + font-family: Delius; font-style: normal; font-weight: 400; - src: url("&/fonts/Delius/Delius-Regular.ttf") format("truetype"); + src: url('&/fonts/Delius/Delius-Regular.ttf') format('truetype'); } /* Delius - SwashCaps */ @font-face { font-display: swap; - font-family: "Delius Swash Caps"; + font-family: 'Delius Swash Caps'; font-style: normal; font-weight: 400; - src: url("&/fonts/Delius/DeliusSwashCaps-Regular.ttf") format("truetype"); + src: url('&/fonts/Delius/DeliusSwashCaps-Regular.ttf') format('truetype'); } diff --git a/resources/sass/front/app.scss b/resources/sass/front/app.scss index fd655c2c..435cb15c 100644 --- a/resources/sass/front/app.scss +++ b/resources/sass/front/app.scss @@ -1,11 +1,13 @@ // * COMMON CSS. @use './../common'; @use './fonts'; -@use './vendor/_cookie-notice'; +@use './vendor/cookie-notice'; @layer base { * { + @apply border-border font-gotham; + --primary: 40 100% 64%; --primary-foreground: 227 65% 19%; --background: 0 0% 100%; @@ -14,9 +16,7 @@ --accent: 220 14% 96%; --accent-foreground: 227 51% 23%; --foreground: 227 65% 19%; - - - + // No customize here --muted: 210 40% 96.1%; --muted-foreground: 215.4 16.3% 46.9%; --popover: 0 0% 100%; @@ -25,9 +25,7 @@ --card-foreground: 222.2 84% 4.9%; --border: 214.3 31.8% 91.4%; --input: 214.3 31.8% 91.4%; - - - + // End no customize --destructive: 0 84.2% 60.2%; --destructive-foreground: 210 40% 98%; --successive: 113 100% 38%; @@ -40,10 +38,6 @@ --radius: 0.5rem; } - * { - @apply border-border font-gotham; - } - body { @apply bg-background text-foreground; } diff --git a/resources/ts/app.tsx b/resources/ts/app.tsx index c106ed73..341e0be7 100644 --- a/resources/ts/app.tsx +++ b/resources/ts/app.tsx @@ -5,7 +5,6 @@ import axios from "axios"; import CookieNotice from "@ldc-web/cookie-notice"; import recaptcha from "./hooks/use-recaptcha"; - // @ts-expect-error Env is always present. const appName = import.meta.env.VITE_APP_NAME || "Laravel"; diff --git a/resources/ts/back/Components/Inputs/ModelSelect.tsx b/resources/ts/back/Components/Inputs/ModelSelect.tsx index 986e8eb7..652cd21d 100644 --- a/resources/ts/back/Components/Inputs/ModelSelect.tsx +++ b/resources/ts/back/Components/Inputs/ModelSelect.tsx @@ -643,13 +643,9 @@ export const ModelSelect = forwardRef( onValueChange(defaultValues); } - const singleDefaultValue = defaultValues.length > 0 ? defaultValues[0] : null; - setData( - name, - multiple - ? defaultValues - : singleDefaultValue - ); + const singleDefaultValue = + defaultValues.length > 0 ? defaultValues[0] : null; + setData(name, multiple ? defaultValues : singleDefaultValue); // eslint-disable-next-line react-hooks/exhaustive-deps }, [defaultValues, onValueChange]); @@ -666,12 +662,7 @@ export const ModelSelect = forwardRef( onValueChange(values); } const singleDefaultValue = values.length > 0 ? values[0] : null; - setData( - name, - multiple - ? values - : singleDefaultValue - ); + setData(name, multiple ? values : singleDefaultValue); }, clear: () => { setSelectedValues([]); @@ -876,13 +867,9 @@ export const ModelSelect = forwardRef( if (onModelChange) { onModelChange(newSelectedModels); } - const singleDefaultValue = newSelectedValues.length > 0 ? newSelectedValues[0] : null; - setData( - name, - multiple - ? newSelectedValues - : singleDefaultValue - ); + const singleDefaultValue = + newSelectedValues.length > 0 ? newSelectedValues[0] : null; + setData(name, multiple ? newSelectedValues : singleDefaultValue); } }; @@ -904,13 +891,9 @@ export const ModelSelect = forwardRef( if (onModelChange) { onModelChange(newSelectedModels); } - const singleDefaultValue = newSelectedValues.length > 0 ? newSelectedValues[0] : null; - setData( - name, - multiple - ? newSelectedValues - : singleDefaultValue - ); + const singleDefaultValue = + newSelectedValues.length > 0 ? newSelectedValues[0] : null; + setData(name, multiple ? newSelectedValues : singleDefaultValue); if (closeOnSelect) { setIsPopoverOpen(false); } @@ -943,13 +926,9 @@ export const ModelSelect = forwardRef( } setSelectedModels(newSelectedModels); - const singleDefaultValue = newSelectedValues.length > 0 ? newSelectedValues[0] : null; - setData( - name, - multiple - ? newSelectedValues - : singleDefaultValue - ); + const singleDefaultValue = + newSelectedValues.length > 0 ? newSelectedValues[0] : null; + setData(name, multiple ? newSelectedValues : singleDefaultValue); } else { if (maxSelection && selectedValues.length >= maxSelection) { announce(`Maximum ${maxSelection} selection(s) allowed`, "assertive"); @@ -966,13 +945,9 @@ export const ModelSelect = forwardRef( onModelChange(newSelectedModels); } setSelectedModels(newSelectedModels); - const singleDefaultValue = newSelectedValues.length > 0 ? newSelectedValues[0] : null; - setData( - name, - multiple - ? newSelectedValues - : singleDefaultValue - ); + const singleDefaultValue = + newSelectedValues.length > 0 ? newSelectedValues[0] : null; + setData(name, multiple ? newSelectedValues : singleDefaultValue); } if (closeOnSelect) { setIsPopoverOpen(false); @@ -1020,13 +995,9 @@ export const ModelSelect = forwardRef( if (onModelChange) { onModelChange(newSelectedModels); } - const singleDefaultValue = newSelectedValues.length > 0 ? newSelectedValues[0] : null; - setData( - name, - multiple - ? newSelectedValues - : singleDefaultValue - ); + const singleDefaultValue = + newSelectedValues.length > 0 ? newSelectedValues[0] : null; + setData(name, multiple ? newSelectedValues : singleDefaultValue); }; const toggleAll = () => { @@ -1057,12 +1028,7 @@ export const ModelSelect = forwardRef( onModelChange(allOptions); } const singleDefaultValue = allValues.length > 0 ? allValues[0] : null; - setData( - name, - multiple - ? allValues - : singleDefaultValue - ); + setData(name, multiple ? allValues : singleDefaultValue); } if (closeOnSelect) { diff --git a/resources/ts/front/Components/Base/BreadCrumbsBase.tsx b/resources/ts/front/Components/Base/BreadCrumbsBase.tsx index 09d09b13..57538180 100644 --- a/resources/ts/front/Components/Base/BreadCrumbsBase.tsx +++ b/resources/ts/front/Components/Base/BreadCrumbsBase.tsx @@ -9,10 +9,16 @@ import { Link } from "@inertiajs/react"; //* THEME import { cn } from "@/lib/utils"; -const BreadcrumbsBase = ({ className, breadcrumbs }: { className?: string, breadcrumbs?: Array<{ - title: string; - url: string; -}> }) => { +export default function BreadcrumbsBase({ + className, + breadcrumbs, +}: { + className?: string; + breadcrumbs?: Array<{ + title: string; + url: string; + }>; +}) { return ( breadcrumbs && ( @@ -25,7 +31,7 @@ const BreadcrumbsBase = ({ className, breadcrumbs }: { className?: string, bread {breadcrumbIndex >= 1 && } {breadcrumbIndex !== breadcrumbs.length - 1 && - breadcrumb.url ? ( + breadcrumb.url ? ( - ) - ) + ); } -export default BreadcrumbsBase; diff --git a/resources/ts/front/Components/Base/Carousel/Carousel.tsx b/resources/ts/front/Components/Base/Carousel/Carousel.tsx index 44b133ba..fe0b7350 100644 --- a/resources/ts/front/Components/Base/Carousel/Carousel.tsx +++ b/resources/ts/front/Components/Base/Carousel/Carousel.tsx @@ -4,15 +4,15 @@ import { CarouselPropsWithNavigation } from "@/types/front"; type Props = CarouselPropsWithNavigation & { className?: string; -} -const Carousel = (props: Props) => { +}; +export default function Carousel(props: Props) { const { className, ...carouselProps } = props; const { ref, isVisible } = useInView(); return (
+ {/* eslint-disable-next-line react/jsx-props-no-spreading */} {isVisible && }
- ) + ); } -export default Carousel; diff --git a/resources/ts/front/Components/Base/Carousel/CarouselContent.tsx b/resources/ts/front/Components/Base/Carousel/CarouselContent.tsx index 0f870592..41087309 100644 --- a/resources/ts/front/Components/Base/Carousel/CarouselContent.tsx +++ b/resources/ts/front/Components/Base/Carousel/CarouselContent.tsx @@ -1,40 +1,80 @@ /** REACT */ -import { ReactNode, useMemo, useRef, useState } from "react"; +import { useMemo, useRef, useState } from "react"; /** SWIPER PACKAGE */ import { Swiper as SwiperType } from "swiper"; import { PaginationOptions } from "swiper/types"; import { Swiper, SwiperClass, SwiperSlide } from "swiper/react"; import { Pagination } from "swiper/modules"; -import 'swiper/css'; -import 'swiper/css/navigation'; -import 'swiper/css/pagination'; +import "swiper/css"; +import "swiper/css/navigation"; +import "swiper/css/pagination"; /** THEME */ import ItemCard from "$/uwil/ItemCard"; -import { CarouselBreakpointsProps, CarouselPropsWithNavigation, SwiperButtonProps } from "@/types/front"; +import { + CarouselBreakpointsProps, + CarouselPropsWithNavigation, + SwiperButtonProps, +} from "@/types/front"; import { bgColors } from "@/front/lib/constants"; import { cn } from "@/lib/utils"; -const CarouselContent = (props: CarouselPropsWithNavigation) => { - const { items, carousel, variant = bgColors.PRIMARY, prevBtn, nextBtn } = props; +function NextButton({ swiperRef, disabled, icon }: SwiperButtonProps) { + return ( + + ); +} + +function PrevButton({ swiperRef, disabled, icon }: SwiperButtonProps) { + return ( + + ); +} + +const defaultSlidesPerView: Record = { + 768: 2, + 1024: 3, + 1248: 4, +}; + +export default function CarouselContent(props: CarouselPropsWithNavigation) { + const { + items, + carousel, + variant = bgColors.PRIMARY, + prevBtn, + nextBtn, + } = props; const [isBeginning, setIsBeginning] = useState(true); const [isEnd, setIsEnd] = useState(false); const swiperRef = useRef(null); - const paginationDefaultVariant = variant === bgColors.PRIMARY ? "bg-background" : "bg-primary" const spaceBetween = carousel?.spaceBetween ?? 50; const slidesPerView = carousel?.slidesPerView ?? 1; - const defaultPagination: PaginationOptions = { - clickable: true, - bulletClass: `inline-block w-3 h-3 rounded-full ${paginationDefaultVariant} mx-1`, - bulletActiveClass: 'bg-primary-foreground w-5 h-5', - }; + const defaultPagination = useMemo((): PaginationOptions => { + const variantClass = + variant === bgColors.PRIMARY ? "bg-background" : "bg-primary"; - const defaultSlidesPerView: Record = { - 768: 2, - 1024: 3, - 1248: 4 - }; + return { + clickable: true, + bulletClass: `inline-block w-3 h-3 rounded-full ${variantClass} mx-1`, + bulletActiveClass: "bg-primary-foreground w-5 h-5", + }; + }, [variant]); const breakpoints = useMemo(() => { return Object.keys({ @@ -59,11 +99,9 @@ const CarouselContent = (props: CarouselPropsWithNavigation) => { return { ...defaultPagination, - ...(typeof carousel?.pagination === 'object' - ? carousel.pagination - : {}), + ...(typeof carousel?.pagination === "object" ? carousel.pagination : {}), }; - }, [carousel?.pagination, variant]); + }, [carousel?.pagination, defaultPagination]); const handleSwiper = (swiper: SwiperClass) => { swiperRef.current = swiper; @@ -96,14 +134,11 @@ const CarouselContent = (props: CarouselPropsWithNavigation) => { wrapperClass={cn("pb-20", carousel?.wrapperClass)} className="w-full" > - {items.map((item, index) => { + {items.map((item) => { return ( - + { variant={variant} /> - ) + ); })} - ) + ); } -export default CarouselContent; - -const NextButton = ({ swiperRef, disabled, icon }: SwiperButtonProps) => { - return ( - - ); -}; - -const PrevButton = ({ swiperRef, disabled, icon }: SwiperButtonProps) => { - return ( - - ); -}; diff --git a/resources/ts/front/Components/Base/GoToTopBase.tsx b/resources/ts/front/Components/Base/GoToTopBase.tsx index 12c8df86..ef4ca204 100644 --- a/resources/ts/front/Components/Base/GoToTopBase.tsx +++ b/resources/ts/front/Components/Base/GoToTopBase.tsx @@ -8,12 +8,11 @@ type Props = { classes?: { onVisibleClasses?: string; onHiddenClasses?: string; - generalClasses?: string - } -} - -const GoToTopBase = (props: Props) => { + generalClasses?: string; + }; +}; +export default function GoToTopBase(props: Props) { const { threshold = 300, behavior = "smooth", children, classes } = props; const [visible, setVisible] = useState(false); @@ -28,7 +27,7 @@ const GoToTopBase = (props: Props) => { return () => { window.removeEventListener("scroll", handleScroll); }; - }, []); + }, [threshold]); const scrollToTop = () => { window.scrollTo({ @@ -39,11 +38,17 @@ const GoToTopBase = (props: Props) => { return ( - ) + ); } -export default GoToTopBase; diff --git a/resources/ts/front/Components/Base/Inputs/FilterDropdown.tsx b/resources/ts/front/Components/Base/Inputs/FilterDropdown.tsx index 18dd5603..91c665ed 100644 --- a/resources/ts/front/Components/Base/Inputs/FilterDropdown.tsx +++ b/resources/ts/front/Components/Base/Inputs/FilterDropdown.tsx @@ -1,43 +1,47 @@ /** OTHER */ -import * as React from "react" +import * as React from "react"; /** SHADCN */ -import { Checkbox } from "@/components/ui/checkbox" -import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" -import { Label } from "@/components/ui/label" +import { Checkbox } from "@/components/ui/checkbox"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Label } from "@/components/ui/label"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, -} from "@/components/ui/accordion" +} from "@/components/ui/accordion"; /** THEME */ -import { cn } from "@/lib/utils" -import Button from "$/uwil/Button" -import { fonts, sidePlacements } from "@/front/lib/constants" -import { Trash, X } from "lucide-react" +import { cn } from "@/lib/utils"; +import Button from "$/uwil/Button"; +import { fonts, sidePlacements } from "@/front/lib/constants"; export interface FilterOption { - id: string - label: string - checked?: boolean + id: string; + label: string; + checked?: boolean; } interface FilterDropdownProps { /** Le texte du bouton */ - label?: string + label?: string; /** Les options de filtre */ - options: FilterOption[] + options: FilterOption[]; + /* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */ /** Callback quand les filtres changent */ - onChange?: (selectedIds: string[]) => void + onChange?: (selectedIds: string[]) => void; /** Ouvrir au survol en plus du clic */ - openOnHover?: boolean + openOnHover?: boolean; /** Délai avant fermeture au survol (ms) */ - hoverCloseDelay?: number + hoverCloseDelay?: number; /** Classes additionnelles pour le bouton */ - className?: string + className?: string; /** Value of the input */ value: string[]; - isMobile?: boolean + isMobile?: boolean; } export function FilterDropdown({ @@ -48,12 +52,14 @@ export function FilterDropdown({ hoverCloseDelay = 200, className, value, - isMobile = false + isMobile = false, }: FilterDropdownProps) { - const [open, setOpen] = React.useState(false) + const [open, setOpen] = React.useState(false); const selected = new Set(value); const selectedCount = value.length; - const closeTimeoutRef = React.useRef(null) + const closeTimeoutRef = React.useRef | null>( + null, + ); const handleCheckedChange = (id: string, checked: boolean) => { let next: string[]; @@ -68,30 +74,25 @@ export function FilterDropdown({ }; const handleMouseEnter = () => { - if (!openOnHover) return + if (!openOnHover) return; if (closeTimeoutRef.current) { - clearTimeout(closeTimeoutRef.current) - closeTimeoutRef.current = null + clearTimeout(closeTimeoutRef.current); + closeTimeoutRef.current = null; } - setOpen(true) - } + setOpen(true); + }; const handleMouseLeave = () => { - if (!openOnHover) return + if (!openOnHover) return; closeTimeoutRef.current = setTimeout(() => { - setOpen(false) - }, hoverCloseDelay) - } - + setOpen(false); + }, hoverCloseDelay); + }; if (isMobile) { return (
- +
@@ -108,6 +109,7 @@ export function FilterDropdown({ {options.map((option) => (
- ) + ); } return ( @@ -139,11 +147,13 @@ export function FilterDropdown({ className="inline-block" > - - + ); } diff --git a/resources/ts/front/Components/Base/Inputs/SimpleCheckbox.tsx b/resources/ts/front/Components/Base/Inputs/SimpleCheckbox.tsx index 0a4a3442..c1a10a4e 100644 --- a/resources/ts/front/Components/Base/Inputs/SimpleCheckbox.tsx +++ b/resources/ts/front/Components/Base/Inputs/SimpleCheckbox.tsx @@ -37,8 +37,8 @@ export default function SimpleCheckbox({ disabled={disabled} className="rounded-full border-primary-foreground data-[state=checked]:bg-primary-foreground data-[state=checked]:text-primary" checked={value} - onCheckedChange={(value) => { - setData(name, Boolean(value)) + onCheckedChange={(v) => { + setData(name, Boolean(v)); }} />
- ) + ); } diff --git a/resources/ts/front/Components/Base/Inputs/SimpleImage.tsx b/resources/ts/front/Components/Base/Inputs/SimpleImage.tsx deleted file mode 100644 index f76b8872..00000000 --- a/resources/ts/front/Components/Base/Inputs/SimpleImage.tsx +++ /dev/null @@ -1,294 +0,0 @@ -import { Button as ShadcnButton } from "@/components/ui/button"; -import str from "@/hooks/use-string"; -import { useToast } from "@/hooks/use-toast"; -import useTrans from "@/hooks/use-translations"; -import { cn, GetTranslation } from "@/lib/utils"; -import { FileCheck, Image, Trash, UploadIcon } from "lucide-react"; -import { ReactNode, useCallback, useEffect, useState } from "react"; -import { ErrorCode, FileWithPath, useDropzone } from "react-dropzone"; -import BtnOptionnalLinkWithTooltip from "../BtnOptionnalLinkWithTooltip"; - -type FileWithPreview = FileWithPath & { - preview: string; -}; - -type FileValidation = { - validationRules?: { - width: string | null; - height: string | null; - } | null; - maxFileSize: string | null; - allowedFormats: string | null; -}; - -type SimpleImageProps = FileValidation & { - name: string; - value?: string | File | null; - /** Original data is the data directly from the model, not in the form state */ - originalData?: string | undefined; - /** Add custom event when refresh to the originalData */ - onRefreshFile?: () => void; - label?: ReactNode | string; - required?: boolean; - fileName?: string; - hasRefreshBtn?: boolean; - parentErrors?: Record | null; - setData: (name: string, value: File | string | null) => void; - reset: (name?: string) => void; - hasFile?: (hasFile: boolean) => void; -} -export default function SimpleImage({ - value, - setData, - originalData, - name = "defaultName", - onRefreshFile, - label = "defaultLabel", - required = false, - maxFileSize, - validationRules, - allowedFormats, - reset, - fileName = "image", - hasRefreshBtn = true, - hasFile, - parentErrors, -}: SimpleImageProps) { - const { toast } = useToast(); - const [selectedFile, setSelectedFile] = useState(null); - const [accept, setAccept] = useState>>({ - "image/*": [], - }); - const [extensions, setExtensions] = useState(); - const localMaxFileSize = maxFileSize - ? parseInt(maxFileSize, 10) * 1024 - : 50000; - - // Fonction utilitaire pour formater la taille de fichier - const formatFileSize = (bytes: number): string => { - if (bytes === 0) return "0 Bytes"; - const k = 1024; - const sizes = ["Bytes", "KB", "MB", "GB"]; - const i = Math.floor(Math.log(bytes) / Math.log(k)); - const currentSize = sizes[i]; - const currentBytes = parseFloat((bytes / k ** i).toFixed(2)); - return `${currentBytes} ${currentSize}`; - }; - - const dropErrorMessages = { - noFile: str(useTrans("front.image.toast.no_file")) - .ucFirst() - .value(), - tooLarge: str( - useTrans("front.image.toast.too_big", { - params: { - maxSize: formatFileSize(localMaxFileSize), - }, - }), - ) - .ucFirst() - .value(), - forbidden: str( - useTrans("front.image.toast.forbidden_file"), - ) - .ucFirst() - .value(), - tooMany: str(useTrans("front.image.toast.too_many")) - .ucFirst() - .value(), - default: str( - useTrans("front.image.toast.defaultError"), - ) - .ucFirst() - .value(), - }; - - const onDrop = useCallback( - (acceptedFiles: FileWithPath[]) => { - const file = acceptedFiles[0]; - if (!file) { - toast({ - title: "Oups !", - description: dropErrorMessages.noFile, - }); - return; - } - const fileWithPreview = Object.assign(file, { - preview: URL.createObjectURL(file), - }); - - setSelectedFile(fileWithPreview); - setData(name, file); - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [maxFileSize, formatFileSize], - ); - - const { getRootProps, getInputProps } = useDropzone({ - onDrop, - accept, - multiple: false, - maxSize: localMaxFileSize, - onDropRejected: (fileRejections) => { - const rejection = fileRejections[0]; - const rejectionCode = rejection?.errors?.[0]?.code; - if (rejectionCode === ErrorCode.FileTooLarge) { - toast({ - title: "Oups !", - description: `${dropErrorMessages.tooLarge} (${formatFileSize(rejection.file.size)}).`, - }); - } else if (rejectionCode === ErrorCode.FileInvalidType) { - toast({ - title: "Oups !", - description: dropErrorMessages.forbidden, - }); - } else if (rejectionCode === ErrorCode.TooManyFiles) { - toast({ - title: "Oups !", - description: dropErrorMessages.tooMany, - }); - } else { - toast({ - title: "Oups !", - description: dropErrorMessages.default, - }); - } - }, - }); - - // Translations - const transSelectImgZone = GetTranslation( - "front.image.select_file_zone" - ); - const transValidationAllFormats = str( - useTrans("front.image.validation.all_formats"), - ) - .ucFirst() - .value(); - const transCropperFileUploaded = useTrans( - "front.image.state_file_uploaded", - ); - const transCancel = useTrans("uwil-backend::back.cancel"); - const getTransValidationAllowedFormats = (targetExtensions: string) => { - return str( - GetTranslation( - "front.image.validation.allowed_formats", - { - params: { - formats: targetExtensions, - }, - }, - ), - ) - .ucFirst() - .value(); - }; - const transRulesWeight = GetTranslation( - "front.image.validation.rules_weight", - { - params: { - size: formatFileSize(localMaxFileSize).toString(), - }, - }, - ); - - const buildDropzoneAccept = (): Record => { - if (!allowedFormats) return {}; - - const currentExtensions = allowedFormats.split(","); - setExtensions(allowedFormats); - const mimeMap: Record = { - jpg: "image/jpeg", - jpeg: "image/jpeg", - png: "image/png", - gif: "image/gif", - pdf: "application/pdf", - svg: "image/svg+xml", - webp: "image/webp", - }; - - const result: Record> = {}; - - currentExtensions.forEach((ext) => { - const cleanExt = ext.trim().toLowerCase(); - const mime = mimeMap[cleanExt]; - if (mime) { - if (!result[mime]) { - result[mime] = new Set(); - } - result[mime].add(`.${cleanExt}`); - } - }); - - // Convert Set to Array for React Dropzone - const currentAccept: Record = {}; - Object.entries(result).forEach(([mime, extSet]) => { - currentAccept[mime] = Array.from(extSet); - }); - setAccept(currentAccept); - return currentAccept; - }; - - useEffect(() => { - buildDropzoneAccept(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return ( -
- {selectedFile ? ( -
-
-
- -

- {str(transCropperFileUploaded).ucFirst().value()} -

- {selectedFile.name} -
-
- } - onClick={() => { - setSelectedFile(null); - setData(name, null); - }} - tooltipContent={str(transCancel).ucFirst().value()} - /> -
- ) : ( - - {/* eslint-disable-next-line react/jsx-props-no-spreading */} - -
- -

- {transSelectImgZone} -

- - {extensions - ? getTransValidationAllowedFormats(extensions) - : transValidationAllFormats} - . {str(transRulesWeight).ucFirst().value()} - -
-
- )} -
- ) -} diff --git a/resources/ts/front/Components/Base/RecaptchaForm.tsx b/resources/ts/front/Components/Base/RecaptchaForm.tsx index ad1a77f6..2afb3914 100644 --- a/resources/ts/front/Components/Base/RecaptchaForm.tsx +++ b/resources/ts/front/Components/Base/RecaptchaForm.tsx @@ -11,61 +11,29 @@ import InputError from "$/base/InputError"; import useTrans from "@/hooks/use-translations"; import { cn } from "@/lib/utils"; - interface CustomData { "g-recaptcha-response"?: string; } -type Props = { - onSubmit: (e: FormEvent) => void; - data: TFormData & CustomData; - children: React.ReactNode; - footer?: React.ReactNode; - banner?: BannerClassName - classNames?: { - wrapperClassName?: string; - formClassName?: string; - } -}; - type BannerClassName = { classNames?: { wrapperClassName?: string; btnClassName?: string; - } -} -export default function RecaptchaForm({ onSubmit, classNames, banner, data, children, footer }: Props) { - const { getToken, formRef, enabled } = useRecaptcha(); - const { errors } = usePage().props; - const recaptchaKey = usePage().props.recaptchaKey as string; - const handleSubmit = (e: FormEvent) => { - e.preventDefault(); - if (!enabled) return; - const token = getToken(); - data["g-recaptcha-response"] = token; - onSubmit(e); }; +}; - return ( -
- -
- {children} - {enabled && ( - <> - -
- - )} - {footer} - -
- ); -} +type Props = { + /* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */ + onSubmit: (e: FormEvent) => void; + data: TFormData & CustomData; + children: React.ReactNode; + footer?: React.ReactNode; + banner?: BannerClassName; + classNames?: { + wrapperClassName?: string; + formClassName?: string; + }; +}; function RecaptchaNotice({ banner }: { banner?: BannerClassName }) { const { enabled } = useRecaptcha(); @@ -75,7 +43,7 @@ function RecaptchaNotice({ banner }: { banner?: BannerClassName }) { const label = useTrans("cookie-notice.custom.recaptcha.accept"); const handleAccept = () => { - // @ts-expect-error + // @ts-expect-error External library window.WebCookieNotice?.acceptCookie("recaptcha"); }; @@ -84,7 +52,10 @@ function RecaptchaNotice({ banner }: { banner?: BannerClassName }) { return (

@@ -94,10 +65,56 @@ function RecaptchaNotice({ banner }: { banner?: BannerClassName }) { {warning}

); } + +export default function RecaptchaForm({ + onSubmit, + classNames, + banner, + data, + children, + footer, +}: Props) { + const { getToken, formRef, enabled } = useRecaptcha(); + const { errors } = usePage().props; + const recaptchaKey = usePage().props.recaptchaKey as string; + const handleSubmit = (e: FormEvent) => { + e.preventDefault(); + if (!enabled) return; + const token = getToken(); + // eslint-disable-next-line no-param-reassign + data["g-recaptcha-response"] = token; + onSubmit(e); + }; + + return ( +
+ +
+ {children} + {enabled && ( + <> + +
+ + )} + {footer} + +
+ ); +} diff --git a/resources/ts/front/Components/Base/VideoEmbedWithConsent.tsx b/resources/ts/front/Components/Base/VideoEmbedWithConsent.tsx index bd1d71ff..9b1401a2 100644 --- a/resources/ts/front/Components/Base/VideoEmbedWithConsent.tsx +++ b/resources/ts/front/Components/Base/VideoEmbedWithConsent.tsx @@ -1,7 +1,7 @@ import { Loader } from "lucide-react"; import { cn, GetTranslation } from "@/lib/utils"; import { VideoProviderName } from "@/front/lib/constants"; -import { useCookieNotice } from "@/hooks/use-cookie-notice"; +import useCookieNotice from "@/hooks/use-cookie-notice"; type Props = { service: VideoProviderName; @@ -11,37 +11,52 @@ type Props = { iframeContainerClassName?: string; }; -const VideoEmbedWithConsent = ({ +function NoStatusComponent({ + loading, + service, + accept, +}: { + loading: boolean; + service: VideoProviderName; + accept: () => void; +}) { + const warning = GetTranslation(`cookie-notice.custom.${service}.warning`); + const acceptLabel = GetTranslation(`cookie-notice.custom.${service}.accept`); + return loading ? ( +
+ +
+ ) : ( +
+

{warning}

+ +
+ ); +} + +export default function VideoEmbedWithConsent({ service, embedUrl, title, className = "", - iframeContainerClassName = "" -}: Props) => { + iframeContainerClassName = "", +}: Props) { const { status, loading, accept } = useCookieNotice(service); - const warning = GetTranslation(`cookie-notice.custom.${service}.warning`); - const acceptLabel = GetTranslation(`cookie-notice.custom.${service}.accept`); - return (
{!status ? ( - loading ? ( -
- -
- ) : ( -
-

{warning}

- -
- ) + ) : (