refactor(style): destructuring style change to array (#5451)

pull/5457/head
bqy_fe 2022-04-08 10:04:31 +08:00 committed by GitHub
parent a41a9b086b
commit 34ebd55082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 33 deletions

View File

@ -168,7 +168,7 @@ const Alert = defineComponent({
<div <div
role="alert" role="alert"
{...attrs} {...attrs}
style={{ ...(attrs.style as Object), ...motionStyle.value }} style={[attrs.style, motionStyle.value]}
v-show={!closing.value} v-show={!closing.value}
class={[attrs.class, alertCls]} class={[attrs.class, alertCls]}
data-show={!closing.value} data-show={!closing.value}

View File

@ -203,11 +203,7 @@ const Avatar = defineComponent({
{...attrs} {...attrs}
ref={avatarNodeRef} ref={avatarNodeRef}
class={classString} class={classString}
style={{ style={[sizeStyle, responsiveSizeStyle(!!icon), attrs.style]}
...sizeStyle,
...responsiveSizeStyle(!!icon),
...(attrs.style as CSSProperties),
}}
> >
{childrenToRender} {childrenToRender}
</span> </span>

View File

@ -1,4 +1,4 @@
import type { CSSProperties, VNode } from 'vue'; import type { VNode } from 'vue';
import { import {
onMounted, onMounted,
getCurrentInstance, getCurrentInstance,
@ -110,13 +110,13 @@ const ResizableTextArea = defineComponent({
const cls = classNames(prefixCls, attrs.class, { const cls = classNames(prefixCls, attrs.class, {
[`${prefixCls}-disabled`]: disabled, [`${prefixCls}-disabled`]: disabled,
}); });
const style = { const style = [
...(attrs.style as CSSProperties), attrs.style,
...textareaStyles.value, textareaStyles.value,
...(resizeStatus.value === RESIZE_STATUS_RESIZING resizeStatus.value === RESIZE_STATUS_RESIZING
? { overflowX: 'hidden', overflowY: 'hidden' } ? { overflowX: 'hidden', overflowY: 'hidden' }
: null), : null,
}; ];
const textareaProps: any = { const textareaProps: any = {
...otherProps, ...otherProps,
...attrs, ...attrs,

View File

@ -193,13 +193,15 @@ export default defineComponent({
</div> </div>
) )
: null; : null;
const divStyle = { const divStyle = [
...(attrs.style as CSSProperties), attrs.style,
flex: `0 0 ${siderWidth}`, {
maxWidth: siderWidth, // Fix width transition bug in IE11 flex: `0 0 ${siderWidth}`,
minWidth: siderWidth, // https://github.com/ant-design/ant-design/issues/6349 maxWidth: siderWidth, // Fix width transition bug in IE11
width: siderWidth, minWidth: siderWidth, // https://github.com/ant-design/ant-design/issues/6349
}; width: siderWidth,
},
];
const siderCls = classNames( const siderCls = classNames(
pre, pre,
`${pre}-${theme}`, `${pre}-${theme}`,

View File

@ -63,7 +63,7 @@ export default defineComponent({
tabindex={active ? 0 : -1} tabindex={active ? 0 : -1}
aria-labelledby={id && `${id}-tab-${tabKey}`} aria-labelledby={id && `${id}-tab-${tabKey}`}
aria-hidden={!active} aria-hidden={!active}
style={{ ...mergedStyle.value, ...(attrs.style as any) }} style={[mergedStyle.value, attrs.style]}
class={[`${prefixCls}-tabpane`, active && `${prefixCls}-tabpane-active`, attrs.class]} class={[`${prefixCls}-tabpane`, active && `${prefixCls}-tabpane-active`, attrs.class]}
> >
{(active || visited.value || forceRender) && slots.default?.()} {(active || visited.value || forceRender) && slots.default?.()}

View File

@ -1,4 +1,4 @@
import type { CSSProperties, PropType } from 'vue'; import type { PropType } from 'vue';
import { computed, defineComponent, ref, onMounted, onBeforeUnmount } from 'vue'; import { computed, defineComponent, ref, onMounted, onBeforeUnmount } from 'vue';
import classNames from '../../_util/classNames'; import classNames from '../../_util/classNames';
import PropTypes from '../../_util/vue-types'; import PropTypes from '../../_util/vue-types';
@ -108,10 +108,7 @@ export default defineComponent({
'aria-valuenow': value, 'aria-valuenow': value,
'aria-disabled': !!disabled, 'aria-disabled': !!disabled,
}; };
const elStyle = { const elStyle = [attrs.style, positionStyle.value];
...(attrs.style as CSSProperties),
...positionStyle.value,
};
let mergedTabIndex = tabindex || 0; let mergedTabIndex = tabindex || 0;
if (disabled || tabindex === null) { if (disabled || tabindex === null) {
mergedTabIndex = null; mergedTabIndex = null;

View File

@ -144,13 +144,16 @@ export default defineComponent({
} = props as PopupInnerProps; } = props as PopupInnerProps;
const statusValue = status.value; const statusValue = status.value;
// ======================== Render ======================== // ======================== Render ========================
const mergedStyle: CSSProperties = { const mergedStyle: CSSProperties[] = [
...stretchStyle.value, {
zIndex, ...stretchStyle.value,
opacity: statusValue === 'motion' || statusValue === 'stable' || !visible.value ? null : 0, zIndex,
pointerEvents: statusValue === 'stable' ? null : 'none', opacity:
...(attrs.style as object), statusValue === 'motion' || statusValue === 'stable' || !visible.value ? null : 0,
}; pointerEvents: statusValue === 'stable' ? null : 'none',
},
attrs.style,
];
let childNode: any = flattenChildren(slots.default?.({ visible: props.visible })); let childNode: any = flattenChildren(slots.default?.({ visible: props.visible }));