Skip to content

Commit 4cb3806

Browse files
authored
Merge pull request #480 from mashmatrix/support-slds-2-notification
Update `Notification` for SLDS2
2 parents 72353ea + 4af32c7 commit 4cb3806

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

src/scripts/Notification.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export type NotificationProps = {
1616
alt?: string;
1717
icon?: string;
1818
iconSize?: IconSize;
19-
alertTexture?: boolean;
2019
onClose?: EventHandler<MouseEvent<HTMLButtonElement>>;
2120
} & HTMLAttributes<HTMLDivElement>;
2221

@@ -26,7 +25,6 @@ export const Notification: FC<NotificationProps> = (props) => {
2625
type,
2726
level,
2827
alt,
29-
alertTexture = true,
3028
icon,
3129
iconSize = 'small',
3230
onClose,
@@ -46,16 +44,20 @@ export const Notification: FC<NotificationProps> = (props) => {
4644
'slds-notify',
4745
typeClassName,
4846
levelClassName,
49-
alertTexture ? 'slds-theme_alert-texture' : null
47+
{
48+
[`slds-alert_${level}`]: type === 'alert' && level && level !== 'info',
49+
}
5050
);
5151

5252
const iconEl = icon ? (
5353
<Icon
54-
className={
55-
type === 'toast' ? 'slds-m-right_small' : 'slds-m-right_x-small'
56-
}
54+
container={true}
55+
containerClassName={classnames(
56+
type === 'toast' ? 'slds-m-right_small' : 'slds-m-right_x-small',
57+
type === 'alert' ? ['slds-no-flex', 'slds-align-top'] : null
58+
)}
5759
icon={icon}
58-
size={iconSize}
60+
size={iconSize ?? (type === 'toast' ? 'small' : 'x-small')}
5961
fillColor='none'
6062
textColor={level === 'warning' ? 'default' : null}
6163
/>
@@ -65,27 +67,23 @@ export const Notification: FC<NotificationProps> = (props) => {
6567
<div className={alertClassNames} role='alert' {...pprops}>
6668
{alt ? <span className='slds-assistive-text'>{alt}</span> : undefined}
6769
{onClose ? (
68-
<Button
69-
className='slds-notify__close'
70-
type='icon-inverse'
71-
icon='close'
72-
iconSize={type === 'toast' ? 'large' : 'small'}
73-
alt='Close'
74-
onClick={onClose}
75-
/>
70+
<div className='slds-notify__close'>
71+
<Button
72+
type='icon-inverse'
73+
icon='close'
74+
size={type === 'toast' ? undefined : 'small'}
75+
alt='Close'
76+
onClick={onClose}
77+
/>
78+
</div>
7679
) : undefined}
80+
{iconEl}
7781
{type === 'toast' ? (
78-
<div className='slds-notify__content slds-grid'>
79-
{iconEl}
80-
<div className='slds-col slds-align-middle'>
81-
<h2 className='slds-text-heading_small'>{children}</h2>
82-
</div>
82+
<div className='slds-notify__content'>
83+
<h2 className='slds-text-heading_small'>{children}</h2>
8384
</div>
8485
) : (
85-
<h2>
86-
{iconEl}
87-
{children}
88-
</h2>
86+
<h2>{children}</h2>
8987
)}
9088
</div>
9189
);

stories/Notification.stories.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const ControlledWithKnobs: ComponentStoryObj<typeof Notification> = {
1919
name: 'Controlled with knobs',
2020
args: {
2121
type: 'alert',
22-
alertTexture: true,
2322
children: 'This is notification text.',
2423
},
2524
argTypes: {
@@ -241,7 +240,6 @@ export const ToastWarning: ComponentStoryObj<typeof Toast> = {
241240
args: {
242241
icon: 'warning',
243242
level: 'warning',
244-
alertTexture: false,
245243
children: (
246244
<>
247245
This is <strong>warning</strong> toast with icon and close button.
@@ -269,7 +267,6 @@ export const ToastError: ComponentStoryObj<typeof Toast> = {
269267
args: {
270268
icon: 'warning',
271269
level: 'error',
272-
alertTexture: false,
273270
children: (
274271
<>
275272
This is <strong>error</strong> toast with icon and close button.

0 commit comments

Comments
 (0)