Skip to content

Commit

Permalink
Fixes brave#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 96f5902
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 13 deletions.
50 changes: 41 additions & 9 deletions src/features/rewards/panelWelcome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ 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
}
Expand Down Expand Up @@ -77,13 +80,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={'Try Again'}
onClick={optInAction}
data-test-id='optInAction'
/>
</>
: <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;
`
20 changes: 16 additions & 4 deletions stories/features/rewards/concepts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,37 @@ 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}
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}
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 96f5902

Please sign in to comment.