summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components/Modal.tsx
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-02-11 18:00:59 +0100
committerOskar Nyberg <oskar@mullvad.net>2020-02-12 21:12:12 +0100
commitde59f4a1528f062f50044366f024c786fbc30927 (patch)
tree91e76f648135d62b456cfa57dab8cef59fabd4cc /gui/src/renderer/components/Modal.tsx
parent75e97041d7c922dff5d0783cc0431b0646283898 (diff)
downloadmullvadvpn-de59f4a1528f062f50044366f024c786fbc30927.tar.xz
mullvadvpn-de59f4a1528f062f50044366f024c786fbc30927.zip
Add dialog icon
Diffstat (limited to 'gui/src/renderer/components/Modal.tsx')
-rw-r--r--gui/src/renderer/components/Modal.tsx31
1 files changed, 31 insertions, 0 deletions
diff --git a/gui/src/renderer/components/Modal.tsx b/gui/src/renderer/components/Modal.tsx
index 3e7ec4414f..b0a972955d 100644
--- a/gui/src/renderer/components/Modal.tsx
+++ b/gui/src/renderer/components/Modal.tsx
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Component, Styles, Text, View } from 'reactxp';
import { colors } from '../../config.json';
+import ImageView from './ImageView';
const styles = {
modalAlertBackground: Styles.createViewStyle({
@@ -14,6 +15,11 @@ const styles = {
borderRadius: 11,
padding: 16,
}),
+ modalAlertIcon: Styles.createViewStyle({
+ alignItems: 'center',
+ marginBottom: 12,
+ marginTop: 4,
+ }),
modalAlertMessage: Styles.createTextStyle({
fontFamily: 'Open Sans',
fontSize: 16,
@@ -67,7 +73,13 @@ export const ModalContainer: React.FC = ({ children }) => {
return <div style={{ position: 'relative', flex: 1 }}>{children}</div>;
};
+export enum ModalAlertType {
+ Info = 1,
+ Warning,
+}
+
interface IModalAlertProps {
+ type?: ModalAlertType;
message: string;
buttons: React.ReactNode[];
}
@@ -78,6 +90,9 @@ export class ModalAlert extends Component<IModalAlertProps> {
<ModalBackground>
<View style={styles.modalAlertBackground}>
<View style={styles.modalAlert}>
+ {this.props.type && (
+ <View style={styles.modalAlertIcon}>{this.renderTypeIcon(this.props.type)}</View>
+ )}
<Text style={styles.modalAlertMessage}>{this.props.message}</Text>
{this.props.buttons.map((button, index) => (
<View key={index} style={styles.modalAlertButtonContainer}>
@@ -89,4 +104,20 @@ export class ModalAlert extends Component<IModalAlertProps> {
</ModalBackground>
);
}
+
+ private renderTypeIcon(type: ModalAlertType) {
+ let source = '';
+ let color = '';
+ switch (type) {
+ case ModalAlertType.Info:
+ source = 'icon-alert';
+ color = colors.white;
+ break;
+ case ModalAlertType.Warning:
+ source = 'icon-alert';
+ color = colors.red;
+ break;
+ }
+ return <ImageView height={44} width={44} source={source} tintColor={color} />;
+ }
}