From bcdb9974883d673234db394cbad5cea454c5dc99 Mon Sep 17 00:00:00 2001 From: Ferran Buireu Date: Sat, 7 Sep 2024 13:59:34 +0200 Subject: [PATCH] feat: add slider for related articles --- .../utils/validateContact/validateContact.ts | 16 +-- src/pages/index.astro | 1 - src/pages/tags/_tag.css | 29 ++--- .../AboutLatestArticles.astro | 2 +- .../AboutLatestArticlesSlider.tsx | 10 +- .../components/articleCard/ArticleCard.astro | 26 ++-- .../components/articleCard/ArticleCard.tsx | 4 +- .../components/articleCard/article-card.css | 2 +- .../latestArticles/LatestArticles.astro | 2 +- .../LatestArticlesSlider.tsx | 8 +- .../relatedArticles/RelatedArticles.astro | 28 ++--- .../RelatedArticleCard.astro | 48 -------- .../related-article-card.css | 114 ------------------ .../RelatedArticlesSlider.tsx | 77 ++++++++++++ .../atoms/relatedArticlesSlider/index.ts | 1 + .../modules/core/components/slider/Slider.tsx | 15 ++- .../SliderNavigation/SliderNavigation.tsx | 10 +- .../SliderNavigation/slider-navigation.css | 5 +- .../articleVariantToClass.ts | 4 +- .../testimonials/Testimonials.astro | 2 +- .../testimonialsSlider/TestimonialsSlider.tsx | 5 +- src/ui/styles/vendor/swiper.css | 3 +- 22 files changed, 165 insertions(+), 247 deletions(-) delete mode 100644 src/ui/modules/core/components/relatedArticles/atoms/relatedArticleCard/RelatedArticleCard.astro delete mode 100644 src/ui/modules/core/components/relatedArticles/atoms/relatedArticleCard/related-article-card.css create mode 100644 src/ui/modules/core/components/relatedArticles/atoms/relatedArticlesSlider/RelatedArticlesSlider.tsx create mode 100644 src/ui/modules/core/components/relatedArticles/atoms/relatedArticlesSlider/index.ts diff --git a/src/infrastructure/utils/validateContact/validateContact.ts b/src/infrastructure/utils/validateContact/validateContact.ts index 7486a4c6..3ae3e9c2 100644 --- a/src/infrastructure/utils/validateContact/validateContact.ts +++ b/src/infrastructure/utils/validateContact/validateContact.ts @@ -5,14 +5,14 @@ import type { ContactFormData } from "@shared/ui/types"; type ValidateContact = Omit; export function validateContact(contact: ValidateContact) { - const { success, data, error } = contactFormSchema.safeParse(contact); + const { success, data, error } = contactFormSchema.safeParse(contact); - if (!success) { - throw new Exception({ - message: error?.errors.join(", ") || "Invalid data", - code: "BAD_REQUEST", - }); - } + if (!success) { + throw new Exception({ + message: error?.errors.join(", ") || "Invalid data", + code: "BAD_REQUEST", + }); + } - return data; + return data; } diff --git a/src/pages/index.astro b/src/pages/index.astro index c653a0cb..06dfa76e 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -6,7 +6,6 @@ import Testimonials from "@modules/home/components/testimonials/Testimonials.ast import Welcome from "@modules/home/components/welcome/Welcome.astro"; // check responsive -// related articles slider? // todo: add small transitions & animations // - Latest articles (https://codepen.io/jh3y/pen/MWLyGxo) // - add small icons (reading time, tags, etc)? diff --git a/src/pages/tags/_tag.css b/src/pages/tags/_tag.css index 458b4353..982037ad 100644 --- a/src/pages/tags/_tag.css +++ b/src/pages/tags/_tag.css @@ -1,24 +1,25 @@ .tag__article__list { - gap: 0 3rem; + --gap: 2rem; + gap: 0 var(--gap); margin-block: 2rem; position: relative; @media (width <= 960px) { margin-inline: 1rem; } -} - -.tag__article__item { - --gap: 2rem; - margin-block-end: 3rem; - max-width: calc(100% / var(--items-per-row) - var(--gap)); - position: relative; - width: 100%; - --items-per-row: 4; - @media (width <= 960px) { - --gap: 0; + .tag__article__item { margin-block-end: 3rem; - --items-per-row: 1; - } + max-width: calc(100% / var(--items-per-row) - var(--gap)); + position: relative; + width: 100%; + --items-per-row: 4; + + @media (width <= 960px) { + --gap: 0; + margin-block-end: 3rem; + --items-per-row: 1; + } + } } + diff --git a/src/ui/modules/about/components/aboutLatestArticles/AboutLatestArticles.astro b/src/ui/modules/about/components/aboutLatestArticles/AboutLatestArticles.astro index 04b9c66d..3af277dc 100644 --- a/src/ui/modules/about/components/aboutLatestArticles/AboutLatestArticles.astro +++ b/src/ui/modules/about/components/aboutLatestArticles/AboutLatestArticles.astro @@ -15,7 +15,7 @@ const articles = await getCollection("articles");

Lorem ipsum dolir sit Amet. Dolor sit amet.

Ferran Buireu
- +