Skip to content

Commit

Permalink
feat(menu): propTypes && defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
ming680 committed Jul 8, 2024
1 parent 7bf4b92 commit 29036b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
18 changes: 12 additions & 6 deletions src/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getChildrenArray, hasSlot } from '../_util/component';
import { convertToLightDomNode } from '../_util/lightDom';
import { StyledProps } from '../common';
import { DEFAULT_MENU_WIDTH } from './_util/constant';
import { menuDefaultProps } from './defaultProps';
import { MenuValue, TdMenuProps } from './type';

export interface MenuProps extends TdMenuProps, StyledProps, OmiDOMAttributes {}
Expand All @@ -14,7 +13,17 @@ export interface MenuProps extends TdMenuProps, StyledProps, OmiDOMAttributes {}
export default class Menu extends Component<MenuProps> {
static css = [];

static defaultProps = {};
static defaultProps: TdMenuProps = {
collapsed: false,
width: '232px',
};

static propTypes = {
collapsed: Boolean,
value: [String, Number],
width: [String, Number, Array],
onChange: Function,
};

active = signal<MenuValue>('');

Expand All @@ -29,10 +38,7 @@ export default class Menu extends Component<MenuProps> {
}

render() {
const { className, style, width, collapsed, value } = {
...menuDefaultProps,
...this.props,
};
const { className, style, width, collapsed, value } = this.props;

this.active.value = value;

Expand Down
10 changes: 10 additions & 0 deletions src/menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ export default class MenuItem extends Component<MenuItemProps> {
}
`;

static propTypes = {
label: Object,
disabled: Boolean,
href: String,
icon: Object,
target: String,
value: [String, Number],
onClick: Function,
};

inject = ['active', 'onChange'];

constructor() {
Expand Down
8 changes: 0 additions & 8 deletions src/menu/defaultProps.ts

This file was deleted.

0 comments on commit 29036b4

Please sign in to comment.