Skip to content

Commit

Permalink
(Shields extension) Imported from brave-ui: add multiple views for sh…
Browse files Browse the repository at this point in the history
…ields
  • Loading branch information
cezaraugusto authored and petemill committed Sep 10, 2019
1 parent 4b53bf4 commit 0148175
Show file tree
Hide file tree
Showing 34 changed files with 1,044 additions and 117 deletions.
27 changes: 27 additions & 0 deletions src/features/shields/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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/. */

export const dummyData = {
thirdPartyCookiesBlocked: '2',
thirdPartyScriptsBlocked: '2',
thirdPartyDeviceRecognitionBlocked: '2',
pishingMalwareBlocked: '2',
connectionsEncrypted: '2',
noScriptsResouces: {
'https://imasdk.googleapis.com/js/sdkloader/ima3.js': {
actuallyBlocked: true,
willBlock: true,
userInteracted: true
},
'https://scripts.dailymail.co.uk/rta2/v-0.37.min.js': {
actuallyBlocked: true,
willBlock: true,
userInteracted: true
}
},
otherBlockedResources: [
'https://aaaa.com/abcdefghijklmnopqrstuwxyz/123456789',
'https://bbbb.com/abcdefghijklmnopqrstuwxyz/123456789'
]
}
3 changes: 2 additions & 1 deletion src/features/shields/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ export const Link = styled<{}, 'button'>('button')`
font-size: 13px;
font-weight: 500;
display: inline-block;
text-align: left;
width: fit-content;
&:hover {
text-decoration: underline;
}
&:focus {
outline-offset: 6px;
outline-color: ${p => p.theme.color.brandBrave};
outline-width: 2px;
}
Expand Down
17 changes: 15 additions & 2 deletions src/features/shields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export {
SiteInfo,
// Controls
BlockedInfoRow,
BlockedInfoRowDetails,
BlockedInfoRowSummary,
BlockedInfoRowSingle,
BlockedInfoRowSingleText,
BlockedInfoRowForSelect,
BlockedInfoRowForSelectSummary,
BlockedInfoRowData,
BlockedInfoRowDataForSelect,
// footer
Expand All @@ -31,7 +35,15 @@ export {
BlockedListItemSummary,
BlockedListFooter,
BlockedListFooterWithOptions,
DisabledContentView
DisabledContentView,
// Static content
StaticHeader,
StaticResourcesControls,
StaticResourcesContainer,
// Overlay
Overlay,
WarningText,
WarningModal
} from './structure'

export {
Expand All @@ -58,6 +70,7 @@ export {
ShieldsButton
} from './display'

export { ArrowDownIcon, ArrowUpIcon, ShieldIcon } from './media'
export { ArrowDownIcon, ArrowUpIcon, ShieldIcon, WarningIcon } from './media'
export { Toggle } from './toggle'
export { SelectBox } from './select'
export { dummyData } from './data'
12 changes: 11 additions & 1 deletion src/features/shields/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import styled from '../../../theme'
import { StyledComponentClass } from 'styled-components'
import { CaratStrongDownIcon, ShieldAlertIcon } from '../../../components/icons'
import { CaratStrongDownIcon, ShieldAlertIcon, AlertMessageIcon } from '../../../components/icons'

import { ComponentType } from 'react'

Expand All @@ -26,11 +26,21 @@ export const ShieldIcon = styled(ShieldAlertIcon as ComponentType)`
color: ${p => p.theme.color.lionLogo};
`

export const WarningIcon = styled(AlertMessageIcon as ComponentType)`
box-sizing: border-box;
display: block;
width: 48px;
height: auto;
margin: 0 auto 12px;
color: ${p => p.theme.color.lionLogo};
`

export const ArrowDownIcon = styled(CaratStrongDownIcon as ComponentType)`
width: 24px;
height: 24px;
padding: 4px;
color: ${p => p.theme.color.text};
pointer-events: none;
&:focus {
outline-width: 2px;
Expand Down
2 changes: 2 additions & 0 deletions src/features/shields/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface SelectBoxProps {
multiple?: boolean
autoFocus?: boolean
disabled?: boolean
readOnly?: boolean
value?: string
onChange?: (e: any) => void
children: React.ReactNode
Expand All @@ -32,6 +33,7 @@ export const SelectBox = styled<SelectBoxProps, 'select'>('select')`
line-height: 18px;
font-family: ${p => p.theme.fontFamily.heading};
border: 1px solid ${p => p.theme.color.inputBorder};
pointer-events: ${p => p.readOnly && 'none'};
background: url(${caratUrl}) 97% / 16px no-repeat transparent;
/* avoid text overflow w/ carat */
-webkit-padding-start: 10px;
Expand Down
112 changes: 106 additions & 6 deletions src/features/shields/structure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ export const SiteOverview = styled<SiteOverviewProps, 'div'>('div')`
padding: 32px 0;
`

export const TotalBlockedStats = styled<{}, 'section'>('section')`
interface TotalBlockedStatsProps {
size?: 'large'
}

export const TotalBlockedStats = styled<TotalBlockedStatsProps, 'section'>('section')`
box-sizing: border-box;
display: grid;
grid-template-columns: 80px 140px;
grid-template-columns: ${p => p.size === 'large' ? '80px 210px' : '80px 140px'};
align-items: center;
margin: 0px auto 5px;
grid-gap: 10px;
Expand All @@ -85,7 +89,7 @@ export const SiteInfo = styled<{}, 'div'>('div')`
display: grid;
grid-template-columns: auto 1fr;
align-items: center;
margin: 0px auto 5px;
margin: 0px auto 7px;
gap: 8px;
`

Expand Down Expand Up @@ -122,19 +126,55 @@ export const BlockedInfoRow = styled<BlockedInfoRowProps, 'div'>('div')`
}
`

export const BlockedInfoRowDetails = styled<BlockedInfoRowProps, 'details'>('details')`
box-sizing: border-box;
`

export const BlockedInfoRowSummary = styled(BlockedInfoRow.withComponent('summary'))`
&::-webkit-details-marker {
display: none;
}
&:focus {
outline-color: ${p => p.theme.color.brandBrave};
outline-offset: -3px;
outline-width: 2px;
}
`

export const BlockedInfoRowSingle = styled(BlockedInfoRow)`
padding: 8px 24px 8px 74px;
cursor: default;
grid-template-columns: 1fr;
`

export const BlockedInfoRowSingleText = styled(BlockedInfoRow)`
padding: 14px 24px 14px 84px;
cursor: default;
grid-template-columns: 1fr;
`

export const BlockedInfoRowForSelect = styled(BlockedInfoRow)`
grid-template-columns: auto 1fr;
padding-right: 24px;
`

export const BlockedInfoRowForSelectSummary = styled(BlockedInfoRowForSelect.withComponent('summary'))`
&::-webkit-details-marker {
display: none;
}
&:focus {
outline-color: ${p => p.theme.color.brandBrave};
outline-offset: -3px;
outline-width: 2px;
}
box-sizing: border-box;
`

interface BlockedInfoRowDataProps {
disabled: boolean
disabled?: boolean
}

export const BlockedInfoRowData = styled<BlockedInfoRowDataProps, 'div'>('div')`
Expand Down Expand Up @@ -194,6 +234,9 @@ export const BlockedInfoRowDataForSelect = styled(BlockedInfoRowData)`
*/
export const MainFooter = styled<{}, 'div'>('div')`
box-sizing: border-box;
position: relative;
display: grid;
grid-gap: 16px;
padding: 24px;
`

Expand Down Expand Up @@ -246,10 +289,14 @@ export const BlockedListSummary = styled<BlockedListSummaryProps, 'summary'>('su
}
`

export const BlockedListStatic = styled<{}, 'ul'>('ul')`
interface BlockedListStaticProps {
fixedHeight?: boolean
}

export const BlockedListStatic = styled<BlockedListStaticProps, 'ul'>('ul')`
box-sizing: border-box;
list-style-type: none;
height: 328px;
height: ${p => p.fixedHeight && '358px'};
overflow: auto;
padding: 0 0 0 24px;
margin: 0;
Expand Down Expand Up @@ -387,3 +434,56 @@ export const DisabledContentView = styled<{}, 'section'>('section')`
max-width: 80%;
margin: 5px auto 8px;
`

/**
* Static panel (learn more overlay)
*/
export const StaticHeader = styled<{}, 'header'>('header')`
padding: 0 20px 10px 24px;
line-height: 18px;
`

export const StaticResourcesControls = styled<{}, 'div'>('div')`
box-sizing: border-box;
position: relative;
height: 216px;
overflow: auto;
`

export const StaticResourcesContainer = styled<{}, 'div'>('div')`
box-sizing: border-box;
position: absolute;
width: 100%;
`

/**
* Modals and overlays
*/
export const Overlay = styled<{}, 'div'>('div')`
box-sizing: border-box;
position: absolute;
z-index: 5;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 0 44px;
background-color: ${p => p.theme.color.modalOverlayBackground}
`
export const WarningText = styled<{}, 'p'>('p')`
margin: 0 0 24px;
line-height: 18px;
`

export const WarningModal = styled<{}, 'div'>('div')`
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
text-align: center;
min-height: 100px;
`
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import {
BlockedInfoRowStats,
BlockedInfoRowText,
Toggle
} from '../../../../../src/features/shields'
} from '../../../../../../src/features/shields'

// Group Components
import StaticList from '../list/static'
import StaticList from '../overlays/staticOverlay'

// Fake data
import { getLocale } from '../../fakeLocale'
import data from '../../fakeData'
import { getLocale } from '../../../fakeLocale'
import data from '../../../fakeData'

// Helpers
import { getTabIndexValueBasedOnProps } from '../../helpers'
import { getTabIndexValueBasedOnProps } from '../../../helpers'

interface Props {
favicon: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import * as React from 'react'

// Feature-specific components
import { BlockedInfoRowSingle, SelectBox } from '../../../../../src/features/shields'
import { BlockedInfoRowSingle, SelectBox } from '../../../../../../src/features/shields'

// Fake data
import { getLocale } from '../../fakeLocale'
import { getLocale } from '../../../fakeLocale'

interface Props {
isBlockedListOpen: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import {
ArrowDownIcon,
BlockedInfoRowStats,
SelectBox
} from '../../../../../src/features/shields'
} from '../../../../../../src/features/shields'

// Group Components
import StaticList from '../list/static'
import StaticList from '../overlays/staticOverlay'

// Fake data
import { getLocale } from '../../fakeLocale'
import data from '../../fakeData'
import { getLocale } from '../../../fakeLocale'
import data from '../../../fakeData'

// Helpers
import { getTabIndexValueBasedOnProps } from '../../helpers'
import { getTabIndexValueBasedOnProps } from '../../../helpers'

interface Props {
favicon: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import {
BlockedInfoRowStats,
BlockedInfoRowText,
Toggle
} from '../../../../../src/features/shields'
} from '../../../../../../src/features/shields'

// Group Components
import StaticList from '../list/static'
import StaticList from '../overlays/staticOverlay'

// Fake data
import { getLocale } from '../../fakeLocale'
import data from '../../fakeData'
import { getLocale } from '../../../fakeLocale'
import data from '../../../fakeData'

// Helpers
import { getTabIndexValueBasedOnProps } from '../../helpers'
import { getTabIndexValueBasedOnProps } from '../../../helpers'

interface Props {
favicon: string
Expand Down
Loading

0 comments on commit 0148175

Please sign in to comment.