Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit e42d4e1

Browse files
committed
feat: new notifications alignment and position
1 parent a3a6a1e commit e42d4e1

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

@types/cherry.d.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,15 @@ declare class Space extends React.Component<SpaceProps, any> {}
4141

4242
declare class TableOverflow extends React.Component<TableOverflowProps, any> {}
4343

44-
45-
declare class ToastNotificationsProvider extends React.Component<
46-
any,
47-
any
48-
> {}
44+
declare class ToastNotificationsProvider extends React.Component<any, any> {}
4945

5046
declare class ToastNotifications extends React.Component<
51-
any,
47+
ToastNotificationsProps,
5248
any
5349
> {}
5450

55-
const ToastNotificationsContext = React.createContext<ToastNotificationsContextProps | null>(null);
51+
const ToastNotificationsContext =
52+
React.createContext<ToastNotificationsContextProps | null>(null);
5653

5754
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
5855
children?: React.ReactNode;
@@ -278,6 +275,12 @@ interface ToastNotificationsContextProps {
278275
) => void;
279276
}
280277

278+
interface ToastNotificationsProps {
279+
align?: "right" | "left" | "center";
280+
bottom?: boolean;
281+
theme?: object;
282+
}
283+
281284
export {
282285
Button,
283286
Container,

dist/cherry.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cherry.module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cherry-components",
3-
"version": "0.0.2-20",
3+
"version": "0.0.2-21",
44
"description": "Cherry React Components",
55
"main": "dist/cherry.js",
66
"module": "dist/cherry.module.js",

src/Layout/ToastNotifications/ToastNotifications.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import * as styles from "./ToastNotifications.styles";
44
import { Close } from "../../svg/Close";
55
import { localTheme } from "../../theme";
66

7-
function ToastNotifications({ theme = localTheme }) {
7+
function ToastNotifications({ align = "center", bottom, theme = localTheme }) {
88
const { notifications } = useContext(ToastNotificationsContext);
99

1010
return (
11-
<ul css={styles.notificationsStyles(theme)}>
11+
<ul css={styles.notificationsStyles(theme, align, bottom)}>
1212
{notifications.map((notification, i) => (
1313
<NotificationItem key={i} {...notification} />
1414
))}

src/Layout/ToastNotifications/ToastNotifications.styles.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
import { css } from "@emotion/react";
22
import { resetButtonStyles, shadowStyles } from "../../helperStyles";
33

4-
export const notificationsStyles = (theme) => css`
4+
export const notificationsStyles = (theme, align, bottom) => css`
55
position: fixed;
6-
top: 12px;
7-
left: 50%;
8-
transform: translateX(-50%);
96
z-index: 99999;
107
margin: 0;
118
padding: 0;
129
list-style: none;
1310
11+
${align === "center" &&
12+
css`
13+
left: 50%;
14+
transform: translateX(-50%);
15+
`}
16+
17+
${align === "right" &&
18+
css`
19+
right: 20px;
20+
`}
21+
22+
${align === "left" &&
23+
css`
24+
left: 20px;
25+
`}
26+
27+
${bottom
28+
? css`
29+
bottom: 12px;
30+
`
31+
: css`
32+
top: 12px;
33+
`}
34+
1435
& li {
1536
justify-content: center;
1637
display: flex;

0 commit comments

Comments
 (0)