Skip to content

Commit fc7cef0

Browse files
committed
chore(ui): optimize transition animation
1 parent 662ac5e commit fc7cef0

11 files changed

Lines changed: 174 additions & 165 deletions

File tree

packages/ui/src/components/accordion/Accordion.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ export function DAccordion<ID extends DId, T extends DAccordionItem<ID>>(props:
130130
return (
131131
<div
132132
key={itemId}
133-
className={getClassName(`${dPrefix}accordion__container`, {
134-
[`${dPrefix}accordion__container--last`]: index === dList.length - 1,
133+
className={getClassName(`${dPrefix}accordion__item`, {
134+
[`${dPrefix}accordion__item--last`]: index === dList.length - 1,
135135
})}
136136
>
137137
<div
138138
id={buttonId}
139-
className={getClassName(`${dPrefix}accordion__button`, {
140-
[`${dPrefix}accordion__button--arrow-left`]: itemArrow === 'left',
139+
className={getClassName(`${dPrefix}accordion__item-button`, {
140+
[`${dPrefix}accordion__item-button--arrow-left`]: itemArrow === 'left',
141141
'is-disabled': itemDisabled,
142142
})}
143143
tabIndex={itemDisabled ? -1 : 0}
@@ -189,8 +189,8 @@ export function DAccordion<ID extends DId, T extends DAccordionItem<ID>>(props:
189189
}
190190
}}
191191
>
192-
<div className={`${dPrefix}accordion__title`}>{itemTitle}</div>
193-
{itemArrow && <DownOutlined className={`${dPrefix}accordion__arrow`} dRotate={iconRotate} />}
192+
<div className={`${dPrefix}accordion__item-title`}>{itemTitle}</div>
193+
{itemArrow && <DownOutlined className={`${dPrefix}accordion__item-arrow`} dRotate={iconRotate} />}
194194
</div>
195195
<DCollapseTransition
196196
dSize={0}
@@ -222,7 +222,7 @@ export function DAccordion<ID extends DId, T extends DAccordionItem<ID>>(props:
222222
<div
223223
ref={ref}
224224
id={regionId}
225-
className={`${dPrefix}accordion__region`}
225+
className={`${dPrefix}accordion__item-region`}
226226
style={collapseStyle}
227227
role="region"
228228
aria-labelledby={getButtonId(itemId)}

packages/ui/src/components/avatar/demos/3.LoadError.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import { DAvatar } from '@react-devui/ui';
1919
export default function Demo() {
2020
return (
2121
<>
22-
<DAvatar dImg={{ src: 'avatar.png', alt: 'avatar' }} dIcon={<UserOutlined />}></DAvatar>
23-
<DAvatar dImg={{ src: 'avatar.png', alt: 'avatar' }} dText="U"></DAvatar>
22+
<DAvatar dImg={{ src: '/error-path/avatar.png', alt: 'avatar' }} dIcon={<UserOutlined />}></DAvatar>
23+
<DAvatar dImg={{ src: '/error-path/avatar.png', alt: 'avatar' }} dText="U"></DAvatar>
2424
</>
2525
);
2626
}

packages/ui/src/components/card/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const DCard: {
5151
...action.props,
5252
className: getClassName(action.props.className, `${dPrefix}card__action`),
5353
})}
54-
{index !== dActions.length - 1 && <DSeparator dVertical></DSeparator>}
54+
{index !== dActions.length - 1 && <DSeparator style={{ margin: 8 }} dVertical></DSeparator>}
5555
</>
5656
))}
5757
</div>

packages/ui/src/components/dropdown/Dropdown.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { registerComponentMate, TTANSITION_DURING_POPUP } from '../../utils';
1111
import { DFocusVisible } from '../_focus-visible';
1212
import { DPopup, useNestedPopup } from '../_popup';
1313
import { DTransition } from '../_transition';
14+
import { DSeparator } from '../separator';
1415
import { DGroup } from './Group';
1516
import { DItem } from './Item';
1617
import { DSub } from './Sub';
@@ -26,6 +27,7 @@ export interface DDropdownItem<ID extends DId> {
2627
type: 'item' | 'group' | 'sub';
2728
icon?: React.ReactNode;
2829
disabled?: boolean;
30+
separator?: boolean;
2931
}
3032

3133
export interface DDropdownProps<ID extends DId, T extends DDropdownItem<ID> & { children?: T[] }>
@@ -188,7 +190,15 @@ function Dropdown<ID extends DId, T extends DDropdownItem<ID> & { children?: T[]
188190
const nodes = (() => {
189191
const getNodes = (arr: T[], level: number, subParents: T[]): JSX.Element[] =>
190192
arr.map((item) => {
191-
const { id: itemId, label: itemLabel, type: itemType, icon: itemIcon, disabled: itemDisabled, children } = item;
193+
const {
194+
id: itemId,
195+
label: itemLabel,
196+
type: itemType,
197+
icon: itemIcon,
198+
disabled: itemDisabled,
199+
separator: itemSeparator,
200+
children,
201+
} = item;
192202

193203
const newSubParents = itemType === 'sub' ? subParents.concat([item]) : subParents;
194204
const id = getItemId(itemId);
@@ -347,6 +357,7 @@ function Dropdown<ID extends DId, T extends DDropdownItem<ID> & { children?: T[]
347357
{itemLabel}
348358
</DSub>
349359
)}
360+
{itemSeparator && <DSeparator style={{ margin: '2px 0' }} />}
350361
</React.Fragment>
351362
);
352363
});

packages/ui/src/components/menu/Item.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ export function DItem(props: DItemProps): JSX.Element | null {
6767
>
6868
<div style={{ backgroundColor: dLevel === 0 ? 'transparent' : undefined }}></div>
6969
</div>
70-
{checkNodeExist(dIcon) && (
71-
<div className={`${dPrefix}menu__item-icon-wrapper`}>
72-
<div className={`${dPrefix}menu__item-icon`}>{dIcon}</div>
73-
</div>
74-
)}
70+
{checkNodeExist(dIcon) && <div className={`${dPrefix}menu__item-icon`}>{dIcon}</div>}
7571
<div className={`${dPrefix}menu__item-content`}>{children}</div>
7672
</li>
7773
);

0 commit comments

Comments
 (0)