Skip to content

Commit

Permalink
feat: add a page for preview save the date from directus (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoeTerrier authored Sep 18, 2024
1 parent f7c5ca8 commit 91a099a
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 32 deletions.
11 changes: 11 additions & 0 deletions app/src/components/DirectusImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ const imageLoader: ImageLoader = ({ src, width, quality }) => {
return `${PUBLIC_DIRECTUS_URL}/assets/${src}?width=${width}`;
};

export function directusImageUrl(
img: string | components["schemas"]["Files"] | null
) {
return img
? imageLoader({
src: typeof img === "string" ? img : img.filename_disk || "",
width: 1920,
})
: "";
}

/**
* Display an Image fetched from the Directus instance
* @param img unique public identifier of the image .
Expand Down
66 changes: 35 additions & 31 deletions app/src/components/SocialsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,42 @@ export default function SocialsList(props: {
return (
<div className={styles.socialsList}>
<div className={styles.list}>
{props.socials.map((s) => {
const content = (
<DirectusImage
sizes="4rem"
img={s.logo}
name={s.media_name}
className={`${styles.social} ${props.light ? styles.light : ""}`}
/>
);

if (/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(s.link || "")) {
return (
<a
href={`mailto:${s.link}`}
id={s.id?.toString()}
key={s.id?.toString()}
>
{content}
</a>
);
} else {
return (
<Link
href={s.link || ""}
id={s.id?.toString()}
key={s.id?.toString()}
>
{content}
</Link>
{props.socials
.filter((s) => s)
.map((s) => {
const content = (
<DirectusImage
sizes="4rem"
img={s.logo}
name={s.media_name}
className={`${styles.social} ${
props.light ? styles.light : ""
}`}
/>
);
}
})}

if (/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(s.link || "")) {
return (
<a
href={`mailto:${s.link}`}
id={s.id?.toString()}
key={s.id?.toString()}
>
{content}
</a>
);
} else {
return (
<Link
href={s.link || ""}
id={s.id?.toString()}
key={s.id?.toString()}
>
{content}
</Link>
);
}
})}
</div>
</div>
);
Expand Down
Loading

0 comments on commit 91a099a

Please sign in to comment.