Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fixes #228, adds optin status messages to panelWelcome
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanml committed Oct 23, 2018
1 parent 046ebcf commit ffd6275
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 14 deletions.
53 changes: 43 additions & 10 deletions src/features/rewards/panelWelcome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ import {
StyledDescText,
StyledFooterText,
StyledButtonWrapper,
StyledTrademark
StyledTrademark,
StyledErrorMessage
} from './style'

import { BatColorIcon } from '../../../components/icons'
import { BatColorIcon, LoaderIcon } from '../../../components/icons'
import Button from '../../../components/buttonsIndicators/button'

export type Variant = 'one' | 'two'

export interface Props {
id?: string
variant?: Variant
creating?: boolean
error?: boolean
moreLink?: () => void
optInAction: () => void
optInErrorAction: () => void
}

export default class PanelWelcome extends React.PureComponent<Props, {}> {
Expand All @@ -50,7 +54,7 @@ export default class PanelWelcome extends React.PureComponent<Props, {}> {
}

render () {
const { id, optInAction, moreLink } = this.props
const { id, optInAction, optInErrorAction, moreLink } = this.props

let props = {}

Expand All @@ -77,13 +81,42 @@ export default class PanelWelcome extends React.PureComponent<Props, {}> {
{getLocale(this.locale.desc)}
</StyledDescText>
<StyledButtonWrapper>
<Button
size='call-to-action'
type='subtle'
level='secondary'
onClick={optInAction}
text={getLocale(this.locale.button)}
/>
{
this.props.creating && !this.props.error
? <Button
level='secondary'
size='call-to-action'
type='subtle'
text={getLocale('braveRewardsCreatingText')}
disabled={true}
data-test-id='optInAction'
icon={{
image: <LoaderIcon />,
position: 'after'
}}
/>
: this.props.error
? <>
<StyledErrorMessage>
{getLocale('walletFailedTitle')}
</StyledErrorMessage>
<Button
level='secondary'
size='call-to-action'
type='subtle'
text={getLocale('tryAgain')}
onClick={optInErrorAction}
data-test-id='optInErrorAction'
/>
</>
: <Button
size='call-to-action'
type='subtle'
level='secondary'
onClick={optInAction}
text={getLocale(this.locale.button)}
/>
}
</StyledButtonWrapper>
<StyledFooterText {...props}>
{getLocale(this.locale.footer)}
Expand Down
8 changes: 8 additions & 0 deletions src/features/rewards/panelWelcome/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ export const StyledTrademark = styled<{}, 'span'>('span')`
font-weight: 500;
opacity: 0.7;
` as any

export const StyledErrorMessage = styled<{}, 'span'>('span')`
font-size: 16px;
display: block;
margin: 0px auto 20px;
line-height: 28px;
color: #FFF;
`
1 change: 1 addition & 0 deletions stories/assets/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const locale: Record<string, string> = {
tokens: 'tokens',
total: 'Total',
transactions: 'Transactions',
tryAgain: 'Try Again',
turnOnRewardsDesc: 'This enables both Brave Ads and Auto-Contribute. You can always opt out each any time.',
turnOnRewardsTitle: 'Turn on Rewards',
type: 'Type',
Expand Down
22 changes: 18 additions & 4 deletions stories/features/rewards/concepts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,39 @@ storiesOf('Feature Components/Rewards/Concepts/Desktop', module)
</div>
)
}))
.add('Pre Opt-In', () => {
.add('Pre Opt-In', withState({ creatingOne: false, creatingTwo: false }, (store) => {
const creatingOne = () => {
store.set({ creatingOne: true })
}

const creatingTwo = () => {
store.set({ creatingTwo: true })
}

return (
<div style={{ background: `url(${tipScreen}) no-repeat top center`, width: '986px', height: '912px', margin: '0 auto', position: 'relative' }}>
<div style={{ position: 'absolute', top: '40px', left: '120px', width: '373px', minHeight: '446px', borderRadius: '8px', overflow: 'hidden' }}>
<PanelWelcome
variant={'one'}
optInAction={dummyOptInAction}
creating={store.state.creatingOne}
optInAction={creatingOne}
moreLink={dummyOptInAction}
optInErrorAction={dummyOptInAction}
error={boolean('Wallet Creation Error', false)}
/>
</div>
<div style={{ position: 'absolute', top: '40px', left: '565px', width: '373px', minHeight: '446px', borderRadius: '8px', overflow: 'hidden' }}>
<PanelWelcome
variant={'two'}
optInAction={dummyOptInAction}
optInAction={creatingTwo}
creating={store.state.creatingTwo}
optInErrorAction={dummyOptInAction}
error={boolean('Wallet Creation Error', false)}
/>
</div>
</div>
)
})
}))
.add('Wallet Panel', withState({ showSummary: false, tipsEnabled: true, includeInAuto: true }, (store) => {
const curveRgb = '233,235,255'
const panelRgb = '249,251,252'
Expand Down

0 comments on commit ffd6275

Please sign in to comment.