Alert: Redesign with tinted background (#66918)

This commit is contained in:
Torkel Ödegaard 2023-05-01 15:50:25 +02:00 committed by GitHub
parent ba8bba78fc
commit d2bc270097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 29 deletions

View File

@ -280,7 +280,7 @@ export function createColors(colors: ThemeColorsInput): ThemeColors {
color.shade = base.mode === 'light' ? darken(color.main, tonalOffset) : lighten(color.main, tonalOffset);
}
if (!color.transparent) {
color.transparent = base.mode === 'light' ? alpha(color.main, 0.08) : alpha(color.main, 0.15);
color.transparent = alpha(color.main, 0.15);
}
if (!color.contrastText) {
color.contrastText = getContrastText(color.main);

View File

@ -30,8 +30,8 @@ export const palette = {
redDarkText: '#FF5286',
greenDarkMain: '#1A7F4B',
greenDarkText: '#6CCF8E',
orangeDarkMain: '#F5B73D',
orangeDarkText: '#F8D06B',
orangeDarkMain: '#FF9900',
orangeDarkText: '#fbad37',
blueLightMain: '#3871DC',
blueLightText: '#1F62E0',
@ -39,6 +39,6 @@ export const palette = {
redLightText: '#CF0E5B',
greenLightMain: '#1B855E',
greenLightText: '#0A764E',
orangeLightMain: '#FAD34A',
orangeLightText: '#8A6C00',
orangeLightMain: '#FF9900',
orangeLightText: '#B5510D',
};

View File

@ -1,5 +1,6 @@
import { css, cx } from '@emotion/css';
import React, { AriaRole, HTMLAttributes, ReactNode } from 'react';
import tinycolor2 from 'tinycolor2';
import { GrafanaTheme2 } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
@ -8,7 +9,6 @@ import { useTheme2 } from '../../themes';
import { IconName } from '../../types/icon';
import { Button } from '../Button/Button';
import { Icon } from '../Icon/Icon';
import { IconButton } from '../IconButton/IconButton';
export type AlertVariant = 'success' | 'warning' | 'error' | 'info';
@ -73,7 +73,14 @@ export const Alert = React.forwardRef<HTMLDivElement, Props>(
{/* If onRemove is specified, giving preference to onRemove */}
{onRemove && !buttonContent && (
<div className={styles.close}>
<IconButton aria-label="Close alert" name="times" onClick={onRemove} size="lg" type="button" />
<Button
aria-label="Close alert"
icon="times"
onClick={onRemove}
type="button"
fill="text"
variant="secondary"
/>
</div>
)}
@ -113,6 +120,7 @@ const getStyles = (
) => {
const color = theme.colors[severity];
const borderRadius = theme.shape.borderRadius();
const borderColor = tinycolor2(color.border).setAlpha(0.2).toString();
return {
alert: css`
@ -122,8 +130,10 @@ const getStyles = (
display: flex;
flex-direction: row;
align-items: stretch;
background: ${theme.colors.background.secondary};
box-shadow: ${elevated ? theme.shadows.z3 : theme.shadows.z1};
background: ${color.transparent};
box-shadow: ${elevated ? theme.shadows.z3 : 'none'};
padding: ${theme.spacing(1, 2)};
border: 1px solid ${borderColor};
margin-bottom: ${theme.spacing(bottomSpacing ?? 2)};
margin-top: ${theme.spacing(topSpacing ?? 0)};
@ -139,21 +149,15 @@ const getStyles = (
}
`,
icon: css`
padding: ${theme.spacing(2, 3)};
background: ${color.main};
border-radius: ${borderRadius} 0 0 ${borderRadius};
color: ${color.contrastText};
padding: ${theme.spacing(1, 2, 0, 0)};
color: ${color.text};
display: flex;
align-items: center;
justify-content: center;
`,
title: css`
font-weight: ${theme.typography.fontWeightMedium};
color: ${theme.colors.text.primary};
`,
title: css({
fontWeight: theme.typography.fontWeightMedium,
}),
body: css`
color: ${theme.colors.text.secondary};
padding: ${theme.spacing(2)};
padding: ${theme.spacing(1, 0)};
flex-grow: 1;
display: flex;
flex-direction: column;
@ -162,8 +166,7 @@ const getStyles = (
word-break: break-word;
`,
content: css`
color: ${theme.colors.text.secondary};
padding-top: ${hasTitle ? theme.spacing(1) : 0};
padding-top: ${hasTitle ? theme.spacing(0.5) : 0};
max-height: 50vh;
overflow-y: auto;
`,
@ -174,9 +177,12 @@ const getStyles = (
align-items: center;
`,
close: css`
padding: ${theme.spacing(2, 1)};
position: relative;
color: ${theme.colors.text.secondary};
background: none;
display: flex;
top: -6px;
right: -14px;
`,
};
};

View File

@ -17,7 +17,6 @@ const getStyles = (theme: GrafanaTheme2) => ({
alertParagraph: css`
margin: 0 ${theme.spacing(1)} 0 0;
line-height: ${theme.spacing(theme.components.height.sm)};
color: ${theme.colors.text.primary};
`,
});
@ -31,8 +30,8 @@ export function ConnectionsRedirectNotice() {
Data sources have a new home! You can discover new data sources or manage existing ones in the new Connections
page, accessible from the lefthand nav.
</p>
<LinkButton aria-label="Link to Connections" icon="adjust-circle" href={ROUTES.DataSources}>
See data sources in Connections
<LinkButton aria-label="Link to Connections" icon="arrow-right" href={ROUTES.DataSources} fill="text">
Go to connections
</LinkButton>
</div>
</Alert>

View File

@ -72,10 +72,8 @@ const getStyle = stylesFactory((theme: GrafanaTheme2) => {
margin: 16px;
`,
warn: css`
border: 2px solid ${theme.colors.warning.main};
max-width: 400px;
margin: auto;
height: 3em;
`,
};
});