Skip to content

Commit 006e23a

Browse files
authored
fix: update alert style (#3714)
1 parent f1cf66f commit 006e23a

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

components/alert/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ const Alert = defineComponent({
165165
ref={alertNode}
166166
>
167167
{showIcon ? iconNode : null}
168-
<span class={`${prefixCls}-message`}>{message}</span>
169-
<span class={`${prefixCls}-description`}>{description}</span>
168+
<div class={`${prefixCls}-content`}>
169+
<div class={`${prefixCls}-message`}>{message}</div>
170+
<div class={`${prefixCls}-description`}>{description}</div>
171+
</div>
170172
{closeIcon}
171173
</div>
172174
</Transition>

components/alert/style/index.less

+20-33
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,34 @@
88
@alert-close-color: @text-color-secondary;
99
@alert-close-hover-color: @icon-color-hover;
1010

11+
@alert-with-description-icon-size: 24px;
12+
@alert-with-description-no-icon-padding-vertical: @padding-md - 1px;
13+
@alert-with-description-padding-vertical: @padding-md - 1px;
14+
@alert-with-description-padding: @alert-with-description-padding-vertical 15px;
15+
1116
.@{alert-prefix-cls} {
1217
.reset-component();
1318

1419
position: relative;
15-
padding: 8px 15px 8px 37px;
20+
display: flex;
21+
align-items: center;
22+
padding: 8px 15px;
1623
word-wrap: break-word;
1724
border-radius: @border-radius-base;
1825

19-
&&-no-icon {
20-
padding: 8px 15px;
21-
}
22-
23-
&&-closable {
24-
padding-right: 30px;
26+
&-content {
27+
flex: 1;
28+
min-width: 0;
2529
}
2630

2731
&-icon {
28-
position: absolute;
29-
top: 8px + (@font-size-base * @line-height-base / 2) - (@font-size-base / 2);
30-
left: 16px;
32+
margin-right: @margin-xs;
3133
}
3234

3335
&-description {
3436
display: none;
3537
font-size: @font-size-base;
36-
line-height: 22px;
38+
line-height: @font-size-base + 8px;
3739
}
3840

3941
&-success {
@@ -69,13 +71,11 @@
6971
}
7072

7173
&-close-icon {
72-
position: absolute;
73-
top: 8px;
74-
right: 16px;
74+
margin-left: @margin-xs;
7575
padding: 0;
7676
overflow: hidden;
7777
font-size: @font-size-sm;
78-
line-height: 22px;
78+
line-height: @font-size-sm;
7979
background-color: transparent;
8080
border: none;
8181
outline: none;
@@ -99,30 +99,17 @@
9999
}
100100

101101
&-with-description {
102-
position: relative;
103-
padding: 15px 15px 15px 64px;
104-
color: @alert-text-color;
105-
line-height: @line-height-base;
106-
border-radius: @border-radius-base;
102+
align-items: flex-start;
103+
padding: @alert-with-description-padding;
107104
}
108105

109106
&-with-description&-no-icon {
110-
padding: 15px;
107+
padding: @alert-with-description-no-icon-padding-vertical 15px;
111108
}
112109

113110
&-with-description &-icon {
114-
position: absolute;
115-
top: 16px;
116-
left: 24px;
117-
font-size: 24px;
118-
}
119-
120-
&-with-description &-close-icon {
121-
position: absolute;
122-
top: 16px;
123-
right: 16px;
124-
font-size: @font-size-base;
125-
cursor: pointer;
111+
margin-right: @alert-with-description-padding-vertical;
112+
font-size: @alert-with-description-icon-size;
126113
}
127114

128115
&-with-description &-message {

0 commit comments

Comments
 (0)