Skip to content

Commit

Permalink
refactor(Timeline): use assignSubComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
eternalsky committed Jan 31, 2024
1 parent aebcacd commit ec63d2b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
12 changes: 11 additions & 1 deletion components/animate/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,17 @@ export interface AnimateProps extends React.HTMLAttributes<HTMLElement>, CommonP
/**
* @api Animate.Expand
*/
export interface ExpandProps {
export interface ExpandProps
extends Omit<
AnimateProps,
| 'animation'
| 'beforeEnter'
| 'onEnter'
| 'afterEnter'
| 'beforeLeave'
| 'onLeave'
| 'afterLeave'
> {
/**
* 动画 className
* @en The animation className
Expand Down
11 changes: 8 additions & 3 deletions components/timeline/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { assignSubComponent } from '../util/component';
import Timeline from './view/timeline';
import type { TimelineProps, ItemProps } from './types';
import TimelineItem from './view/timeline-item';

export type { TimelineProps, ItemProps };
const TimelineWithItem = assignSubComponent(Timeline, {
Item: TimelineItem,
});

export default Timeline;
export type { TimelineProps, ItemProps } from './types';

export default TimelineWithItem;
1 change: 0 additions & 1 deletion components/timeline/view/timeline-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Button, { type ButtonProps } from '../../button';
import { obj } from '../../util';
import type { ItemProps } from '../types';

//@ts-expect-error Animate 尚未完成 ts 改造
const { Expand } = Animate;
/** Timeline.Item */
class TimelineItem extends Component<ItemProps> {
Expand Down
2 changes: 0 additions & 2 deletions components/timeline/view/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import { polyfill } from 'react-lifecycles-compat';
import { obj } from '../../util';
import ConfigProvider from '../../config-provider';
import nextLocale from '../../locale/zh-cn';
import Item from './timeline-item';
import { TimelineProps, TimelineState } from '../types';

/** Timeline */
class Timeline extends Component<TimelineProps, TimelineState> {
static displayName = 'Timeline';
static Item = Item;
static propTypes = {
...ConfigProvider.propTypes,
prefix: PropTypes.string,
Expand Down

0 comments on commit ec63d2b

Please sign in to comment.