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

Commit 5e53f7a

Browse files
tripleWdotcomTigge
authored andcommitted
feat(toast): adds the option to remove the close button
1 parent 9d7ed47 commit 5e53f7a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/core/src/Toast/context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface SimpleToast {
77
readonly message?: string
88
readonly onClose?: (id: ToastId) => void
99
readonly duration?: number
10+
readonly hasCloseButton?: boolean
1011
}
1112

1213
export interface ActionToast extends SimpleToast {

packages/core/src/Toast/toastCreators.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,28 +338,38 @@ export const createLoadingToast: SimpleToastCreator = ({
338338
* Progress toast
339339
*/
340340

341-
const ProgressWrapper = styled.div`
341+
const ProgressWrapper = styled.div<{
342+
readonly hasClose: boolean
343+
}>`
342344
display: flex;
343345
align-items: center;
344-
padding-left: ${spacing.large};
346+
${({ hasClose }) =>
347+
!hasClose
348+
? css`
349+
padding: 0 ${spacing.medium} 0 ${spacing.large};
350+
`
351+
: css`
352+
padding-left: ${spacing.large};
353+
`}
345354
`
346355

347356
export const createProgressToast: ProgressToastCreator = ({
348357
label,
349358
message,
350359
progress,
360+
hasCloseButton = true,
351361
...rest
352362
}) => {
353363
const labelComponent = (
354364
<>
355365
<ToastLabel
356-
hasCloseButton={true}
366+
hasCloseButton={hasCloseButton}
357367
isError={false}
358368
hasEmphasis={message !== undefined}
359369
>
360370
{label}
361371
</ToastLabel>
362-
<ProgressWrapper>
372+
<ProgressWrapper hasClose={hasCloseButton}>
363373
<Progress {...progress} />
364374
</ProgressWrapper>
365375
</>
@@ -377,6 +387,7 @@ export const createProgressToast: ProgressToastCreator = ({
377387
icon,
378388
label: labelComponent,
379389
message: messageComponent,
390+
hasCloseButton,
380391
...rest,
381392
}
382393
}

0 commit comments

Comments
 (0)