summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-04-09 15:29:28 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-04-14 13:12:21 +0200
commit84f41658296c8bfa14ca432f0096cd9769afaecd (patch)
tree9e82e8202a440f06f2a1261f69139564091cf5c5 /gui/src/renderer/components
parent492e18f9afd63e036a83d37996a17c30cb6896c8 (diff)
downloadmullvadvpn-84f41658296c8bfa14ca432f0096cd9769afaecd.tar.xz
mullvadvpn-84f41658296c8bfa14ca432f0096cd9769afaecd.zip
Convert Modal.tsx to pure React
Diffstat (limited to 'gui/src/renderer/components')
-rw-r--r--gui/src/renderer/components/Modal.tsx136
1 files changed, 70 insertions, 66 deletions
diff --git a/gui/src/renderer/components/Modal.tsx b/gui/src/renderer/components/Modal.tsx
index c00a1be466..4cd3ab87a2 100644
--- a/gui/src/renderer/components/Modal.tsx
+++ b/gui/src/renderer/components/Modal.tsx
@@ -1,60 +1,77 @@
+import { StyleSheet, css } from 'aphrodite';
import * as React from 'react';
import ReactDOM from 'react-dom';
-import { Component, Styles, Text, View } from 'reactxp';
import { colors } from '../../config.json';
import ImageView from './ImageView';
const MODAL_CONTAINER_ID = 'modalContainer';
-const styles = {
- modalAlertBackground: Styles.createViewStyle({
+const styles = StyleSheet.create({
+ modalAlertBackground: {
+ display: 'flex',
flex: 1,
- justifyContent: 'center',
- paddingLeft: 14,
- paddingRight: 14,
- }),
- modalAlert: Styles.createViewStyle({
- backgroundColor: colors.darkBlue,
- borderRadius: 11,
- padding: 16,
- }),
- modalAlertIcon: Styles.createViewStyle({
alignItems: 'center',
- marginBottom: 12,
- marginTop: 4,
- }),
- modalAlertMessage: Styles.createTextStyle({
+ paddingLeft: '14px',
+ paddingRight: '14px',
+ },
+ modalAlert: {
+ display: 'flex',
+ flex: 1,
+ flexDirection: 'column',
+ backgroundColor: colors.darkBlue,
+ borderRadius: '11px',
+ padding: '16px',
+ },
+ modalAlertIcon: {
+ display: 'flex',
+ justifyContent: 'center',
+ margin: '4px 0 12px',
+ },
+ modalAlertMessage: {
fontFamily: 'Open Sans',
- fontSize: 16,
- fontWeight: '500',
- lineHeight: 20,
+ fontSize: '16px',
+ fontWeight: 500,
+ lineHeight: '20px',
color: colors.white80,
- }),
- modalAlertButtonContainer: Styles.createViewStyle({
- marginTop: 16,
- }),
-};
+ },
+ modalAlertButtonContainer: {
+ display: 'flex',
+ flexDirection: 'column',
+ marginTop: '16px',
+ },
+ modalContent: {
+ position: 'absolute',
+ display: 'flex',
+ flexDirection: 'column',
+ flex: 1,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ },
+ modalBackground: {
+ backgroundColor: 'rgba(0,0,0,0.5)',
+ position: 'absolute',
+ display: 'flex',
+ flexDirection: 'column',
+ flex: 1,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ },
+ modalContainer: {
+ position: 'relative',
+ flex: 1,
+ },
+});
interface IModalContentProps {
children?: React.ReactNode;
}
export const ModalContent: React.FC = (props: IModalContentProps) => {
- return (
- <div
- style={{
- position: 'absolute',
- display: 'flex',
- flexDirection: 'column',
- flex: 1,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }}>
- {props.children}
- </div>
- );
+ return <div className={css(styles.modalContent)}>{props.children}</div>;
};
interface IModalBackgroundProps {
@@ -62,22 +79,7 @@ interface IModalBackgroundProps {
}
const ModalBackground: React.FC = (props: IModalBackgroundProps) => {
- return (
- <div
- style={{
- backgroundColor: 'rgba(0,0,0,0.5)',
- position: 'absolute',
- display: 'flex',
- flexDirection: 'column',
- flex: 1,
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- }}>
- {props.children}
- </div>
- );
+ return <div className={css(styles.modalBackground)}>{props.children}</div>;
};
interface IModalContainerProps {
@@ -86,7 +88,7 @@ interface IModalContainerProps {
export const ModalContainer: React.FC = (props: IModalContainerProps) => {
return (
- <div id={MODAL_CONTAINER_ID} style={{ position: 'relative', flex: 1 }}>
+ <div id={MODAL_CONTAINER_ID} className={css(styles.modalContainer)}>
<ModalContent>{props.children}</ModalContent>
</div>
);
@@ -104,7 +106,7 @@ interface IModalAlertProps {
children?: React.ReactNode;
}
-export class ModalAlert extends Component<IModalAlertProps> {
+export class ModalAlert extends React.Component<IModalAlertProps> {
private element = document.createElement('div');
private modalContainer?: Element;
@@ -131,22 +133,24 @@ export class ModalAlert extends Component<IModalAlertProps> {
private renderModal() {
return (
<ModalBackground>
- <View style={styles.modalAlertBackground}>
- <View style={styles.modalAlert}>
+ <div className={css(styles.modalAlertBackground)}>
+ <div className={css(styles.modalAlert)}>
{this.props.type && (
- <View style={styles.modalAlertIcon}>{this.renderTypeIcon(this.props.type)}</View>
+ <div className={css(styles.modalAlertIcon)}>
+ {this.renderTypeIcon(this.props.type)}
+ </div>
)}
{this.props.message && (
- <Text style={styles.modalAlertMessage}>{this.props.message}</Text>
+ <span className={css(styles.modalAlertMessage)}>{this.props.message}</span>
)}
{this.props.children}
{this.props.buttons.map((button, index) => (
- <View key={index} style={styles.modalAlertButtonContainer}>
+ <div key={index} className={css(styles.modalAlertButtonContainer)}>
{button}
- </View>
+ </div>
))}
- </View>
- </View>
+ </div>
+ </div>
</ModalBackground>
);
}