-
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
Refactor to make the reminder button configurable #430
Changes from all commits
4b78247
31fcac2
d248629
23f2423
c521149
cad223e
f1563d0
78a2f0f
e171991
b70f05e
7b23d5b
d8323d1
75e0915
c7a1cbb
6d5aa3c
8a09e5c
45e1323
345d7d4
0406c5f
7b52fad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { replaceNonArticleCountPlaceholders } from './placeholders'; | |
import { TrackClick } from '../utils/tracking'; | ||
import { FetchEmail } from '../types/dcrTypes'; | ||
import { ReminderStage } from '../logic/reminders'; | ||
import { ReminderButtonColorStyles } from '../styles/colorData'; | ||
import { HeaderSection } from './HeaderSection'; | ||
|
||
// Custom styles for <a> tags in the Epic content | ||
|
@@ -64,6 +65,13 @@ const styles = { | |
`, | ||
}; | ||
|
||
const defaultColors: ReminderButtonColorStyles = { | ||
styleReminderButton: '#121212', | ||
styleReminderButtonBackground: '#ededed', | ||
styleReminderButtonHover: '#dcdcdc', | ||
styleReminderAnimation: '#707070', | ||
}; | ||
|
||
export type BrazeMessageProps = { | ||
buttonText?: string; | ||
buttonUrl?: string; | ||
|
@@ -171,11 +179,13 @@ export const Epic: React.FC<EpicProps> = (props: EpicProps) => { | |
/> | ||
{reminderStage && ( | ||
<ReminderCtaButton | ||
reminderComponent="EPIC" | ||
reminderStage={reminderStage} | ||
reminderOption={reminderOption} | ||
ophanComponentId={ophanComponentId as string} | ||
trackClick={trackClick} | ||
fetchEmail={fetchEmail} | ||
userStyles={defaultColors} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about calling this prop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take this forward in the next PR |
||
/> | ||
)} | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,36 +2,42 @@ import React, { useState } from 'react'; | |
import { Button, LinkButton, SvgCross } from '@guardian/source-react-components'; | ||
import { useEscapeShortcut, OnCloseClick, CLOSE_BUTTON_ID } from '../bannerCommon/bannerActions'; | ||
import type { TrackClick } from '../utils/tracking'; | ||
import { StyleData, selfServeStyles } from '../styles/bannerCommon'; | ||
import { StyleableBannerColorStyles } from '../styles/colorData'; | ||
import { selfServeStyles } from '../styles/bannerCommon'; | ||
import { canRender, COMPONENT_NAME } from './canRender'; | ||
import { PaymentIcons } from '../components/PaymentIcons'; | ||
export { COMPONENT_NAME }; | ||
|
||
export type BrazeMessageProps = { | ||
ophanComponentId?: string; | ||
styleBackground?: string; | ||
header?: string; | ||
styleHeader?: string; | ||
body?: string; | ||
styleBody?: string; | ||
highlight?: string; | ||
styleHighlight?: string; | ||
styleHighlightBackground?: string; | ||
buttonText?: string; | ||
buttonUrl?: string; | ||
showPaymentIcons?: string; | ||
styleButton?: string; | ||
styleButtonBackground?: string; | ||
styleButtonHover?: string; | ||
includeReminderCta?: string; | ||
imageUrl?: string; | ||
imageAltText?: string; | ||
imagePosition?: string; | ||
styleBackground?: string; | ||
styleHeader?: string; | ||
styleBody?: string; | ||
styleHighlight?: string; | ||
styleHighlightBackground?: string; | ||
styleButton?: string; | ||
styleButtonBackground?: string; | ||
styleButtonHover?: string; | ||
styleReminderButton?: string; | ||
styleReminderButtonBackground?: string; | ||
styleReminderButtonHover?: string; | ||
styleReminderAnimation?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea to group these together, I think it makes it easier to understand what's configurable colour-wise here 👍 |
||
styleClose?: string; | ||
styleCloseBackground?: string; | ||
styleCloseHover?: string; | ||
}; | ||
|
||
const defaultColors: StyleData = { | ||
const defaultColors: StyleableBannerColorStyles = { | ||
styleBackground: '#ededed', | ||
styleHeader: '#333333', | ||
styleBody: '#333333', | ||
|
@@ -40,6 +46,10 @@ const defaultColors: StyleData = { | |
styleButton: '#ffffff', | ||
styleButtonBackground: '#052962', | ||
styleButtonHover: '#234b8a', | ||
styleReminderButton: '#121212', | ||
styleReminderButtonBackground: '#ededed', | ||
styleReminderButtonHover: '#dcdcdc', | ||
styleReminderAnimation: '#707070', | ||
styleClose: '#052962', | ||
styleCloseBackground: '#ededed', | ||
styleCloseHover: '#e5e5e5', | ||
|
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.
I think a thing that's been confusing me about the configurable colours is that
AppBanner
,BannerNewsletter
& friends, which don't support configuring the colours, still callselfServeStyles
. I think that's becauseselfServeStyles
serves two purposes:In the case of the banners which don't have configurable colours, we only need the second of those two purposes. This could be done in a follow up PR, but I think it would improve the understandability of the code to de-couple those two things. So instead of
selfServeStyles
taking user provided colours and defaults it just takes colours which are guaranteed to be present and returns the CSS. It wouldn't have to care about where the colours came from (forAppBanner
etc they'd be hardcoded, forStyleableBannnerWithLink
they come from combining user provided colours with defaults). At the top level ofStyleableBannerWithLink
it'd have to do the combining of user provided colours and defaults, usinggetColors
, andselfServeStyles
wouldn't callgetColors
.Thoughts?
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.
My long-term utopia is to have a single epic component, and a single banner component (both styleable, though in the case of the epic limited to eg CTA button colours) which Retention can setup/preview in Storybook. Though the competing vision of being able to use RRCP banner/epic designs from Braze is an even better utopia destination.