Skip to content

Commit 9b3650a

Browse files
committed
feat(ui): move more Toast logic
1 parent 599d4cf commit 9b3650a

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

packages/ui-components/src/Common/CodeBox/index.module.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
}
7474
}
7575

76-
.icon {
77-
@apply size-4;
76+
.toast {
77+
@apply flex
78+
items-center
79+
gap-3;
80+
81+
.icon {
82+
@apply size-4;
83+
}
7884
}

packages/ui-components/src/Common/CodeBox/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ const CodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
9494
const text = containerRef.current?.textContent;
9595
if (text) {
9696
notify({
97-
duration: 300,
97+
duration: 30000,
9898
message: (
99-
<div className="flex items-center gap-3">
99+
<div className={styles.toast}>
100100
<CodeBracketIcon className={styles.icon} />
101101
{notificationText}
102102
</div>

packages/ui-components/src/Providers/__tests__/NotificationProvider.test.jsx renamed to packages/ui-components/src/Providers/NotificationProvider/__tests__/index.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
33
import { describe, it } from 'node:test';
44
import assert from 'node:assert/strict';
55

6-
import { NotificationProvider, useNotification } from '../NotificationProvider';
6+
import { NotificationProvider, useNotification } from '..';
77

88
describe('useNotification', () => {
99
it('should return the notification dispatch function', () => {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@reference "../../styles/index.css";
2+
3+
.viewport {
4+
@apply fixed
5+
bottom-0
6+
right-0
7+
list-none;
8+
}

packages/ui-components/src/Providers/NotificationProvider.tsx renamed to packages/ui-components/src/Providers/NotificationProvider/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import type {
1010

1111
import Notification from '#ui/Common/Notification';
1212

13+
import styles from './index.module.css';
14+
1315
type NotificationContextType = {
1416
message: string | ReactNode;
1517
duration: number;
@@ -38,13 +40,13 @@ export const NotificationProvider: FC<PropsWithChildren> = ({ children }) => {
3840
<Toast.Provider>
3941
{children}
4042

41-
<Toast.Viewport className={'fixed bottom-0 right-0 list-none'} />
42-
4343
{notification && (
4444
<Notification duration={notification.duration}>
4545
{notification.message}
4646
</Notification>
4747
)}
48+
49+
<Toast.Viewport className={styles.viewport} />
4850
</Toast.Provider>
4951
</NotificationDispatch.Provider>
5052
</NotificationContext.Provider>

0 commit comments

Comments
 (0)