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

feat: Add the Marketing Banner component #218

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

LautaroPetaccio
Copy link
Contributor

This PR creates a new component, the MarketingBanner, used to show via Contentful a banner based on its entity id.
It also adds a hook to retrieve information from a Contentful entity that can be used for other purposes.

Copy link

cloudflare-workers-and-pages bot commented Jan 10, 2025

Deploying ui2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: b535645
Status: ✅  Deploy successful!
Preview URL: https://dbdacd14.ui2-423.pages.dev
Branch Preview URL: https://feat-add-marketing-banner.ui2-423.pages.dev

View logs

Copy link
Collaborator

@braianj braianj left a comment

Choose a reason for hiding this comment

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

LGTM, but I leave some small comments

margin: 0,
padding: 0,
},
"@media (max-width: 767px)": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use the breakpoints from the theme here as this, what do you think?

Suggested change
"@media (max-width: 767px)": {
[theme.breakpoints.down("sm")]: {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

display: "flex",
marginTop: "1rem",
alignItems: convertAlignmentToFlex(desktopAlignment || "left"),
"@media (max-width: 767px)": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as before

Suggested change
"@media (max-width: 767px)": {
[theme!.breakpoints.down("sm")]: {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 92 to 110
const Text = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "mobileTextAlignment" && prop !== "desktopTextAlignment",
})<{
mobileTextAlignment?: Property.TextAlign
desktopTextAlignment?: Property.TextAlign
}>(({ mobileTextAlignment, desktopTextAlignment }) => ({
color: "#fff",
textAlign: desktopTextAlignment || "left",
fontSize: "19px",
"& p": {
margin: 0,
padding: 0,
},
"@media (max-width: 767px)": {
textAlign: mobileTextAlignment || "left",
fontSize: "16px",
},
}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

WDYT about extracting the props inside the function to follow the new standard

Suggested change
const Text = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "mobileTextAlignment" && prop !== "desktopTextAlignment",
})<{
mobileTextAlignment?: Property.TextAlign
desktopTextAlignment?: Property.TextAlign
}>(({ mobileTextAlignment, desktopTextAlignment }) => ({
color: "#fff",
textAlign: desktopTextAlignment || "left",
fontSize: "19px",
"& p": {
margin: 0,
padding: 0,
},
"@media (max-width: 767px)": {
textAlign: mobileTextAlignment || "left",
fontSize: "16px",
},
}))
const Text = styled(Box, {
shouldForwardProp: (prop) =>
prop !== "mobileTextAlignment" && prop !== "desktopTextAlignment",
})<{
mobileTextAlignment?: Property.TextAlign
desktopTextAlignment?: Property.TextAlign
}>((props) => {
const { mobileTextAlignment, desktopTextAlignment, theme } = props
return {
color: "#fff",
textAlign: desktopTextAlignment || "left",
fontSize: "19px",
"& p": {
margin: 0,
padding: 0,
},
[theme.breakpoints.down("sm")]: {
textAlign: mobileTextAlignment || "left",
fontSize: "16px",
},
}
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

})<{
mobileAlignment?: Property.TextAlign
desktopAlignment?: Property.TextAlign
}>(({ mobileAlignment, desktopAlignment }) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here about the props

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 25 to 31
export const MarketingBanner: React.FC<MarketingBannerProps> = ({
id,
environment,
token,
space,
locale = Locales.enUS,
}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here about extracting the props inside the function so we have consistency throw all the repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

src/hooks/contenful/contentful.ts Show resolved Hide resolved
`https://cdn.contentful.com/spaces/${space}/environments/${environment}/entries/?` +
new URLSearchParams({
"sys.id": id,
content_type: "banner",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can I use useGetContentfulEntry to get other kind of entries, right?
Maybe we can pass it throw the props or, change the same of the hook to useGetContentfulBannerEntry. Or even remove the content_type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it so any content type can be used.

)

if (!response.ok) {
throw new Error("Failed to fetch banner data")
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe If we make any of the changes above, we'll need to change these message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@LautaroPetaccio LautaroPetaccio merged commit 365ad79 into master Jan 10, 2025
3 checks passed
@LautaroPetaccio LautaroPetaccio deleted the feat/add-marketing-banner branch January 10, 2025 18:33
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