This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #490 from brave/revert-485" This reverts commit 82b3e98, reversing changes made to b0ec08c.
- Loading branch information
1 parent
624be47
commit 3a0f21a
Showing
13 changed files
with
370 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* 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 SettingsMenu = styled<{}, 'div'>('div')` | ||
background-color: ${p => p.theme.color.contextMenuBackground}; | ||
color: ${p => p.theme.color.contextMenuForeground}; | ||
border-radius: 8px; | ||
padding: 24px; | ||
box-shadow: 0px 4px 24px 0px rgba(0, 0, 0, 0.24); | ||
font-family: ${p => p.theme.fontFamily.body}; | ||
` | ||
|
||
export const SettingsTitle = styled<{}, 'div'>('div')` | ||
font-family: ${p => p.theme.fontFamily.body}; | ||
font-size: 18px; | ||
font-weight: bold; | ||
letter-spacing: 0px; | ||
margin-bottom: 16px; | ||
` | ||
|
||
export const SettingsRow = styled<{}, 'div'>('div')` | ||
box-sizing: border-box; | ||
display: grid; | ||
grid-template-columns: 1fr 36px; | ||
height: 30px; | ||
width: 320px; | ||
` | ||
|
||
export const SettingsText = styled<{}, 'span'>('span')` | ||
display: flex; | ||
align-items: center; | ||
font-size: 14px; | ||
font-weight: normal; | ||
` | ||
|
||
export const SettingsWrapper = styled<{}, 'div'>('div')` | ||
position: absolute; | ||
bottom: 118px; | ||
padding: 0 222px; | ||
display: flex; | ||
width: 100%; | ||
justify-content: flex-end; | ||
@media screen and (max-width: 904px) { | ||
padding: 0 192px; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* 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 { StyledWrapper, StyledSlider, StyledBullet, StyleToggle, StyledCheckbox } from './style' | ||
|
||
export interface Props { | ||
testId?: string | ||
checked?: boolean | ||
disabled?: boolean | ||
onChange?: (e: any) => void | ||
id?: string | ||
readOnly?: boolean | ||
autoFocus?: boolean | ||
size: 'large' | 'small' | ||
colorType?: 'dark' | 'light' | 'default' | ||
} | ||
|
||
export interface ToggleState { | ||
checked?: boolean | ||
} | ||
|
||
export class Toggle extends React.PureComponent<Props, ToggleState> { | ||
static defaultProps = { | ||
checked: false, | ||
size: 'small', | ||
type: 'default', | ||
disabled: false | ||
} | ||
|
||
constructor (props: Props) { | ||
super(props) | ||
this.state = { checked: props.checked } | ||
this.handleChange = this.handleChange.bind(this) | ||
} | ||
|
||
componentWillReceiveProps (nextProps: Props) { | ||
if ('checked' in nextProps) { | ||
this.setState({ checked: nextProps.checked }) | ||
} | ||
} | ||
|
||
handleChange (e: any) { | ||
const { props } = this | ||
if (props.disabled) { | ||
return | ||
} | ||
if (!('checked' in props)) { | ||
this.setState({ checked: e.target.checked }) | ||
} | ||
|
||
if (props.onChange) { | ||
props.onChange({ target: { checked: e.target.checked } }) | ||
} | ||
} | ||
|
||
render () { | ||
const { id, testId, readOnly, disabled, autoFocus, size, colorType } = this.props | ||
const { checked } = this.state | ||
|
||
return ( | ||
<StyledWrapper checked={checked} data-test-id={testId} size={size}> | ||
<StyledCheckbox | ||
type='checkbox' | ||
id={id} | ||
readOnly={readOnly} | ||
disabled={disabled} | ||
checked={checked} | ||
onChange={this.handleChange} | ||
autoFocus={autoFocus} | ||
/> | ||
<StyleToggle size={size}> | ||
<StyledSlider htmlFor={id} checked={checked} size={size} disabled={disabled} /> | ||
<StyledBullet htmlFor={id} checked={checked} size={size} disabled={disabled} colorType={colorType} /> | ||
</StyleToggle> | ||
</StyledWrapper> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* 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, { css } from '../../../theme' | ||
import { Props } from './index' | ||
import palette from '../../../theme/colors' | ||
|
||
export const StyledCheckbox = styled<{}, 'input'>('input')` | ||
-webkit-appearance: none; | ||
position: absolute; | ||
z-index: 99999999; | ||
width: 100%; | ||
height: 100%; | ||
top: 0; | ||
left: 0; | ||
outline-offset: -3px; | ||
outline-color: ${palette.orange400}; | ||
outline-width: 2px; | ||
` | ||
|
||
export const StyledWrapper = styled<Props, 'div'>('div')` | ||
box-sizing: border-box; | ||
display: flex; | ||
position: relative; | ||
height: 100%; | ||
justify-content: center; | ||
align-items: center; | ||
` | ||
|
||
export const StyleToggle = styled<Props, 'div'>('div')` | ||
box-sizing: border-box; | ||
position: relative; | ||
display: block; | ||
height: ${(p) => p.size === 'small' ? '16px' : '24px'}; | ||
width: ${(p) => p.size === 'small' ? '28px' : '40px'}; | ||
${(p) => p.disabled | ||
? css` | ||
pointer-events: none; | ||
animation: none; | ||
` : '' | ||
}; | ||
` | ||
|
||
export const StyledSlider = styled<Props, 'label'>('label')` | ||
box-sizing: border-box; | ||
background: ${(p) => p.disabled ? 'rgba(246,246,250,0.1)' : '#C4C7C9'}; | ||
height: ${(p) => p.size === 'small' ? '6px' : '8px'}; | ||
margin-top: ${(p) => p.size === 'small' ? '5px' : '8px'}; | ||
width: 100%; | ||
border-radius: 3px; | ||
display: block; | ||
` | ||
|
||
const transform = (p: Props) => { | ||
let x = p.size === 'small' ? '12px' : '20px' | ||
let y = p.size === 'small' ? '3px' : '4px' | ||
|
||
if (!p.checked) { | ||
x = '-1px' | ||
} | ||
|
||
return { x, y } | ||
} | ||
|
||
const transformBullet = (p: Props) => `${transform(p).x}, calc(-50% - ${transform(p).y})` | ||
|
||
export const StyledBullet = styled<Props, 'label'>('label')` | ||
box-sizing: border-box; | ||
position: relative; | ||
border-radius: 50%; | ||
transition: all .4s ease; | ||
transform: ${p => `translate(${transformBullet(p)})`}; | ||
width: ${p => p.size === 'small' ? '16px' : '20px'}; | ||
height: ${p => p.size === 'small' ? '16px' : '20px'}; | ||
background-color: ${p => p.disabled && 'rgba(235,236,240,0.8)' || p.checked ? '#fb542b' : '#ebecf0'}; | ||
display: block; | ||
box-shadow: 0 3px 3px rgba(0,0,0,0.05); | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import ITheme from './theme-interface' | ||
import colors from './colors' | ||
import defaultTheme from './brave-default' | ||
|
||
const darkTheme: ITheme = { | ||
...defaultTheme, | ||
name: 'Brave Dark' | ||
name: 'Brave Dark', | ||
color: { | ||
...defaultTheme.color, | ||
contextMenuBackground: colors.black, | ||
contextMenuForeground: colors.white | ||
} | ||
} | ||
|
||
export default darkTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.