diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-08-28 15:19:56 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-08-28 17:23:55 +0200 |
| commit | 44af788041d69d660e55aeb5c403323700e88777 (patch) | |
| tree | 960e5773287adaf42967fe2f3db28ca4ee721f93 /gui/src | |
| parent | 2ae7b31424c13b451f18a09457da115b8f96af0e (diff) | |
| download | mullvadvpn-44af788041d69d660e55aeb5c403323700e88777.tar.xz mullvadvpn-44af788041d69d660e55aeb5c403323700e88777.zip | |
Convert PlatformWindow from ReactXP
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/PlatformWindow.tsx | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/gui/src/renderer/components/PlatformWindow.tsx b/gui/src/renderer/components/PlatformWindow.tsx index cc10374fec..c461b647f6 100644 --- a/gui/src/renderer/components/PlatformWindow.tsx +++ b/gui/src/renderer/components/PlatformWindow.tsx @@ -1,42 +1,26 @@ -import * as React from 'react'; -import { Component, Styles, Types, View } from 'reactxp'; +import styled from 'styled-components'; -interface IProps { - arrowPosition?: number; -} +const ARROW_WIDTH = 30; -const containerStyle = Styles.createViewStyle({ flex: 1 }); +export default styled.div({}, ({ arrowPosition }: { arrowPosition?: number }) => { + let mask: string | undefined; -export default class PlatformWindow extends Component<IProps> { - public render() { - return <View style={[containerStyle, this.platformStyle()]}>{this.props.children}</View>; - } - - private platformStyle(): Types.ViewStyleRuleSet { - if (process.platform === 'darwin') { - const arrowPosition = this.props.arrowPosition; - let arrowPositionCss = '50%'; - - if (typeof arrowPosition === 'number') { - const arrowWidth = 30; - const adjustedArrowPosition = arrowPosition - arrowWidth * 0.5; - arrowPositionCss = `${adjustedArrowPosition}px`; - } + if (process.platform === 'darwin') { + const arrowPositionCss = + arrowPosition !== undefined ? `${arrowPosition - ARROW_WIDTH * 0.5}px` : '50%'; - const webkitMask = [ - `url(../../assets/images/app-triangle.svg) ${arrowPositionCss} 0% no-repeat`, - `url(../../assets/images/app-header-backdrop.svg) no-repeat`, - ]; - - return Styles.createViewStyle( - { - // @ts-ignore - WebkitMask: webkitMask.join(','), - }, - false, - ); - } else { - return undefined; - } + mask = [ + `url(../../assets/images/app-triangle.svg) ${arrowPositionCss} 0% no-repeat`, + `url(../../assets/images/app-header-backdrop.svg) no-repeat`, + ].join(','); } -} + + return { + position: 'relative', + overflow: 'hidden', + display: 'flex', + flexDirection: 'column', + flex: 1, + mask, + }; +}); |
