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

Commit

Permalink
Changing tipsMigrationAlert -> boxAlert, adding ads variant
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanml committed Mar 20, 2019
1 parent 918e857 commit ac6f2fc
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TipsMigrationAlert tests basic tests matches the snapshot 1`] = `
exports[`BoxAlert tests basic tests matches the snapshot 1`] = `
.c0 {
width: 100%;
display: -webkit-box;
Expand All @@ -27,9 +27,21 @@ exports[`TipsMigrationAlert tests basic tests matches the snapshot 1`] = `
-ms-letter-spacing: 0;
letter-spacing: 0;
line-height: 18px;
padding: 12px 15px 0px 11px;
vertical-align: top;
max-width: 387px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
padding-left: 5px;
}
.c4 {
Expand All @@ -39,30 +51,6 @@ exports[`TipsMigrationAlert tests basic tests matches the snapshot 1`] = `
font-size: inherit;
}
.c5 {
color: #696FDC;
font-weight: 400;
display: inline-block;
font-size: inherit;
}
.c6 {
vertical-align: top;
margin: 20px 0 0 7px;
}
.c7 {
color: #15A4FA;
cursor: pointer;
font-size: 14px;
font-weight: 500;
-webkit-letter-spacing: 0;
-moz-letter-spacing: 0;
-ms-letter-spacing: 0;
letter-spacing: 0;
line-height: 18px;
}
.c2 {
width: 100%;
height: 100%;
Expand Down Expand Up @@ -92,22 +80,7 @@ exports[`TipsMigrationAlert tests basic tests matches the snapshot 1`] = `
<span
className="c4"
>
MISSING: reviewSitesMsg
</span>
<span
className="c5"
>
MISSING: monthlyTips
</span>
</div>
<div
className="c6"
>
<span
className="c7"
onClick={[Function]}
>
MISSING: learnMore
MISSING: adsNotSupported
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ import { Modal } from '../../../components'
import { AlertCircleIcon, RewardsSendTipsIcon } from '../../../components/icons'
import Button from '../../../components/buttonsIndicators/button'

export type Type = 'tips' | 'ads'

export interface Props {
type: Type
testId?: string
onReview: () => void
onReview?: () => void
}

interface State {
modalShown: boolean
}

export default class TipsMigrationAlert extends React.PureComponent<Props, State> {
export default class BoxAlert extends React.PureComponent<Props, State> {
constructor (props: Props) {
super(props)
this.state = {
Expand Down Expand Up @@ -108,28 +111,40 @@ export default class TipsMigrationAlert extends React.PureComponent<Props, State
}

render () {
const { testId } = this.props
const { testId, type } = this.props

return (
<StyledWrapper data-test-id={testId}>
<StyledAlertIcon>
<AlertCircleIcon />
</StyledAlertIcon>
<StyledInfo>
<StyledMessage>
{getLocale('reviewSitesMsg')}
</StyledMessage>
<StyledMonthlyTips>
{getLocale('monthlyTips')}
</StyledMonthlyTips>
<StyledInfo type={type}>
{
type === 'tips'
? <>
<StyledMessage>
{getLocale('reviewSitesMsg')}
</StyledMessage>
<StyledMonthlyTips>
{getLocale('monthlyTips')}
</StyledMonthlyTips>
</>
: <StyledMessage>
{getLocale('adsNotSupported')}
</StyledMessage>
}
</StyledInfo>
<StyledReviewWrapper>
<StyledReviewList onClick={this.toggleModalDisplay}>
{getLocale('learnMore')}
</StyledReviewList>
</StyledReviewWrapper>
{
this.state.modalShown
type === 'tips'
? <StyledReviewWrapper>
<StyledReviewList onClick={this.toggleModalDisplay}>
{getLocale('learnMore')}
</StyledReviewList>
</StyledReviewWrapper>
: null
}
{
this.state.modalShown && type === 'tips'
? this.pinnedSitesModal()
: null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import { create } from 'react-test-renderer'
import TipsMigrationAlert from './index'
import BoxAlert from './index'
import { TestThemeProvider } from '../../../theme'

describe('TipsMigrationAlert tests', () => {
const baseComponent = (props?: object) => <TestThemeProvider><TipsMigrationAlert id='tipsmigrationalert' {...props} /></TestThemeProvider>
describe('BoxAlert tests', () => {
const baseComponent = (props?: object) => <TestThemeProvider><BoxAlert id='box-alert' {...props} /></TestThemeProvider>

describe('basic tests', () => {
it('matches the snapshot', () => {
Expand All @@ -21,7 +21,7 @@ describe('TipsMigrationAlert tests', () => {

it('renders the component', () => {
const wrapper = shallow(baseComponent())
const assertion = wrapper.find('#tipsmigrationalert').length
const assertion = wrapper.find('#box-alert').length
expect(assertion).toBe(1)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Type } from './index'
import styled from 'styled-components'

interface StyleProps {
modal?: boolean
type?: Type
}

export const StyledWrapper = styled<{}, 'div'>('div')`
Expand All @@ -25,13 +27,16 @@ export const StyledAlertIcon = styled<{}, 'div'>('div')`
color: #15A4FA;
`

export const StyledInfo = styled<{}, 'div'>('div')`
export const StyledInfo = styled<StyleProps, 'div'>('div')`
font-size: 14px;
letter-spacing: 0;
line-height: 18px;
padding: 12px 15px 0px 11px;
vertical-align: top;
max-width: 387px;
display: flex;
align-items: center;
justify-content: center;
padding-left: 5px;
`

export const StyledMessage = styled<StyleProps, 'span'>('span')`
Expand Down
4 changes: 2 additions & 2 deletions src/features/rewards/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Alert from './alert'
import Amount from './amount'
import Box from './box'
import BoxAlert from './boxAlert'
import DisabledContent from './disabledContent'
import DisabledPanel from './disabledPanel'
import Donate from './donate'
Expand Down Expand Up @@ -35,7 +36,6 @@ import TableContribute from './tableContribute'
import TableDonation from './tableDonation'
import TableTransactions from './tableTransactions'
import Tip from './tip'
import TipsMigrationAlert from './tipsMigrationAlert'
import ToggleTips from './toggleTips'
import Tokens from './tokens'
import Tooltip from './tooltip'
Expand All @@ -52,6 +52,7 @@ export {
Alert,
Amount,
Box,
BoxAlert,
DisabledContent,
DisabledPanel,
DonationOverlay,
Expand Down Expand Up @@ -82,7 +83,6 @@ export {
TableDonation,
TableTransactions,
Tip,
TipsMigrationAlert,
ToggleTips,
Tokens,
Tooltip,
Expand Down
1 change: 1 addition & 0 deletions stories/assets/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const locale: Record<string, string> = {
addFundsQR: 'Show QR Code',
addFundsText: 'Be sure to use the address below that matches the type of cryto you own. It will be converted automatically to BAT by Uphold and appear as an increased balance in your Brave Rewards wallet. Please allow up to one hour for your wallet balance to update.',
addFundsTitle: 'Send cryptocurrency from your external account to your Brave Rewards wallet.',
adsNotSupported: 'Sorry! Ads are not yet available in your region.',
allowTip: 'Allow tips on',
amount: 'Amount',
and: 'and',
Expand Down
9 changes: 8 additions & 1 deletion stories/features/rewards/settings/adsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as React from 'react'

// Components
import { DisabledContent, Box } from '../../../../src/features/rewards'
import { DisabledContent, Box, BoxAlert } from '../../../../src/features/rewards'

// Utils
import locale from './fakeLocale'
Expand All @@ -22,13 +22,20 @@ class AdsBox extends React.Component {
)
}

adsAlertChild = () => {
return (
<BoxAlert type={'ads'} />
)
}

render () {
return (
<Box
title={locale.adsTitle}
type={'ads'}
description={locale.adsDesc}
toggle={false}
attachedAlert={this.adsAlertChild()}
disabledContent={this.adsDisabled()}
/>
)
Expand Down
4 changes: 2 additions & 2 deletions stories/features/rewards/settings/donationsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as React from 'react'

// Components
import { Box, TableDonation, Tokens, List, TipsMigrationAlert } from '../../../../src/features/rewards'
import { Box, BoxAlert, TableDonation, Tokens, List } from '../../../../src/features/rewards'
import { DetailRow as DonationDetailRow } from '../../../../src/features/rewards/tableDonation'
import { Column, Grid, Checkbox, ControlWrapper } from '../../../../src/components'

Expand Down Expand Up @@ -98,7 +98,7 @@ class DonationsBox extends React.Component<{}, State> {

donationAlertChild = () => {
return (
<TipsMigrationAlert onReview={doNothing} />
<BoxAlert type={'tips'} onReview={doNothing} />
)
}

Expand Down

0 comments on commit ac6f2fc

Please sign in to comment.