Skip to content

Commit befaceb

Browse files
authored
Merge branch 'main' into spanish_translations_setup_draw
2 parents 0fac62e + dc693ea commit befaceb

46 files changed

Lines changed: 314 additions & 57 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/banner.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Banner
2+
3+
A banner can optionally be added at the bottom of the page with a custom message and link.
4+
5+
## Adding a new banner
6+
7+
Edit the banner text in the body of `src/content/banner/en.mdx`.
8+
9+
Within the file's metadata:
10+
- Change the `title` metadata to a new slug for each message. This does not get displayed anywhere, but it gets recorded when a user dismisses the banner. This way, we can hide that banner for the user the next time they return, but still show them a new banner when we create a new message.
11+
- Make sure `hidden` is `true` for the banner to be visible
12+
13+
## Translating banners
14+
15+
Copy the `en.mdx` file to `${locale}.mdx` (e.g. `es.mdx`) and translate just the body text, leaving the metadata the same.
16+
17+
## Removing a banner
18+
19+
- Set `hidden` to `true` in `src/content/banner/en.mdx`
20+
- Delete any translations of the banner that have been made in non-`en` locales.
21+
22+
This is to make sure that the next time a new banner is made, there is a clean slate to start from for translations.

docs/content_overview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545

4646
## About page
4747

48-
- All translations are stored in `/src/content/text-detail/[lang]/about.mdx` (where `[lang]` is the appropriate language code)
48+
- All translations for the first half of the page are stored in `/src/content/text-detail/[lang]/about.mdx` (where `[lang]` is the appropriate language code)
49+
- The second half of the page (from the "People" section to the bottom) is in `/src/layouts/AboutLayout.astro`
4950

5051
## Simple static pages (like Privacy Policy and Code of Conduct)
5152

src/components/Banner/index.astro

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
import { Icon } from "@components/Icon"
3+
const { entry } = Astro.props;
4+
const { Content } = await entry.render();
5+
const { link, title } = entry.data;
6+
---
7+
8+
<div class="banner bg-accent-color text-accent-type-color" style={{ display: 'none' }} data-title={title}>
9+
<a class="banner-content" href={link} target="_blank">
10+
<Content />
11+
</a>
12+
<button id="hideBanner"><Icon kind="close"></button>
13+
</div>
14+
15+
<script>
16+
const banner = document.querySelector('.banner');
17+
const hideBannerBtn = document.querySelector('#hideBanner');
18+
if (banner && hideBannerBtn) {
19+
const hiddenBanner = window.localStorage.getItem('hideBanner');
20+
const title = banner.getAttribute('data-title');
21+
if (hiddenBanner !== title) {
22+
banner.removeAttribute('style');
23+
}
24+
const hideBanner = () => {
25+
banner.setAttribute('style', 'display: none');
26+
try {
27+
window.localStorage.setItem('hideBanner', title || '');
28+
} catch (e) {
29+
console.error(e);
30+
}
31+
}
32+
hideBannerBtn.addEventListener('click', hideBanner);
33+
}
34+
</script>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script src="https://donorbox.org/widget.js"></script>
22
<!-- @ts-expect-error -->
3-
<div class="rounded-lg overflow-hidden mt-md pb-0 max-w-[420px] min-w-[250px]">
3+
<div class="overflow-hidden mt-md pb-0 max-w-[420px] min-w-[250px]">
44
<iframe
55
allowpaymentrequest=""
66
height="525"
@@ -9,6 +9,7 @@
99
name="donorbox"
1010
src="https://donorbox.org/embed/support-the-processing-foundation?hide_donation_meter=true"
1111
style="max-width: 420px; min-width: 250px; max-height:none !important;"
12+
class="rounded-lg"
1213
>
1314
</iframe>
1415
</div>

src/components/Footer/index.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
---
2+
import { getEntry } from "astro:content";
23
import { getCurrentLocale, getUiTranslator } from "@/src/i18n/utils";
34
import { Icon } from "../Icon";
5+
import Banner from "@components/Banner/index.astro";
46
57
const currentLocale = getCurrentLocale(Astro.url.pathname);
68
const t = await getUiTranslator(currentLocale);
9+
10+
const bannerEntry = await getEntry("banner", currentLocale);
711
---
812

913
<footer
@@ -48,7 +52,6 @@ const t = await getUiTranslator(currentLocale);
4852
<ul aria-labelledby="socials-footer-category">
4953
<li><a href="https://github.com/processing/p5.js">GitHub</a></li>
5054
<li><a href="https://www.instagram.com/p5xjs/">Instagram</a></li>
51-
<li><a href="https://www.facebook.com/groups/p5dotjs/">Facebook</a></li>
5255
<li><a href="https://www.youtube.com/@pjs-dz1rv">YouTube</a></li>
5356
<li><a href="https://twitter.com/p5xjs">X</a></li>
5457
<li><a href="https://discord.gg/SHQ8dH25r9">Discord</a></li>
@@ -59,5 +62,6 @@ const t = await getUiTranslator(currentLocale);
5962
</div>
6063
</div>
6164
</footer>
65+
{bannerEntry && !bannerEntry.data.hidden && (<Banner entry={bannerEntry} />)}
6266

6367
<style></style>

src/components/GridItem/Example.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ const { item, lazyLoad } = Astro.props;
2020
alt={item.data.featuredImageAlt}
2121
widths={[325, 400]}
2222
sizes={`325px, (min-width: 768px) 400px`}
23-
class="w-3/5"
2423
loading={lazyLoad ? "lazy" : "eager"}
24+
class="w-3/5"
25+
visibleAltTextClass="max-w-[calc(60%-30px)]"
2526
/>
27+
<!-- visible alt text class keeps the alt text within
28+
the narrower image width given in class prop -->
2629
<p class="text-body mt-xs break-words break-keep group-hover:underline">
2730
{item.data.title}
2831
</p>

src/components/GridItem/Library.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ if (!/[.!]\)?$/.test(description)) {
3434
alt={item.data.featuredImageAlt}
3535
width="400"
3636
class="w-3/5"
37+
visibleAltTextClass="max-w-[calc(60%-30px)]"
3738
/>
39+
<!-- visible alt text class keeps the alt text within
40+
the narrower image width given in class prop -->
3841
<p
3942
class="text-xl mt-xs text-wrap break-words break-keep group-hover:underline"
4043
>

src/components/Image/index.astro

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
---
2+
import { getCurrentLocale, getUiTranslator } from "@/src/i18n/utils";
23
import type { ComponentProps } from "astro/types";
34
import { Image } from "astro:assets";
45
type Props = ComponentProps<typeof Image> & {
56
/** Defaults to 'photo' aspect ratio */
67
aspectRatio?: "photo" | "square" | "none";
78
caption?: string;
9+
containerClass?: string;
10+
visibleAltTextClass?: string;
811
};
912
const { props } = Astro;
13+
14+
const currentLocale = getCurrentLocale(Astro.url.pathname);
15+
const t = await getUiTranslator(currentLocale);
16+
const noAltText = t("No alt text");
1017
---
1118

12-
<div class="relative w-fit h-fit">
19+
<div class={props.containerClass || "relative w-fit h-fit"}>
1320
<!-- The props are identical but the lack of "IntrinsicAttributes" gives an errant ts error -->
1421
<!-- @ts-ignore -->
1522
<Image
1623
{...props}
1724
class=""
18-
class:list={(props.class,
19-
{
20-
"object-cover": props.aspectRatio !== "none",
21-
"aspect-square": props.aspectRatio === "square",
22-
"aspect-photo":
23-
props.aspectRatio === "photo" || props.aspectRatio === undefined,
24-
})}
25+
class:list={[
26+
props.class,
27+
{
28+
"object-cover": props.aspectRatio !== "none",
29+
"aspect-square": props.aspectRatio === "square",
30+
"aspect-photo":
31+
props.aspectRatio === "photo" || props.aspectRatio === undefined,
32+
},
33+
]}
2534
/>
2635
<p
2736
aria-hidden
28-
class="renderable-alt bg-bg-gray-40 line-clamp-3 absolute top-0 mt-sm mx-sm px-[7.5px] pb-[2.5px] rounded-xl text-body-caption text-ellipsis"
37+
class:list={[
38+
"renderable-alt",
39+
"text-body-caption",
40+
"bg-bg-gray-40 line-clamp-3 absolute top-0 mt-sm mx-sm px-[7.5px] pb-[2.5px] rounded-xl text-ellipsis",
41+
props.visibleAltTextClass,
42+
]}
2943
>
30-
{props.alt}
44+
<!-- It shouldn't be possible to pass no alt text, but if its missing
45+
show a '?' so the component doesn't look broken -->
46+
{props.alt || noAltText}
3147
</p>
3248
{props.caption && <p class="text-body-caption mt-xs">{props.caption}</p>}
3349
</div>

src/components/PageHeader/HomePage.astro

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import Image from "@components/Image/index.astro";
23
import type { CollectionEntry } from "astro:content";
34
import { Icon } from "../Icon";
45
@@ -32,9 +33,11 @@ const { config } = Astro.props;
3233

3334
{
3435
config.data.heroImages.map((im, i) => (
35-
<img
36-
class={`hero-image ${i > 0 ? "hidden" : ""}`}
37-
src={im.image.src}
36+
<Image
37+
containerClass={`relative hero-image-container ${i > 0 ? "hidden" : ""}`}
38+
class={"hero-image"}
39+
aspectRatio="none"
40+
src={im.image}
3841
alt={im.altText}
3942
loading={i > 0 ? "lazy" : "eager"}
4043
/>
@@ -45,9 +48,9 @@ const { config } = Astro.props;
4548
<script>
4649
document.addEventListener("DOMContentLoaded", (event) => {
4750
// find all hero image elements
48-
const images = document.querySelectorAll("img.hero-image");
51+
const images = document.querySelectorAll(".hero-image-container");
4952
if (images.length > 1) {
50-
const shownImageInd = Math.round(Math.random() * images.length);
53+
const shownImageInd = Math.round(Math.random() * (images.length - 1));
5154
// hide the default one
5255
images[0].classList.add("hidden");
5356
// show a random one

src/components/ReferenceDirectoryWithFilter/index.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,18 @@ export const ReferenceDirectoryWithFilter = ({
104104
</div>
105105
);
106106

107+
const subcatShouldHaveHeading = (
108+
subcat: { name: string },
109+
category: { name: string },
110+
) => {
111+
return !(!subcat.name || !category.name || subcat.name === "p5.sound");
112+
}
113+
107114
const getSubcatHeading = (
108115
subcat: { name: string },
109116
category: { name: string },
110117
) => {
111-
if (!subcat.name || !category.name || subcat.name === "p5.sound") {
118+
if (!subcatShouldHaveHeading(subcat, category)) {
112119
return null;
113120
}
114121

@@ -136,7 +143,14 @@ export const ReferenceDirectoryWithFilter = ({
136143
}
137144
return filteredEntries.map((category) => (
138145
<section key={category.name}>
139-
<h2 class="mb-0" id={category.name}>
146+
<h2
147+
class={
148+
subcatShouldHaveHeading(category.subcats[0], category)
149+
? "mb-0"
150+
: "mb-[var(--gutter-md)]"
151+
}
152+
id={category.name}
153+
>
140154
{category.name}
141155
</h2>
142156
{category.subcats.map((subcat) => (

0 commit comments

Comments
 (0)