Skip to content

Commit 6d0b098

Browse files
committed
Merge branch 'main' of github.com:Arize-ai/ui-components
2 parents 2045bdd + 9d571a6 commit 6d0b098

File tree

5 files changed

+75
-38
lines changed

5 files changed

+75
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.4.4",
2+
"version": "0.4.5",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/alert/styles.ts

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
11
import { css } from '@emotion/core';
2-
import { transparentize } from 'polished';
2+
import { transparentize, darken } from 'polished';
33
import theme from '../theme';
44

55
export const baseSeverityCSS = css`
6-
backdrop-filter: blur(4px);
6+
backdrop-filter: blur(10px);
77
`;
8-
export const warningCSS = css(
9-
baseSeverityCSS,
10-
css`
11-
border: 1px solid ${theme.colors.statusWarning};
12-
background-color: ${transparentize(0.85, theme.colors.statusWarning)};
13-
color: ${theme.colors.statusWarning};
14-
`
15-
);
168

17-
export const infoCSS = css(
18-
baseSeverityCSS,
19-
css`
20-
border: 1px solid ${theme.colors.statusInfo};
21-
background-color: ${transparentize(0.85, theme.colors.statusInfo)};
22-
color: ${theme.colors.statusInfo};
23-
`
24-
);
9+
const bgDarken = 0.4,
10+
bgTransparentize = 0.5,
11+
// FireFox does not support backdrop-filter so needs to be less transparent and darker
12+
bgDarkenFallback = 0.45,
13+
bgTransparentizeFallback = 0.1;
2514

26-
export const dangerCSS = css(
27-
baseSeverityCSS,
28-
css`
29-
border: 1px solid ${theme.colors.statusDanger};
30-
background-color: ${transparentize(0.85, theme.colors.statusDanger)};
31-
color: ${theme.colors.statusDanger};
32-
`
33-
);
15+
const generateSeverityCSS = (severityColor: string) =>
16+
css(
17+
baseSeverityCSS,
18+
css`
19+
border: 1px solid ${severityColor};
20+
/* FireFox Only style */
21+
background-color: ${transparentize(
22+
bgTransparentizeFallback,
23+
darken(bgDarkenFallback, severityColor)
24+
)};
25+
color: ${severityColor};
26+
/* background-filter support (Chrome / Safari) */
27+
@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
28+
background-color: ${transparentize(
29+
bgTransparentize,
30+
darken(bgDarken, severityColor)
31+
)};
32+
}
33+
`
34+
);
3435

35-
export const successCSS = css(
36-
baseSeverityCSS,
37-
css`
38-
border: 1px solid ${theme.colors.statusSuccess};
39-
background-color: ${transparentize(0.85, theme.colors.statusSuccess)};
40-
color: ${theme.colors.statusSuccess};
41-
`
42-
);
36+
export const warningCSS = generateSeverityCSS(theme.colors.statusWarning);
37+
export const infoCSS = generateSeverityCSS(theme.colors.statusInfo);
38+
export const dangerCSS = generateSeverityCSS(theme.colors.statusDanger);
39+
export const successCSS = generateSeverityCSS(theme.colors.statusSuccess);

src/notification/Notification.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, CSSProperties } from 'react';
22
import { css } from '@emotion/core';
33
import { Overlay } from '../overlays';
44
import { Notice } from './Notice';
@@ -10,7 +10,12 @@ import {
1010
TRANSITION_EXIT_DURATION_MS,
1111
} from './constants';
1212

13-
export type NotificationProps = {};
13+
export type NotificationProps = {
14+
/**
15+
* If provided, the notification container will use this style as a final override
16+
*/
17+
style?: CSSProperties;
18+
};
1419

1520
type NotificationState = {
1621
notices: NoticeDefinition[];
@@ -72,6 +77,7 @@ export class Notification extends Component<
7277
margin-top: ${theme.spacing.margin16}px;
7378
}
7479
`}
80+
{...this.props}
7581
>
7682
<TransitionGroup className="ac-notice-list">
7783
{this.state.notices.map(notice => (

stories/Gallery.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ const Template: Story = args => {
4747
variant="default"
4848
onClick={() => {
4949
notify({
50-
variant: 'success',
50+
// @ts-ignore
51+
variant: ['info', 'success', 'warning', 'danger'][
52+
Math.floor(Math.random() * 4)
53+
],
5154
title: 'Awesome!',
5255
message: 'Things worked as expected',
5356
action: {

stories/Notification.stories.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,34 @@ const Template: Story<any> = args => {
8686
// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
8787
// https://storybook.js.org/docs/react/workflows/unit-testing
8888
export const Default = Template.bind({});
89+
90+
export const WithCustomStyle = () => {
91+
const [notice, holder] = useNotification({
92+
style: { bottom: 100, right: 30 },
93+
});
94+
return (
95+
<Provider>
96+
<button
97+
onClick={() => {
98+
notice({
99+
// @ts-ignore
100+
variant: ['info', 'success', 'warning', 'danger'][
101+
Math.floor(Math.random() * 4)
102+
],
103+
title: 'Clicked',
104+
message: 'Do you see this?',
105+
action: {
106+
text: 'Try This',
107+
onClick: () => {
108+
alert('Done');
109+
},
110+
},
111+
});
112+
}}
113+
>
114+
Click Me
115+
</button>
116+
{holder}
117+
</Provider>
118+
);
119+
};

0 commit comments

Comments
 (0)