Skip to content

Issue #505: create RandomContent component and example demo on BlogLayout#560

Draft
lsr-explore wants to merge 1 commit into
mainfrom
lsr-explore/gh-505/content-randomizer-component
Draft

Issue #505: create RandomContent component and example demo on BlogLayout#560
lsr-explore wants to merge 1 commit into
mainfrom
lsr-explore/gh-505/content-randomizer-component

Conversation

@lsr-explore
Copy link
Copy Markdown
Contributor

@lsr-explore lsr-explore commented May 10, 2026

Fixes

Note

Remove demo on the Blog page before marking as ready for review.

Description

Created RandomContent component.
Created demo in BlogLayout - it will not be checked in.

Video clip

Screen.Recording.2026-05-09.at.7.42.39.PM.mov

@netlify
Copy link
Copy Markdown

netlify Bot commented May 10, 2026

Deploy Preview for accessiblecommunity ready!

Name Link
🔨 Latest commit 7825d7b
🔍 Latest deploy log https://app.netlify.com/projects/accessiblecommunity/deploys/69fff1187476fa00080cd271
😎 Deploy Preview https://deploy-preview-560--accessiblecommunity.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

import FlexColumn from "@components/FlexColumn.astro";
import ImageHeading from "@components/ImageHeading.astro";
import Layout from "./Layout.astro";
import RandomContent from "@components/RandomContent.astro";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Changes to this file - BlogLayout are just to demonstrated the component. They will be removed in the final PR>

))}
</RandomContent>
</ThemedSection>
)}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Changes to this file - BlogLayout are just to demonstrated the component. They will be removed in the final PR>

Copy link
Copy Markdown
Contributor

@brian-montgomery brian-montgomery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense... A component which selects a random child and shows it. Meaning the static build stays the entire time. I like it Laurie good job. Good job, Laurie.

One addition may be an attribute about how many of the children to show (I can see examples of a Hero where we want 2-3 random Call to Actions, for instance).

});
}
randomize();
document.addEventListener("astro:after-swap", randomize);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of this.

/* Pre-JS / no-JS fallback: show only the first child. */
/* `is:global` because the children come from a slot (consumer-rendered),
so they don't get this component's scoped class. */
[data-random-content]:not([data-random-ready]) > *:nth-child(n + 2) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do the following:

  :global([data-random-content]:not([data-random-ready])) > *:nth-child(n + 2) {
      ...
   }

and therefore won't need the is:global addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Component: Content Randomizer

2 participants