aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/ui/Alert.tsx
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-10-29 15:24:06 +0100
committersonartech <sonartech@sonarsource.com>2018-10-30 12:42:03 +0100
commit440e9db98d7e1a748cb02c8839e21e94ebd2efa4 (patch)
treecddffbbae2f421bf8433663e5abb6bce7e993997 /server/sonar-web/src/main/js/components/ui/Alert.tsx
parent39db83f50fc00ad01b2ed898bf6a8b39b51f4c9c (diff)
downloadsonarqube-440e9db98d7e1a748cb02c8839e21e94ebd2efa4.tar.gz
sonarqube-440e9db98d7e1a748cb02c8839e21e94ebd2efa4.zip
SONAR-11204 Colorblind friendly banners (#899)
Diffstat (limited to 'server/sonar-web/src/main/js/components/ui/Alert.tsx')
-rw-r--r--server/sonar-web/src/main/js/components/ui/Alert.tsx59
1 files changed, 59 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/ui/Alert.tsx b/server/sonar-web/src/main/js/components/ui/Alert.tsx
new file mode 100644
index 00000000000..d7699877bd1
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/ui/Alert.tsx
@@ -0,0 +1,59 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import * as React from 'react';
+import * as classNames from 'classnames';
+import * as theme from '../../app/theme';
+import AlertErrorIcon from '../icons-components/AlertErrorIcon';
+import InfoIcon from '../icons-components/InfoIcon';
+import AlertWarnIcon from '../icons-components/AlertWarnIcon';
+import AlertSuccessIcon from '../icons-components/AlertSuccessIcon';
+import Tooltip from '../controls/Tooltip';
+import { translate } from '../../helpers/l10n';
+
+type AlertDisplay = 'block' | 'inline';
+type AlertVariant = 'error' | 'warning' | 'success' | 'info';
+
+export interface AlertProps {
+ display?: AlertDisplay;
+ variant: AlertVariant;
+}
+
+export function Alert(props: AlertProps & React.HTMLAttributes<HTMLElement>) {
+ const { className, display, variant, ...domProps } = props;
+ return (
+ <div
+ className={classNames('alert', `alert-${variant}`, className, {
+ 'is-inline': display === 'inline'
+ })}
+ role="alert"
+ {...domProps}>
+ <Tooltip overlay={translate('alert.tooltip', variant)}>
+ <div className="alert-icon">
+ {variant === 'error' && <AlertErrorIcon fill={theme.alertIconError} />}
+ {variant === 'warning' && <AlertWarnIcon fill={theme.alertIconWarning} />}
+ {variant === 'success' && <AlertSuccessIcon fill={theme.alertIconSuccess} />}
+ {variant === 'info' && <InfoIcon fill={theme.alertIconInfo} />}
+ </div>
+ </Tooltip>
+
+ <div className="alert-content">{props.children}</div>
+ </div>
+ );
+}