diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-08-28 19:55:05 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-08-28 19:55:05 +0200 |
| commit | d2d32175fd1e8fbf04dd6d5d7ee03c7e419af23e (patch) | |
| tree | 00568f29c44b1800fd0c9b30e8aba766f855fb00 /gui/src/renderer/components | |
| parent | 2ae7b31424c13b451f18a09457da115b8f96af0e (diff) | |
| parent | 3ab3fa377f09646a2d1f4bdfc2e94b821ecbcc47 (diff) | |
| download | mullvadvpn-d2d32175fd1e8fbf04dd6d5d7ee03c7e419af23e.tar.xz mullvadvpn-d2d32175fd1e8fbf04dd6d5d7ee03c7e419af23e.zip | |
Merge branch 'convert-platform-window-from-reactxp' into master
Diffstat (limited to 'gui/src/renderer/components')
| -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, + }; +}); |
