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

Pressroom releases #295

Merged
merged 6 commits into from
Apr 2, 2024
Merged

Pressroom releases #295

merged 6 commits into from
Apr 2, 2024

Conversation

DiogoSoaress
Copy link
Member

What it solves

Adds the Press releases section on the Pressroom page
Refactors the quick categories filter to its own component in the /common folder

Screenshots

Screenshot 2024-03-25 at 11 02 40

Figma

https://www.figma.com/file/zNUgOvD1WcFankfXfBiAfs/Press-room?type=design&node-id=9929-4249&mode=design&t=x13Zf5TNtfe0ytJN-0

Copy link

github-actions bot commented Mar 25, 2024

Branch preview

✅ Deployed successfully in branch deployment:

https://pressroom_releases--homepage.review.5afe.dev

Copy link

github-actions bot commented Mar 25, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Comment on lines 37 to 42
onClick={() => handleToggleCategory(category)}
>
<Typography>
{category}
{isSelected && (
<IconButton className={css.closeFilter} onClick={() => handleToggleCategory(category)}>
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we can remove the duplication by creating a handler for () => handleToggleCategory(category).


const PAGE_QUERY_PARAM = 'page'

export const getPage = (query: NextRouter['query']): number => {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd suggest moving this to a utility file as it is used in multiple components.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this! I wanted to extract it to an util function but forgot.

@DiogoSoaress DiogoSoaress requested a review from iamacook April 2, 2024 09:57
Comment on lines 11 to 43
const handleToggleCategory = (category: string) => () => {
const queryParams = { ...router.query }

if (queryParams.category === category) {
delete queryParams.category
} else {
queryParams.category = category
}

router.push(
{
query: queryParams,
},
undefined,
{ shallow: true },
)
}

return (
<Grid container className={css.filterWrapper}>
{categories.map((category) => {
const isSelected = category === selectedCategory

return (
<Grid item key={category} className={css.filterCard} xs={12} md="auto">
<ButtonBase
className={clsx(css.filterButton, { [css.selected]: isSelected })}
onClick={handleToggleCategory(category)}
>
<Typography>
{category}
{isSelected && (
<IconButton className={css.closeFilter} onClick={handleToggleCategory(category)}>
Copy link
Member

Choose a reason for hiding this comment

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

Currying this still creates the function twice. You can create it within the map once, e.g.

Suggested change
const handleToggleCategory = (category: string) => () => {
const queryParams = { ...router.query }
if (queryParams.category === category) {
delete queryParams.category
} else {
queryParams.category = category
}
router.push(
{
query: queryParams,
},
undefined,
{ shallow: true },
)
}
return (
<Grid container className={css.filterWrapper}>
{categories.map((category) => {
const isSelected = category === selectedCategory
return (
<Grid item key={category} className={css.filterCard} xs={12} md="auto">
<ButtonBase
className={clsx(css.filterButton, { [css.selected]: isSelected })}
onClick={handleToggleCategory(category)}
>
<Typography>
{category}
{isSelected && (
<IconButton className={css.closeFilter} onClick={handleToggleCategory(category)}>
const handleToggleCategory = (category: string) => {
const queryParams = { ...router.query }
if (queryParams.category === category) {
delete queryParams.category
} else {
queryParams.category = category
}
router.push(
{
query: queryParams,
},
undefined,
{ shallow: true },
)
}
return (
<Grid container className={css.filterWrapper}>
{categories.map((category) => {
const isSelected = category === selectedCategory
const handleToggle = () => handleToggleCategory(category)
return (
<Grid item key={category} className={css.filterCard} xs={12} md="auto">
<ButtonBase
className={clsx(css.filterButton, { [css.selected]: isSelected })}
onClick={handleToggle}
>
<Typography>
{category}
{isSelected && (
<IconButton className={css.closeFilter} onClick={handleToggle}>

Copy link
Member Author

Choose a reason for hiding this comment

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

WDYT of memoizing the function with useCallback ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the handler inside of the mapping function

@DiogoSoaress DiogoSoaress requested a review from iamacook April 2, 2024 13:12
@DiogoSoaress DiogoSoaress merged commit 7f0b2dc into main Apr 2, 2024
5 checks passed
@DiogoSoaress DiogoSoaress deleted the pressroom-releases branch April 2, 2024 13:59
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants