diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-05-27 17:47:08 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-05-27 17:47:08 +0200 |
| commit | 3a801671a2dab9a6359ca0cc0b581193fb3649b7 (patch) | |
| tree | ef576608e6a643630aa3bc3762523e84c36452f6 /gui/src/renderer/components/MultiButton.tsx | |
| parent | e7824eb7d2c8368f6aefa157155e9e5a3beb7a76 (diff) | |
| parent | a03dc3d0a0dc22b234c49a61590173aa8a401c9d (diff) | |
| download | mullvadvpn-3a801671a2dab9a6359ca0cc0b581193fb3649b7.tar.xz mullvadvpn-3a801671a2dab9a6359ca0cc0b581193fb3649b7.zip | |
Merge branch 'convert-app-button-to-styled-components'
Diffstat (limited to 'gui/src/renderer/components/MultiButton.tsx')
| -rw-r--r-- | gui/src/renderer/components/MultiButton.tsx | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/gui/src/renderer/components/MultiButton.tsx b/gui/src/renderer/components/MultiButton.tsx index efd21ee9ca..a9f1d09dee 100644 --- a/gui/src/renderer/components/MultiButton.tsx +++ b/gui/src/renderer/components/MultiButton.tsx @@ -1,49 +1,40 @@ -import * as React from 'react'; -import { Component, Styles, Types, View } from 'reactxp'; +import React from 'react'; +import styled from 'styled-components'; +import * as AppButton from './AppButton'; const SIDE_BUTTON_WIDTH = 50; -const styles = { - buttonRow: Styles.createViewStyle({ - flexDirection: 'row', - }), - mainButton: Styles.createViewStyle({ - flex: 1, - borderTopRightRadius: 0, - borderBottomRightRadius: 0, - }), - sideButton: Styles.createViewStyle({ - borderTopLeftRadius: 0, - borderBottomLeftRadius: 0, - width: SIDE_BUTTON_WIDTH, - alignItems: 'center', - marginLeft: 1, - }), -}; +const ButtonRow = styled.div({ + display: 'flex', + flexDirection: 'row', +}); -interface IProps { - mainButton: React.ComponentType<IMainButtonProps>; - sideButton: React.ComponentType<ISideButtonProps>; -} +const MainButton = styled.button({ + display: 'flex', + flex: 1, + borderTopRightRadius: 0, + borderBottomRightRadius: 0, +}); -export interface IMainButtonProps { - textOffset: number; - style?: Types.StyleRuleSetRecursive<Types.ViewStyleRuleSet>; -} +const SideButton = styled.button({ + display: 'flex', + borderTopLeftRadius: 0, + borderBottomLeftRadius: 0, + width: SIDE_BUTTON_WIDTH, + alignItems: 'center', + marginLeft: 1, +}); -export interface ISideButtonProps { - style?: Types.StyleRuleSetRecursive<Types.ViewStyleRuleSet>; +interface IMultiButtonProps { + mainButton: React.ComponentType<AppButton.IProps>; + sideButton: React.ComponentType<AppButton.IProps>; } -export class MultiButton extends Component<IProps> { - public render() { - const { mainButton: MainButton, sideButton: SideButton } = this.props; - - return ( - <View style={styles.buttonRow}> - <MainButton textOffset={SIDE_BUTTON_WIDTH} style={styles.mainButton} /> - <SideButton style={styles.sideButton} /> - </View> - ); - } +export function MultiButton(props: IMultiButtonProps) { + return ( + <ButtonRow> + <MainButton as={props.mainButton} textOffset={SIDE_BUTTON_WIDTH} /> + <SideButton as={props.sideButton} /> + </ButtonRow> + ); } |
