diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-07-18 15:07:37 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-08-15 17:39:38 +0200 |
| commit | 71592249b2dd669b6f24f37bfb7b0f4e43b74998 (patch) | |
| tree | a6097dc7e5d94d06e99c65fdfe160e824395f50c /app/components/Cell.js | |
| parent | e84e87f4ce5a8c242f756566cdc6fb59a45f7bea (diff) | |
| download | mullvadvpn-71592249b2dd669b6f24f37bfb7b0f4e43b74998.tar.xz mullvadvpn-71592249b2dd669b6f24f37bfb7b0f4e43b74998.zip | |
Add workspaces
Diffstat (limited to 'app/components/Cell.js')
| -rw-r--r-- | app/components/Cell.js | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/app/components/Cell.js b/app/components/Cell.js deleted file mode 100644 index 0fd4de40e6..0000000000 --- a/app/components/Cell.js +++ /dev/null @@ -1,117 +0,0 @@ -// @flow - -import * as React from 'react'; -import { Button, Text, Component, Styles, Types } from 'reactxp'; -import Img from './Img'; -import { colors } from '../config'; - -const styles = { - cell: Styles.createViewStyle({ - backgroundColor: colors.blue, - paddingTop: 14, - paddingBottom: 14, - paddingLeft: 16, - paddingRight: 16, - marginBottom: 1, - flex: 1, - flexDirection: 'row', - alignItems: 'center', - alignContent: 'center', - cursor: 'default', - }), - cellHover: Styles.createViewStyle({ - backgroundColor: colors.blue80, - }), - icon: Styles.createViewStyle({ - color: colors.white60, - marginLeft: 8, - }), - - label: Styles.createTextStyle({ - color: colors.white, - alignSelf: 'center', - fontFamily: 'DINPro', - fontSize: 20, - fontWeight: '900', - lineHeight: 26, - flex: 1, - marginLeft: 8, - }), - subtext: Styles.createTextStyle({ - color: colors.white60, - fontFamily: 'Open Sans', - fontSize: 13, - fontWeight: '800', - flex: 0, - textAlign: 'right', - }), -}; - -export class SubText extends Text {} -export class Label extends Text {} - -type CellButtonProps = { - children?: React.Node, - disabled?: boolean, - cellHoverStyle?: Types.ViewStyle, - style?: Types.ViewStyle, -}; - -type State = { hovered: boolean }; - -export 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.cellHover : 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)]} - onHoverStart={this.onHoverStart} - onHoverEnd={this.onHoverEnd} - {...otherProps}> - {React.Children.map(children, (node) => { - if (React.isValidElement(node)) { - let updatedProps = {}; - - if (node.type === Label) { - updatedProps = { - style: [styles.label, node.props.style, this.textStyle(node.props.cellHoverStyle)], - }; - } - - if (node.type === Img) { - updatedProps = { - tintColor: 'currentColor', - style: [styles.icon, node.props.style, this.iconStyle(node.props.cellHoverStyle)], - }; - } - - if (node.type === 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> - ); - } -} |
