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

Adds Wallet creation loader and failure message to panel opt in #229

Merged
merged 1 commit into from
Oct 23, 2018
Merged
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
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('walletFailedButton')}
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;
`
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