Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const CarouselTemplate = ({ cardButton }) => {
const cardItems = feeds?.map((feed, index) =>
cardRow(feed, index, cardButton)
);

return (
<NewsWrapper>
<CardCarousel
Expand Down
12 changes: 7 additions & 5 deletions packages/component-news/src/components/CardGridNews/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NewsWrapper } from "./index.styles";
* @param {Object} feed
* @param {import("../../core/types/news-types").CardButton} cardButton
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Missing JSDoc parameter documentation for the new hideTags parameter. Should add @param {boolean} hideTags to match the pattern used in CardListlNews.

Suggested change
* @param {import("../../core/types/news-types").CardButton} cardButton
* @param {import("../../core/types/news-types").CardButton} cardButton
* @param {boolean} hideTags

Copilot uses AI. Check for mistakes.

*/
const gridRow = (feed, cardButton) => (
const gridRow = (feed, cardButton, hideTags) => (
<div
className="col col-12 col-md-6 col-lg-4 cards-items-container"
key={feed.id}
Expand All @@ -38,7 +38,7 @@ const gridRow = (feed, cardButton) => (
href: feed.buttonLink,
},
]}
tags={parseInterests(feed?.interests)}
tags={hideTags ? [] : parseInterests(feed?.interests)}
/>
</div>
);
Expand All @@ -47,13 +47,14 @@ const gridRow = (feed, cardButton) => (
* @param {import("../../core/types/news-types").TemplateProps} props
*/

const GridTemplate = ({ cardButton }) => {
const GridTemplate = ({ cardButton, hideTags }) => {
const { feeds } = useContext(FeedContext); // Reading the "feeds" object from the context
const shouldHideTags = hideTags === true || hideTags === "true";

return (
<NewsWrapper className="row row-spaced" data-testid="grid-view-container">
{feeds?.map((feed, index) => (
<React.Fragment key={index}>{gridRow(feed, cardButton)}</React.Fragment>
<React.Fragment key={index}>{gridRow(feed, cardButton, shouldHideTags)}</React.Fragment>
))}
</NewsWrapper>
);
Expand All @@ -67,7 +68,7 @@ const GridTemplate = ({ cardButton }) => {
/**
* @param {FeedType} props
*/
const CardGridNews = ({ cardButton, ...props }) => {
const CardGridNews = ({ cardButton, hideTags = true, ...props }) => {
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Missing PropTypes validation for the hideTags prop. Should include the same validation as CardListlNews: hideTags: PropTypes.oneOf([\"true\", \"false\", true, false])

Copilot uses AI. Check for mistakes.

useEffect(() => {
if (typeof window !== "undefined") {
trackReactComponent({
Expand All @@ -87,6 +88,7 @@ const CardGridNews = ({ cardButton, ...props }) => {
<BaseFeed {...props}>
<GridTemplate
cardButton={{ ...defaultProps.cardButton, ...cardButton }}
hideTags={hideTags}
/>
</BaseFeed>
);
Expand Down
16 changes: 10 additions & 6 deletions packages/component-news/src/components/CardListlNews/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import { BaseFeed } from "../../core/components/BaseFeed";
import { defaultProps } from "../../core/constants/default-props";
import { parseInterests } from "../../core/utils";
import { NewsWrapper } from "./index.styles";
import PropTypes from "prop-types";

/**
* @param {object} feed
* @param {import("../../core/types/news-types").CardButton} cardButton
* @param {boolean} hideTags
*/
const listRow = (feed, cardButton) => (
const listRow = (feed, cardButton, hideTags) => (
<div className="card card-hover cards-items-container" key={feed.id}>
<Card
type="story"
Expand All @@ -35,7 +37,7 @@ const listRow = (feed, cardButton) => (
href: feed.buttonLink,
},
]}
tags={parseInterests(feed?.interests)}
tags={hideTags ? [] : parseInterests(feed?.interests)}
/>
</div>
);
Expand All @@ -44,13 +46,14 @@ const listRow = (feed, cardButton) => (
* @param {import("../../core/types/news-types").TemplateProps} props
*/

const ListTemplate = ({ cardButton }) => {
const ListTemplate = ({ cardButton, hideTags }) => {
const { feeds } = useContext(FeedContext); // Reading the "feeds" object from the context
const shouldHideTags = hideTags === true || hideTags === "true";

return (
<NewsWrapper className="row-spaced" data-testid="list-view-container">
{feeds?.map((feed, index) => (
<React.Fragment key={index}>{listRow(feed, cardButton)}</React.Fragment>
<React.Fragment key={index}>{listRow(feed, cardButton, shouldHideTags)}</React.Fragment>
))}
</NewsWrapper>
);
Expand All @@ -64,7 +67,7 @@ const ListTemplate = ({ cardButton }) => {
/**
* @param {FeedType} props
*/
const CardListlNews = ({ cardButton, ...props }) => {
const CardListlNews = ({ cardButton, hideTags = true, ...props }) => {
useEffect(() => {
if (typeof window !== "undefined") {
trackReactComponent({
Expand All @@ -84,11 +87,12 @@ const CardListlNews = ({ cardButton, ...props }) => {
<BaseFeed {...props}>
<ListTemplate
cardButton={{ ...defaultProps.cardButton, ...cardButton }}
hideTags={hideTags}
/>
</BaseFeed>
);
};

CardListlNews.propTypes = { ...BaseFeed.propTypes, feedCardButtonShape };
CardListlNews.propTypes = { ...BaseFeed.propTypes, feedCardButtonShape, hideTags: PropTypes.oneOf(["true", "false", true, false]) };

export { CardListlNews };
1 change: 1 addition & 0 deletions packages/component-news/src/core/types/news-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @ignore
* @typedef {Object} TemplateProps
* @property {CardButton} cardButton
* @property {"true" | "false" | boolean} [hideTags]
*/

/**
Expand Down