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

Dynamic year filter #155

Merged
merged 3 commits into from
Dec 6, 2023
Merged

Dynamic year filter #155

merged 3 commits into from
Dec 6, 2023

Conversation

Shane98c
Copy link
Member

@Shane98c Shane98c commented Dec 5, 2023

The year list is dynamic now!

I made things more complicated tho -- I changed the variable names to use years plural for what feels like more clarity, but I may not be conceptualizing things correctly cause I see the singular naming on the press page for the format variable...

const initFormat = {
  print: true,
  audio: true,
  video: true,
}

https://github.com/carbonplan/carbonplan.org/blob/7827a44a218dd8ce01caf8de1986edd3d4272baa/pages/press.js#L105-L109

Any reason to lean one way or the other on this?

Not a huge thing obviously, just curious!

cc @katamartin

Copy link

vercel bot commented Dec 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2023 2:58pm

Copy link
Member

@katamartin katamartin left a comment

Choose a reason for hiding this comment

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

This looks great to me!

On the naming of values prop passed to the Filter component, I don't think we're very consistent with that. I think the plural is definitely more readable here!

The only argument I can think of for using the singular would maaaybe be in the case where the Filter is operating like a radio button, so the values value really reflects a single "active" value. But the values object is always going to contain multiple keys and represent the state for multiple options, so even in that case plural might be better 🤔

2021: true,
2022: true,
2023: true,
const currentYear = new Date().getFullYear()
Copy link
Member

Choose a reason for hiding this comment

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

Ooh actually, I'm realizing that this will probably be evaluated at build time, so might require triggering a new deployment in order to update around the New Year. That wouldn't be a huge deal, but turning this into a function that gets invoked within Main (similar to what you did in the Footer PR) should ensure we always render the latest!

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yep that makes sense! gotta get my mind in the ssr world!

Copy link
Member

@katamartin katamartin left a comment

Choose a reason for hiding this comment

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

:shipit:

@Shane98c Shane98c merged commit 82d7d68 into main Dec 6, 2023
9 checks passed
@Shane98c Shane98c deleted the dynamic-year-filter branch December 6, 2023 15:02
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.

2 participants