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

Commit

Permalink
Implemented Brave Rewards Ads feedback loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Sadler committed May 15, 2019
1 parent 4f12cb4 commit 9c8ee28
Show file tree
Hide file tree
Showing 33 changed files with 2,090 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "brave-ui",
"main": "index.js",
"sideEffects": false,
"version": "0.34.4",
"version": "0.38.0",
"description": "List of reusable React components to empower your brave UI",
"author": "Brave Software",
"contributors": [
Expand Down Expand Up @@ -93,7 +93,7 @@
"react": "^16.4.2",
"react-beautiful-dnd": "^10.0.3",
"react-dom": "^16.3.0",
"react-storybook-addon-chapters": "^3.1.3",
"react-storybook-addon-chapters": "^3.1.1",
"react-test-renderer": "^16.3.0",
"rimraf": "^2.6.2",
"storybook-addon-styled-component-theme": "^1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "brave-ui",
"main": "index.js",
"sideEffects": false,
"version": "0.38.0",
"version": "0.34.4",
"description": "List of reusable React components to empower your brave UI",
"author": "Brave Software",
"contributors": [
Expand Down Expand Up @@ -93,7 +93,7 @@
"react": "^16.4.2",
"react-beautiful-dnd": "^10.0.3",
"react-dom": "^16.3.0",
"react-storybook-addon-chapters": "^3.1.1",
"react-storybook-addon-chapters": "^3.1.3",
"react-test-renderer": "^16.3.0",
"rimraf": "^2.6.2",
"storybook-addon-styled-component-theme": "^1.1.1",
Expand Down
94 changes: 94 additions & 0 deletions src/features/rewards/adRowsDetails/__snapshots__/spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Ad Rows Details tests basic tests matches the snapshot 1`] = `
.c4 {
font-family: Muli,sans-serif;
font-size: 14px;
color: #686978;
display: inline-block;
}
.c1 {
white-space: nowrap;
}
.c0 {
text-align: left;
padding-top: 15px;
}
.c5 {
width: 94.5%;
padding-left: 10px;
display: inline-block;
}
.c6 {
color: #DADCE8;
background-color: #DADCE8;
height: 2px;
border: none;
}
.c2 {
margin: 0;
background: none;
border: none;
cursor: pointer;
width: 16px;
height: 16px;
color: #9E9FAB;
padding: 1px;
outline: none;
display: inline-block;
text-align: center;
}
.c3 {
width: 100%;
height: 100%;
fill: currentColor;
}
<tr>
<td
colSpan={3}
>
<div
className="c0"
>
<div
className="c1"
>
<div
className="c2"
onClick={[Function]}
>
<svg
aria-hidden="true"
className="c3"
focusable="false"
viewBox="0 0 32 32"
>
<path
d="M3.36242 7h17.26845c1.19463 0 1.79195 1.3994.94631 2.21953l-8.63087 8.37692c-.5235.5077-1.37584.5077-1.89933 0L2.41611 9.21953C1.57047 8.3994 2.16779 7 3.3624 7z"
/>
</svg>
</div>
<div
className="c4"
>
</div>
<div
className="c5"
>
<hr
className="c6"
/>
</div>
</div>
</div>
</td>
</tr>
`;
96 changes: 96 additions & 0 deletions src/features/rewards/adRowsDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

import * as React from 'react'
import {
StyledAdPortionTD,
StyledAdsDateRow,
StyledAdsDetailRow,
StyledCaratIcon,
StyledDateText,
StyledHR,
StyledHRDiv,
StyledInnerStartTD
} from './style'
import {
CaratTriangleDownSIcon, CaratTriangleRightSIcon
} from '../../../components/icons'
import { DetailRow } from '../tableAdsHistory'
import { Row, Cell } from '../../../components/dataTables/table'

export interface Props {
id?: string
row?: DetailRow
rowIndex?: number
detailRows?: Row[]
}

interface State {
innerDetailVisible: boolean
}

export default class AdRowsDetails extends React.PureComponent<Props, State> {
constructor (props: Props) {
super(props)
this.state = {
innerDetailVisible: true
}
}

setInnerVisible = () => {
this.setState({
innerDetailVisible: !this.state.innerDetailVisible
})
}

render () {
const { row, rowIndex, detailRows } = this.props
return (
<>
<tr key={rowIndex}>
<td colSpan={3}>
<StyledAdsDetailRow>
<StyledAdsDateRow>
<StyledCaratIcon onClick={this.setInnerVisible}>
{
this.state.innerDetailVisible ?
<CaratTriangleDownSIcon />
:
<CaratTriangleRightSIcon />
}
</StyledCaratIcon>
<StyledDateText>
{
row ? row.date : ''
}
</StyledDateText>
<StyledHRDiv>
<StyledHR />
</StyledHRDiv>
</StyledAdsDateRow>
</StyledAdsDetailRow>
</td>
</tr>
{
detailRows && this.state.innerDetailVisible ?
detailRows.map((detailRow: Row, j: number) => {
return (
<tr key={j}>
{
detailRow.content.map((detailCell: Cell, k: number) => {
return k === 0 ?
<StyledInnerStartTD key={k} />
:
<StyledAdPortionTD key={k}>{detailCell.content}</StyledAdPortionTD>
})
}
</tr>
)
})
: null
}
</>
)
}
}
24 changes: 24 additions & 0 deletions src/features/rewards/adRowsDetails/spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* global jest, expect, describe, it, afterEach */
import * as React from 'react'
import { shallow } from 'enzyme'
import { create } from 'react-test-renderer'
import { TestThemeProvider } from '../../../theme'
import AdRowsDetails from './index';

describe('Ad Rows Details tests', () => {
const baseComponent = (props?: object) => <TestThemeProvider><AdRowsDetails id={'adRowsDetails'} /></TestThemeProvider>

describe('basic tests', () => {
it('matches the snapshot', () => {
const component = baseComponent()
const tree = create(component).toJSON()
expect(tree).toMatchSnapshot()
})

it('renders the component', () => {
const wrapper = shallow(baseComponent())
const assertion = wrapper.find('#adRowsDetails').length
expect(assertion).toBe(1)
})
})
})
70 changes: 70 additions & 0 deletions src/features/rewards/adRowsDetails/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License. v. 2.0. If a copy of the MPL was not distributed with this file.
* You can obtain one at http://mozilla.org/MPL/2.0/. */

import styled from 'styled-components'

export const StyledDateText = styled<{}, 'div'>('div')`
font-family: Muli, sans-serif;
font-size: 14px;
color: #686978;
display: inline-block;
`
export const StyledAdsDateRow = styled<{}, 'div'>('div')`
white-space: nowrap;
`

export const StyledAdsDetailRow = styled<{}, 'div'>('div')`
text-align: left;
padding-top: 15px;
`

export const StyledHRDiv = styled<{}, 'div'>('div')`
width: 94.5%;
padding-left: 10px;
display: inline-block;
`

export const StyledHR = styled<{}, 'hr'>('hr')`
color: #DADCE8;
background-color: #DADCE8;
height: 2px;
border: none;
`

export const StyledCaratIcon = styled<{}, 'div'>('div')`
margin: 0;
background: none;
border: none;
cursor: pointer;
width: 16px;
height: 16px;
color: #9E9FAB;
padding: 1px;
outline: none;
display: inline-block;
text-align: center;
`

export const StyledAdPortionTD = styled<{}, 'td'>('td')`
font-family: Muli, sans-serif;
font-size: 14px;
font-weight: 500;
color: #686978;
border-bottom: none;
padding: 5px 0;
text-align: left;
width: 70%;
`

export const StyledInnerStartTD = styled<{}, 'td'>('td')`
font-family: Muli, sans-serif;
font-size: 14px;
font-weight: 500;
color: #686978;
border-bottom: none;
padding: 12px 0;
text-align: left;
width: 15%;
height: 0%;
`
Loading

0 comments on commit 9c8ee28

Please sign in to comment.