summaryrefslogtreecommitdiffhomepage
path: root/app/components/styled/AppButton.js
diff options
context:
space:
mode:
authoranderklander <anderklander@gmail.com>2018-04-08 20:05:25 +0200
committeranderklander <anderklander@gmail.com>2018-04-11 13:45:42 +0200
commitbd5708c2af1650aa2a8019f0f0a9fb815dd6091f (patch)
treee5f2b88ac5c82cfa8397bc01fc23acb8d004f3c9 /app/components/styled/AppButton.js
parent5b2efbd2664209f671f30cebf22fd633a92544d1 (diff)
downloadmullvadvpn-bd5708c2af1650aa2a8019f0f0a9fb815dd6091f.tar.xz
mullvadvpn-bd5708c2af1650aa2a8019f0f0a9fb815dd6091f.zip
Revert to blur-able button on web
Diffstat (limited to 'app/components/styled/AppButton.js')
-rw-r--r--app/components/styled/AppButton.js76
1 files changed, 44 insertions, 32 deletions
diff --git a/app/components/styled/AppButton.js b/app/components/styled/AppButton.js
index fdb6d35dfa..5561aba4fb 100644
--- a/app/components/styled/AppButton.js
+++ b/app/components/styled/AppButton.js
@@ -44,6 +44,11 @@ const styles = {
right: 8,
marginLeft: 8,
},
+ iconTransparent:{
+ position: 'absolute',
+ alignSelf: 'flex-end',
+ right: 42,
+ },
common:{
paddingTop: 9,
paddingLeft: 9,
@@ -78,45 +83,46 @@ class BaseButton extends Component {
props: {
children?: React.Node,
disabled: boolean,
+ onPress?: ()=>{},
};
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;
-
- 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() ]}
- onHoverStart={this.onHoverStart}
- onHoverEnd={this.onHoverEnd}
- {...otherProps}>
- {
- React.Children.map(children, (node) => {
- if (React.isValidElement(node)) {
- let updatedProps = {};
+ cloneChildren = (children) => {return 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 === 'Label') {
+ updatedProps = { style: [styles.label, this.textStyle()]};
+ }
- if(node.type.name === 'Img') {
- updatedProps = { tintColor:'currentColor', style: [styles.icon, this.iconStyle()]};
- }
+ 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>
- );
+ return React.cloneElement(node, updatedProps);
+ } else {
+ return <Label style={[styles.label, this.textStyle()]}>{children}</Label>;
+ }
+ });
}
+
+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;
+render() {
+ const { children, ...otherProps } = this.props;
+ return (
+ <Button style={[ styles.common, this.backgroundStyle() ]}
+ onHoverStart={this.onHoverStart}
+ onHoverEnd={this.onHoverEnd}
+ {...otherProps}>
+ { this.cloneChildren(children) }
+ </Button>);
+}
}
export class RedButton extends BaseButton {
@@ -132,5 +138,11 @@ export class BlueButton extends BaseButton {
}
export class TransparentButton extends BaseButton {
- backgroundStyle = () => this.state.hovered ? styles.transparentHover : styles.transparent;
+ iconStyle = () => [styles.iconTransparent, this.state.hovered ? styles.white80 : styles.white];
+ render(){
+ const { children, onPress, ...otherProps } = this.props;
+ return (<button className="button button--neutral button--blur" onClick={ onPress } {...otherProps}>
+ { this.cloneChildren(children) }
+ </button>);
+ }
} \ No newline at end of file