You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
966 B

9 years ago
import * as React from 'react';
import { PropTypes } from 'react';
import RcSwitch from 'rc-switch';
import classNames from 'classnames';
10 years ago
export interface SwitchProps {
prefixCls?: string;
size?: 'small' | 'default';
className?: string;
checked?: boolean;
defaultChecked?: boolean;
onChange?: (checked: boolean) => any;
checkedChildren?: React.ReactNode;
unCheckedChildren?: React.ReactNode;
}
export default class Switch extends React.Component<SwitchProps, any> {
static defaultProps = {
prefixCls: 'ant-switch',
size: 'default',
};
static propTypes = {
prefixCls: PropTypes.string,
size: PropTypes.oneOf(['small', 'default']),
className: PropTypes.string,
};
10 years ago
render() {
const { prefixCls, size, className } = this.props;
const classes = classNames({
[className]: !!className,
[`${prefixCls}-small`]: size === 'small',
});
return <RcSwitch {...this.props} className={classes} />;
10 years ago
}
}