diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-06-01 16:13:10 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-06-05 12:11:55 +0200 |
| commit | ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch) | |
| tree | b1f7754eb50896ab3681e35fa4e08be642b940c9 /app/components/styled | |
| parent | 5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff) | |
| download | mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip | |
Add formatted source code
Diffstat (limited to 'app/components/styled')
| -rw-r--r-- | app/components/styled/AppButton.js | 57 | ||||
| -rw-r--r-- | app/components/styled/AppButtonStyles.js | 22 | ||||
| -rw-r--r-- | app/components/styled/BlurAppButtonStyles.android.js | 12 | ||||
| -rw-r--r-- | app/components/styled/BlurAppButtonStyles.js | 12 | ||||
| -rw-r--r-- | app/components/styled/CellButton.js | 82 | ||||
| -rw-r--r-- | app/components/styled/index.js | 8 |
6 files changed, 105 insertions, 88 deletions
diff --git a/app/components/styled/AppButton.js b/app/components/styled/AppButton.js index 59cba4eefb..f54bd18024 100644 --- a/app/components/styled/AppButton.js +++ b/app/components/styled/AppButton.js @@ -15,59 +15,60 @@ class BaseButton extends Component { state = { hovered: false }; - textStyle = () => this.state.hovered ? styles.white80 : styles.white; - iconStyle = () => this.state.hovered ? styles.white80 : styles.white; - backgroundStyle = () => this.state.hovered ? styles.white80 : styles.white; + textStyle = () => (this.state.hovered ? styles.white80 : styles.white); + iconStyle = () => (this.state.hovered ? styles.white80 : styles.white); + backgroundStyle = () => (this.state.hovered ? styles.white80 : styles.white); - onHoverStart = () => !this.props.disabled ? this.setState({ hovered: true }) : null; - onHoverEnd = () => !this.props.disabled ? this.setState({ hovered: false }) : null; + onHoverStart = () => (!this.props.disabled ? this.setState({ hovered: true }) : null); + onHoverEnd = () => (!this.props.disabled ? this.setState({ hovered: false }) : null); render() { const { children, ...otherProps } = this.props; return ( - <Button style={[ styles.common, this.backgroundStyle() ]} + <Button + style={[styles.common, this.backgroundStyle()]} onHoverStart={this.onHoverStart} onHoverEnd={this.onHoverEnd} {...otherProps}> - { - React.Children.map(children, (node) => { - if (React.isValidElement(node)) { - let updatedProps = {}; + {React.Children.map(children, (node) => { + if (React.isValidElement(node)) { + let updatedProps = {}; - if(node.type.name === 'Label') { - updatedProps = { style: [styles.label, this.textStyle()]}; - } - - if(node.type.name === 'Img') { - updatedProps = { tintColor:'currentColor', style: [styles.icon, this.iconStyle()]}; - } + if (node.type.name === 'Label') { + updatedProps = { style: [styles.label, this.textStyle()] }; + } - return React.cloneElement(node, updatedProps); - } else { - return <Label style={[styles.label, this.textStyle()]}>{children}</Label>; + if (node.type.name === 'Img') { + updatedProps = { tintColor: 'currentColor', style: [styles.icon, this.iconStyle()] }; } - }) - } + + return React.cloneElement(node, updatedProps); + } else { + return <Label style={[styles.label, this.textStyle()]}>{children}</Label>; + } + })} </Button> ); } } export class RedButton extends BaseButton { - backgroundStyle = () => this.state.hovered ? styles.redHover : styles.red; + backgroundStyle = () => (this.state.hovered ? styles.redHover : styles.red); } export class GreenButton extends BaseButton { - backgroundStyle = () => this.state.hovered ? styles.greenHover : styles.green; + backgroundStyle = () => (this.state.hovered ? styles.greenHover : styles.green); } export class BlueButton extends BaseButton { - backgroundStyle = () => this.state.hovered ? styles.blueHover : styles.blue; + backgroundStyle = () => (this.state.hovered ? styles.blueHover : styles.blue); } export class TransparentButton extends BaseButton { - backgroundStyle = () => this.state.hovered ? blurStyles.transparentHover : blurStyles.transparent; + backgroundStyle = () => + this.state.hovered ? blurStyles.transparentHover : blurStyles.transparent; } export class RedTransparentButton extends BaseButton { - backgroundStyle = () => this.state.hovered ? blurStyles.redTransparentHover : blurStyles.redTransparent; -}
\ No newline at end of file + backgroundStyle = () => + this.state.hovered ? blurStyles.redTransparentHover : blurStyles.redTransparent; +} diff --git a/app/components/styled/AppButtonStyles.js b/app/components/styled/AppButtonStyles.js index 477a0cc54a..6049f227d5 100644 --- a/app/components/styled/AppButtonStyles.js +++ b/app/components/styled/AppButtonStyles.js @@ -4,42 +4,42 @@ import { createViewStyles, createTextStyles } from '../../lib/styles'; export default { ...createViewStyles({ - red:{ + red: { backgroundColor: colors.red95, }, redHover: { backgroundColor: colors.red, }, - green:{ + green: { backgroundColor: colors.green, }, - greenHover:{ + greenHover: { backgroundColor: colors.green90, }, - blue:{ + blue: { backgroundColor: colors.blue80, }, - blueHover:{ + blueHover: { backgroundColor: colors.blue60, }, - white80:{ + white80: { color: colors.white80, }, white: { color: colors.white, }, - icon:{ + icon: { position: 'absolute', alignSelf: 'flex-end', right: 8, marginLeft: 8, }, - iconTransparent:{ + iconTransparent: { position: 'absolute', alignSelf: 'flex-end', right: 42, }, - common:{ + common: { paddingTop: 9, paddingLeft: 9, paddingRight: 9, @@ -56,7 +56,7 @@ export default { }, }), ...createTextStyles({ - label:{ + label: { alignSelf: 'center', fontFamily: 'DINPro', fontSize: 20, @@ -65,4 +65,4 @@ export default { flex: 1, }, }), -};
\ No newline at end of file +}; diff --git a/app/components/styled/BlurAppButtonStyles.android.js b/app/components/styled/BlurAppButtonStyles.android.js index 9243a28729..c39e44cdd5 100644 --- a/app/components/styled/BlurAppButtonStyles.android.js +++ b/app/components/styled/BlurAppButtonStyles.android.js @@ -4,17 +4,17 @@ import { createViewStyles } from '../../lib/styles'; export default { ...createViewStyles({ - transparent:{ + transparent: { backgroundColor: colors.white20, }, - transparentHover:{ + transparentHover: { backgroundColor: colors.white40, }, - redTransparent:{ + redTransparent: { backgroundColor: colors.red40, }, - redTransparentHover:{ + redTransparentHover: { backgroundColor: colors.red45, }, - }) -};
\ No newline at end of file + }), +}; diff --git a/app/components/styled/BlurAppButtonStyles.js b/app/components/styled/BlurAppButtonStyles.js index 9e7b213754..72d5398ea8 100644 --- a/app/components/styled/BlurAppButtonStyles.js +++ b/app/components/styled/BlurAppButtonStyles.js @@ -4,21 +4,21 @@ import { createViewStyles } from '../../lib/styles'; export default { ...createViewStyles({ - transparent:{ + transparent: { backgroundColor: colors.white20, backdropFilter: 'blur(4px)', }, - transparentHover:{ + transparentHover: { backgroundColor: colors.white40, backdropFilter: 'blur(4px)', }, - redTransparent:{ + redTransparent: { backgroundColor: colors.red40, backdropFilter: 'blur(4px)', }, - redTransparentHover:{ + redTransparentHover: { backgroundColor: colors.red45, backdropFilter: 'blur(4px)', }, - }) -};
\ No newline at end of file + }), +}; diff --git a/app/components/styled/CellButton.js b/app/components/styled/CellButton.js index 1a0e055b01..f0251c942e 100644 --- a/app/components/styled/CellButton.js +++ b/app/components/styled/CellButton.js @@ -9,7 +9,7 @@ import { createViewStyles, createTextStyles } from '../../lib/styles'; const styles = { ...createViewStyles({ - cell:{ + cell: { backgroundColor: colors.blue80, paddingTop: 14, paddingBottom: 14, @@ -21,19 +21,19 @@ const styles = { alignItems: 'center', alignContent: 'center', }, - blue:{ + blue: { backgroundColor: colors.blue80, }, - blueHover:{ + blueHover: { backgroundColor: colors.blue60, }, - white40:{ + white40: { color: colors.white40, }, - white60:{ + white60: { color: colors.white60, }, - white80:{ + white80: { color: colors.white80, }, white: { @@ -45,7 +45,7 @@ const styles = { }, }), ...createTextStyles({ - label:{ + label: { color: colors.white, alignSelf: 'center', fontFamily: 'DINPro', @@ -55,7 +55,7 @@ const styles = { flex: 1, marginLeft: 8, }, - subtext:{ + subtext: { color: colors.white60, fontFamily: 'Open Sans', fontSize: 13, @@ -69,12 +69,11 @@ const styles = { export class SubText extends Text {} export class Label extends Text {} - type CellButtonProps = { children?: React.Node, disabled?: boolean, cellHoverStyle?: Types.ViewStyle, - style?: Types.ViewStyle + style?: Types.ViewStyle, }; type State = { hovered: boolean }; @@ -82,44 +81,55 @@ type State = { hovered: boolean }; export default class CellButton extends Component<CellButtonProps, State> { state = { hovered: false }; - textStyle = (cellHoverStyle?: Types.ViewStyle) => this.state.hovered ? cellHoverStyle : null; - iconStyle = (cellHoverStyle?: Types.ViewStyle) => this.state.hovered ? cellHoverStyle : null; - subtextStyle = (cellHoverStyle?: Types.ViewStyle) => this.state.hovered ? cellHoverStyle : null; - backgroundStyle = (cellHoverStyle?: Types.ViewStyle) => this.state.hovered ? cellHoverStyle || styles.blueHover : null; + textStyle = (cellHoverStyle?: Types.ViewStyle) => (this.state.hovered ? cellHoverStyle : null); + iconStyle = (cellHoverStyle?: Types.ViewStyle) => (this.state.hovered ? cellHoverStyle : null); + subtextStyle = (cellHoverStyle?: Types.ViewStyle) => (this.state.hovered ? cellHoverStyle : null); + backgroundStyle = (cellHoverStyle?: Types.ViewStyle) => + this.state.hovered ? cellHoverStyle || styles.blueHover : null; - onHoverStart = () => !this.props.disabled ? this.setState({ hovered: true }) : null; - onHoverEnd = () => !this.props.disabled ? this.setState({ hovered: false }) : null; + onHoverStart = () => (!this.props.disabled ? this.setState({ hovered: true }) : null); + onHoverEnd = () => (!this.props.disabled ? this.setState({ hovered: false }) : null); render() { const { children, style, cellHoverStyle, ...otherProps } = this.props; return ( - <Button style={[ styles.cell, style, this.backgroundStyle(cellHoverStyle) ]} + <Button + style={[styles.cell, style, this.backgroundStyle(cellHoverStyle)]} onHoverStart={this.onHoverStart} onHoverEnd={this.onHoverEnd} {...otherProps}> - { - React.Children.map(children, (node) => { - if (React.isValidElement(node)) { - let updatedProps = {}; - - if(node.type.name === 'Label') { - updatedProps = { style: [styles.label, node.props.style, this.textStyle(node.props.cellHoverStyle)]}; - } + {React.Children.map(children, (node) => { + if (React.isValidElement(node)) { + let updatedProps = {}; - if(node.type.name === 'Img') { - updatedProps = { tintColor:'currentColor', style: [styles.icon, node.props.style, this.iconStyle(node.props.cellHoverStyle)]}; - } + if (node.type.name === 'Label') { + updatedProps = { + style: [styles.label, node.props.style, this.textStyle(node.props.cellHoverStyle)], + }; + } - if(node.type.name === 'SubText') { - updatedProps = { style: [styles.subtext, node.props.style, this.subtextStyle(node.props.cellHoverStyle)]}; - } + if (node.type.name === 'Img') { + updatedProps = { + tintColor: 'currentColor', + style: [styles.icon, node.props.style, this.iconStyle(node.props.cellHoverStyle)], + }; + } - return React.cloneElement(node, updatedProps); - } else if (node){ - return <Label style={[styles.label, this.textStyle()]}>{children}</Label>; + if (node.type.name === 'SubText') { + updatedProps = { + style: [ + styles.subtext, + node.props.style, + this.subtextStyle(node.props.cellHoverStyle), + ], + }; } - }) - } + + return React.cloneElement(node, updatedProps); + } else if (node) { + return <Label style={[styles.label, this.textStyle()]}>{children}</Label>; + } + })} </Button> ); } diff --git a/app/components/styled/index.js b/app/components/styled/index.js index 7efeb28389..6582da5e77 100644 --- a/app/components/styled/index.js +++ b/app/components/styled/index.js @@ -2,7 +2,13 @@ import { Button } from './Button'; import CellButton, { Label, SubText } from './CellButton'; -import { RedButton, GreenButton, BlueButton, TransparentButton, RedTransparentButton } from './AppButton'; +import { + RedButton, + GreenButton, + BlueButton, + TransparentButton, + RedTransparentButton, +} from './AppButton'; export { Button, |
