-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
Deploying ui2 with Cloudflare Pages
|
There was a problem hiding this 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)": { |
There was a problem hiding this comment.
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?
"@media (max-width: 767px)": { | |
[theme.breakpoints.down("sm")]: { |
There was a problem hiding this comment.
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)": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before
"@media (max-width: 767px)": { | |
[theme!.breakpoints.down("sm")]: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
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", | ||
}, | ||
})) |
There was a problem hiding this comment.
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
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", | |
}, | |
} | |
}) |
There was a problem hiding this comment.
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 }) => ({ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
export const MarketingBanner: React.FC<MarketingBannerProps> = ({ | ||
id, | ||
environment, | ||
token, | ||
space, | ||
locale = Locales.enUS, | ||
}) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Outdated
`https://cdn.contentful.com/spaces/${space}/environments/${environment}/entries/?` + | ||
new URLSearchParams({ | ||
"sys.id": id, | ||
content_type: "banner", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/hooks/contenful/contentful.ts
Outdated
) | ||
|
||
if (!response.ok) { | ||
throw new Error("Failed to fetch banner data") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
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.