Skip to content

Commit 9e57359

Browse files
authored
Merge branch 'main' into fix/workspace
2 parents f1500e2 + 33695e6 commit 9e57359

File tree

7 files changed

+52
-14
lines changed

7 files changed

+52
-14
lines changed

packages/fuselage-toastbar/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @rocket.chat/fuselage-toastbar
22

3+
## 0.35.0
4+
5+
### Minor Changes
6+
7+
- [#1591](https://github.com/RocketChat/fuselage/pull/1591) [`13755ae`](https://github.com/RocketChat/fuselage/commit/13755aef092f68a392809999a03c54bd0ec66749) Thanks [@juliajforesti](https://github.com/juliajforesti)! - feat(toastbar): new Toastbar variants
8+
39
## 0.34.0
410

511
### Minor Changes

packages/fuselage-toastbar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rocket.chat/fuselage-toastbar",
3-
"version": "0.34.0",
3+
"version": "0.35.0",
44
"description": "Fuselage ToastBar component",
55
"keywords": [
66
"rocketchat",

packages/fuselage-toastbar/src/ToastBar.stories.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,16 @@ export const Default: StoryFn = () => {
5353
);
5454
};
5555

56-
const Template: StoryFn<{
57-
position: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
58-
}> = ({ position }) => {
56+
const Template: StoryFn<typeof useToastBarDispatch> = (args) => {
5957
const dispatchToastMessage = useToastBarDispatch();
6058

6159
useEffect(() => {
6260
dispatchToastMessage({
6361
type: 'success',
6462
message: DEFAULT_MESSAGE,
65-
position,
63+
...args,
6664
});
67-
}, [dispatchToastMessage, position]);
65+
}, [args, dispatchToastMessage]);
6866

6967
return (
7068
<Button
@@ -73,7 +71,7 @@ const Template: StoryFn<{
7371
dispatchToastMessage({
7472
type: 'success',
7573
message: DEFAULT_MESSAGE,
76-
position,
74+
...args,
7775
})
7876
}
7977
>
@@ -101,3 +99,8 @@ export const BottomEnd = Template.bind({});
10199
BottomEnd.args = {
102100
position: 'bottom-end',
103101
};
102+
103+
export const Persistent = Template.bind({});
104+
Persistent.args = {
105+
isPersistent: true,
106+
};

packages/fuselage-toastbar/src/ToastBarContext.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { createContext, useContext } from 'react';
1+
import { createContext, ReactNode, useContext } from 'react';
22

33
export type ToastBarPayload = {
44
type?: 'success' | 'info' | 'error';
5-
message: string | Error;
5+
message: ReactNode | string | Error;
66
title?: string;
77
position?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
88
time: number;
99
id: string;
10+
isPersistent?: boolean;
1011
};
1112

1213
type ToastBarContextValue = {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ToastBar } from '@rocket.chat/fuselage';
2+
import type { ReactElement } from 'react';
3+
4+
import type { ToastBarPayload } from './ToastBarContext';
5+
6+
const ToastBarPersistent = ({
7+
type,
8+
message,
9+
title,
10+
id,
11+
}: ToastBarPayload): ReactElement => {
12+
return (
13+
<ToastBar variant={type} id={id} isPaused>
14+
{title}
15+
{message instanceof Error ? String(message) : message}
16+
</ToastBar>
17+
);
18+
};
19+
20+
export default ToastBarPersistent;

packages/fuselage-toastbar/src/ToastBarProvider.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useState, memo, useCallback } from 'react';
33

44
import type { ToastBarPayload } from './ToastBarContext';
55
import { ToastBarContext } from './ToastBarContext';
6+
import ToastBarPersistent from './ToastBarPersistent';
67
import ToastBarPortal from './ToastBarPortal';
78
import ToastBarTimed from './ToastBarTimed';
89
import ToastBarZone from './ToastBarZone';
@@ -52,9 +53,13 @@ const ToastBarProvider = ({ children }: ToastBarProps): ReactElement => {
5253
key={zone}
5354
position={zone as ToastBarPayload['position']}
5455
>
55-
{toasts.map((toast) => (
56-
<ToastBarTimed key={toast.id} {...toast} />
57-
))}
56+
{toasts.map((toast) =>
57+
toast.isPersistent ? (
58+
<ToastBarPersistent key={toast.id} {...toast} />
59+
) : (
60+
<ToastBarTimed key={toast.id} {...toast} />
61+
),
62+
)}
5863
</ToastBarZone>
5964
))}
6065
</ToastBarPortal>

packages/fuselage-toastbar/src/ToastBarTimed.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ToastBarTimed = ({
1010
type,
1111
id,
1212
message,
13+
title,
1314
}: ToastBarPayload): ReactElement => {
1415
const dismissToastMessage = useToastBarDismiss();
1516

@@ -23,12 +24,14 @@ const ToastBarTimed = ({
2324
variant={type}
2425
onPointerEnter={() => pause()}
2526
onPointerLeave={() => resume()}
26-
children={String(message)}
2727
onClose={dismissToastMessage}
2828
id={id}
2929
time={time}
3030
isPaused={isPaused}
31-
/>
31+
>
32+
{title}
33+
{message instanceof Error ? String(message) : message}
34+
</ToastBar>
3235
);
3336
};
3437

0 commit comments

Comments
 (0)