Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-utilise general article content #989

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/components/richText/richText.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
}

Expand Down
17 changes: 8 additions & 9 deletions src/components/sections/article/Article.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -11,28 +10,28 @@ interface ArticleProps {
article: ArticleSection;
}

const Article = ({ article }: ArticleProps) => {
export default function Article({ article }: ArticleProps) {
return (
<article className={styles.wrapper} id={article._key}>
<div
className={`${styles.article} ${article.imageExtended.imageAlignment == "right" ? styles.right : ""}`}
>
{article?.imageExtended && (
<div className={styles.article}>
{hasImage(article) && (
<div className={styles.image}>
<SanityImage image={article.imageExtended} />
</div>
)}
<div className={styles.content}>
<div>
<Text type="labelRegular">{article.tag}</Text>
<Text type="h2">{article.basicTitle}</Text>
<Text type="h1">{article.basicTitle}</Text>
</div>
{article.richText && <RichText value={article.richText} />}
{article.link && <CustomLink link={article.link} />}
</div>
</div>
</article>
);
};
}

export default Article;
function hasImage(article: ArticleSection) {
return Boolean(article?.imageExtended?.src || article?.imageExtended?.asset);
}
62 changes: 13 additions & 49 deletions src/components/sections/article/article.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}
Loading