Commit 1ae0845 1 parent ab88ee9 commit 1ae0845 Copy full SHA for 1ae0845
File tree 6 files changed +27
-15
lines changed
packages/orbit-components/src/Alert
6 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export function TestAlert() {
47
47
type = { type }
48
48
icon = { false }
49
49
closable
50
+ labelClose = "Close"
50
51
inlineActions = {
51
52
< AlertButton type = { type } href = "#" >
52
53
Link
@@ -65,6 +66,7 @@ export function TestAlert() {
65
66
type = { type }
66
67
icon = { < Icons . Ai /> }
67
68
closable
69
+ labelClose = "Close"
68
70
inlineActions = {
69
71
< AlertButton type = { type } href = "#" >
70
72
Link
@@ -90,7 +92,7 @@ export function TestAlert() {
90
92
< h2 > With multiline text, closable, without icon</ h2 >
91
93
< div className = "gap-400 flex flex-col items-stretch" >
92
94
{ Object . values ( TYPE_OPTIONS ) . map ( type => (
93
- < Alert type = { type } closable icon = { false } >
95
+ < Alert type = { type } closable icon = { false } labelClose = "Close" >
94
96
< p >
95
97
< TextLink type = "primary" > This is</ TextLink > a primary textlink.
96
98
< br />
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ const meta: Meta<typeof Alert> = {
31
31
closable : false ,
32
32
spaceAfter : SPACINGS_AFTER . SMALL ,
33
33
suppressed : false ,
34
+ labelClose : "Close" ,
34
35
} ,
35
36
36
37
argTypes : {
@@ -295,7 +296,7 @@ export const Rtl: Story = {
295
296
Make sure you know your visa requirements for these countries:
296
297
</ Heading >
297
298
< List >
298
- < ListItem icon = { < CountryFlag code = "pl" name = "Poland" /> } > Poland</ ListItem >
299
+ < ListItem icon = { < CountryFlag code = "pl" /> } > Poland</ ListItem >
299
300
</ List >
300
301
</ Stack >
301
302
< AlertButton type = "info" > Check Visa Requirements</ AlertButton >
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ The table below contains all types of the props available in Alert component.
26
26
| inlineActions | ` React.Node ` | | Renders action to a right side of a Alert. [ See Functional specs] ( #functional-specs ) |
27
27
| onClose | ` () => void \| Promise ` | | Function for handling Alert onClose. |
28
28
| spaceAfter | ` enum ` | | Additional ` margin-bottom ` after component. |
29
- | title | ` Translation ` | | The title of the Alert. |
29
+ | title | ` string ` | | The title of the Alert. |
30
30
| ** type** | [ ` enum ` ] ( #enum ) | ` "info" ` | The type of Alert. |
31
31
| suppressed | ` boolean ` | | If ` suppressed ` is on, Alert will not have colored background |
32
32
| labelClose | ` string ` | | The label of the close button. |
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ describe("Alert", () => {
21
21
it ( "should be closable" , async ( ) => {
22
22
const onClose = jest . fn ( ) ;
23
23
render (
24
- < Alert onClose = { onClose } closable >
24
+ < Alert onClose = { onClose } closable labelClose = "Close" >
25
25
{ message }
26
26
</ Alert > ,
27
27
) ;
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ const Alert = (props: Props) => {
130
130
return (
131
131
< div
132
132
className = { cx (
133
+ "orbit-alert" ,
133
134
"rounded-150 text-ink-dark font-base text-normal p-300 relative box-border flex w-full border border-t-[3px] leading-normal" ,
134
135
"lm:border-s-[3px] lm:border-t" ,
135
136
"tb:rounded-100" ,
Original file line number Diff line number Diff line change @@ -6,14 +6,22 @@ import type * as React from "react";
6
6
import type * as Common from "../common/types" ;
7
7
8
8
export type Type = "info" | "success" | "warning" | "critical" ;
9
- export interface Props extends Common . Globals , Common . SpaceAfter {
10
- readonly type ?: Type ;
11
- readonly children ?: React . ReactNode ;
12
- readonly title ?: Common . Translation ;
13
- readonly icon ?: React . ReactNode ;
14
- readonly closable ?: boolean ;
15
- readonly inlineActions ?: React . ReactNode ;
16
- readonly labelClose ?: string ;
17
- readonly onClose ?: Common . Callback ;
18
- readonly suppressed ?: boolean ;
19
- }
9
+ export type Props = Common . Globals &
10
+ Common . SpaceAfter & {
11
+ readonly type ?: Type ;
12
+ readonly children ?: React . ReactNode ;
13
+ readonly title ?: Common . Translation ;
14
+ readonly icon ?: React . ReactNode ;
15
+ readonly inlineActions ?: React . ReactNode ;
16
+ readonly onClose ?: Common . Callback ;
17
+ readonly suppressed ?: boolean ;
18
+ /**
19
+ * When closable is true, labelClose is required.
20
+ */
21
+ } & (
22
+ | {
23
+ readonly closable : true ;
24
+ readonly labelClose : string ;
25
+ }
26
+ | { readonly closable ?: false ; readonly labelClose ?: string }
27
+ ) ;
You can’t perform that action at this time.
0 commit comments