From 1401b49bd21dda1fcca58ffc8cedfda5e78180ae Mon Sep 17 00:00:00 2001 From: Mikael Brevik Date: Tue, 10 Dec 2024 21:26:40 +0100 Subject: [PATCH] fix: re-utilise general article content --- src/components/richText/richText.module.css | 16 +---- src/components/sections/article/Article.tsx | 17 +++-- .../sections/article/article.module.css | 62 ++++--------------- 3 files changed, 24 insertions(+), 71 deletions(-) diff --git a/src/components/richText/richText.module.css b/src/components/richText/richText.module.css index 6b31b285f..f28a517f9 100644 --- a/src/components/richText/richText.module.css +++ b/src/components/richText/richText.module.css @@ -17,22 +17,12 @@ .image { overflow: hidden; margin: auto; - width: 100%; - min-width: 150px; - max-width: 15rem; - @media (min-width: 640px) { - min-width: 240px; - max-width: 21.25rem; - } - - @media (min-width: 1024px) { - max-width: 100%; - height: 25rem; - } + border-radius: var(--radius-medium); & img { - border-radius: 0.3125rem; + display: block; + max-width: 100%; } } diff --git a/src/components/sections/article/Article.tsx b/src/components/sections/article/Article.tsx index 82ea39dc3..b60eed1c1 100644 --- a/src/components/sections/article/Article.tsx +++ b/src/components/sections/article/Article.tsx @@ -1,4 +1,3 @@ -"use client"; import { SanityImage } from "src/components/image/SanityImage"; import CustomLink from "src/components/link/CustomLink"; import { RichText } from "src/components/richText/RichText"; @@ -11,13 +10,11 @@ interface ArticleProps { article: ArticleSection; } -const Article = ({ article }: ArticleProps) => { +export default function Article({ article }: ArticleProps) { return (
-
- {article?.imageExtended && ( +
+ {hasImage(article) && (
@@ -25,7 +22,7 @@ const Article = ({ article }: ArticleProps) => {
{article.tag} - {article.basicTitle} + {article.basicTitle}
{article.richText && } {article.link && } @@ -33,6 +30,8 @@ const Article = ({ article }: ArticleProps) => {
); -}; +} -export default Article; +function hasImage(article: ArticleSection) { + return Boolean(article?.imageExtended?.src || article?.imageExtended?.asset); +} diff --git a/src/components/sections/article/article.module.css b/src/components/sections/article/article.module.css index 1ae5a6de0..bdf1f74a5 100644 --- a/src/components/sections/article/article.module.css +++ b/src/components/sections/article/article.module.css @@ -8,52 +8,11 @@ .article { display: flex; flex-direction: column; - justify-content: center; align-items: center; - padding: 5rem 2rem; gap: 1.5rem; - - @media (min-width: 640px) { - max-width: 50rem; - align-self: stretch; - padding: 5rem 3rem; - } - - @media (min-width: 1024px) { - flex-direction: row; - width: 100%; - max-width: 87.5rem; - gap: 4.5rem; - padding: 7.5rem 8.75rem; - } -} - -.image { - border-radius: 0.75rem; - overflow: hidden; - - min-width: 150px; - max-width: 15rem; - - @media (min-width: 640px) { - min-width: 240px; - max-width: 21.25rem; - } - - @media (min-width: 1024px) { - min-width: 260px; - max-width: 21.25rem; - } - - @media (min-width: 1400px) { - min-width: 360px; - max-width: 27.5rem; - } - - @media (min-width: 1800px) { - min-width: 460px; - max-width: 33.75rem; - } + max-width: var(--max-content-width-large); + margin: 3rem auto; + padding: 1rem; } .content { @@ -63,11 +22,16 @@ justify-content: center; gap: 1.5rem; align-self: stretch; - max-width: 560px; + margin: auto; + + max-width: 600px; } -.right { - @media (min-width: 1024px) { - flex-direction: row-reverse; - } +.image { + border-radius: var(--radius-medium); + overflow: hidden; + aspect-ratio: 16/9; + + max-width: var(--max-content-width-medium); + margin: auto; }