Skip to content

Commit 34ebd55

Browse files
authored
refactor(style): destructuring style change to array (#5451)
1 parent a41a9b0 commit 34ebd55

File tree

7 files changed

+31
-33
lines changed

7 files changed

+31
-33
lines changed

components/alert/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const Alert = defineComponent({
168168
<div
169169
role="alert"
170170
{...attrs}
171-
style={{ ...(attrs.style as Object), ...motionStyle.value }}
171+
style={[attrs.style, motionStyle.value]}
172172
v-show={!closing.value}
173173
class={[attrs.class, alertCls]}
174174
data-show={!closing.value}

components/avatar/Avatar.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,7 @@ const Avatar = defineComponent({
203203
{...attrs}
204204
ref={avatarNodeRef}
205205
class={classString}
206-
style={{
207-
...sizeStyle,
208-
...responsiveSizeStyle(!!icon),
209-
...(attrs.style as CSSProperties),
210-
}}
206+
style={[sizeStyle, responsiveSizeStyle(!!icon), attrs.style]}
211207
>
212208
{childrenToRender}
213209
</span>

components/input/ResizableTextArea.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CSSProperties, VNode } from 'vue';
1+
import type { VNode } from 'vue';
22
import {
33
onMounted,
44
getCurrentInstance,
@@ -110,13 +110,13 @@ const ResizableTextArea = defineComponent({
110110
const cls = classNames(prefixCls, attrs.class, {
111111
[`${prefixCls}-disabled`]: disabled,
112112
});
113-
const style = {
114-
...(attrs.style as CSSProperties),
115-
...textareaStyles.value,
116-
...(resizeStatus.value === RESIZE_STATUS_RESIZING
113+
const style = [
114+
attrs.style,
115+
textareaStyles.value,
116+
resizeStatus.value === RESIZE_STATUS_RESIZING
117117
? { overflowX: 'hidden', overflowY: 'hidden' }
118-
: null),
119-
};
118+
: null,
119+
];
120120
const textareaProps: any = {
121121
...otherProps,
122122
...attrs,

components/layout/Sider.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,15 @@ export default defineComponent({
193193
</div>
194194
)
195195
: null;
196-
const divStyle = {
197-
...(attrs.style as CSSProperties),
198-
flex: `0 0 ${siderWidth}`,
199-
maxWidth: siderWidth, // Fix width transition bug in IE11
200-
minWidth: siderWidth, // https://github.com/ant-design/ant-design/issues/6349
201-
width: siderWidth,
202-
};
196+
const divStyle = [
197+
attrs.style,
198+
{
199+
flex: `0 0 ${siderWidth}`,
200+
maxWidth: siderWidth, // Fix width transition bug in IE11
201+
minWidth: siderWidth, // https://github.com/ant-design/ant-design/issues/6349
202+
width: siderWidth,
203+
},
204+
];
203205
const siderCls = classNames(
204206
pre,
205207
`${pre}-${theme}`,

components/tabs/src/TabPanelList/TabPane.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineComponent({
6363
tabindex={active ? 0 : -1}
6464
aria-labelledby={id && `${id}-tab-${tabKey}`}
6565
aria-hidden={!active}
66-
style={{ ...mergedStyle.value, ...(attrs.style as any) }}
66+
style={[mergedStyle.value, attrs.style]}
6767
class={[`${prefixCls}-tabpane`, active && `${prefixCls}-tabpane-active`, attrs.class]}
6868
>
6969
{(active || visited.value || forceRender) && slots.default?.()}

components/vc-slider/src/Handle.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CSSProperties, PropType } from 'vue';
1+
import type { PropType } from 'vue';
22
import { computed, defineComponent, ref, onMounted, onBeforeUnmount } from 'vue';
33
import classNames from '../../_util/classNames';
44
import PropTypes from '../../_util/vue-types';
@@ -108,10 +108,7 @@ export default defineComponent({
108108
'aria-valuenow': value,
109109
'aria-disabled': !!disabled,
110110
};
111-
const elStyle = {
112-
...(attrs.style as CSSProperties),
113-
...positionStyle.value,
114-
};
111+
const elStyle = [attrs.style, positionStyle.value];
115112
let mergedTabIndex = tabindex || 0;
116113
if (disabled || tabindex === null) {
117114
mergedTabIndex = null;

components/vc-trigger/Popup/PopupInner.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ export default defineComponent({
144144
} = props as PopupInnerProps;
145145
const statusValue = status.value;
146146
// ======================== Render ========================
147-
const mergedStyle: CSSProperties = {
148-
...stretchStyle.value,
149-
zIndex,
150-
opacity: statusValue === 'motion' || statusValue === 'stable' || !visible.value ? null : 0,
151-
pointerEvents: statusValue === 'stable' ? null : 'none',
152-
...(attrs.style as object),
153-
};
147+
const mergedStyle: CSSProperties[] = [
148+
{
149+
...stretchStyle.value,
150+
zIndex,
151+
opacity:
152+
statusValue === 'motion' || statusValue === 'stable' || !visible.value ? null : 0,
153+
pointerEvents: statusValue === 'stable' ? null : 'none',
154+
},
155+
attrs.style,
156+
];
154157

155158
let childNode: any = flattenChildren(slots.default?.({ visible: props.visible }));
156159

0 commit comments

Comments
 (0)