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.
123 lines
4.0 KiB
123 lines
4.0 KiB
5 years ago
|
---
|
||
|
order: 2
|
||
|
title:
|
||
5 years ago
|
zh-CN: 骨架按钮、头像和输入框。
|
||
5 years ago
|
en-US: Skeleton button and avatar
|
||
5 years ago
|
---
|
||
|
|
||
|
## zh-CN
|
||
|
|
||
5 years ago
|
骨架按钮、头像和输入框。
|
||
5 years ago
|
|
||
|
## en-US
|
||
|
|
||
5 years ago
|
Skeleton button, avatar and input.
|
||
5 years ago
|
|
||
|
```jsx
|
||
|
import { Skeleton, Switch, Form, Radio } from 'antd';
|
||
|
|
||
|
class Demo extends React.Component {
|
||
|
state = {
|
||
5 years ago
|
buttonActive: false,
|
||
|
avatarActive: false,
|
||
5 years ago
|
inputActive: false,
|
||
5 years ago
|
buttonSize: 'default',
|
||
|
avatarSize: 'default',
|
||
5 years ago
|
inputSize: 'default',
|
||
5 years ago
|
buttonShape: 'default',
|
||
|
avatarShape: 'circle',
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
handleActiveChange = prop => checked => {
|
||
|
this.setState({ [prop]: checked });
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
handleSizeChange = prop => e => {
|
||
|
this.setState({ [prop]: e.target.value });
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
handleShapeChange = prop => e => {
|
||
|
this.setState({ [prop]: e.target.value });
|
||
5 years ago
|
};
|
||
|
|
||
|
render() {
|
||
5 years ago
|
const {
|
||
|
buttonActive,
|
||
|
avatarActive,
|
||
5 years ago
|
inputActive,
|
||
5 years ago
|
buttonSize,
|
||
|
avatarSize,
|
||
5 years ago
|
inputSize,
|
||
5 years ago
|
buttonShape,
|
||
|
avatarShape,
|
||
|
} = this.state;
|
||
5 years ago
|
return (
|
||
|
<div>
|
||
5 years ago
|
<div>
|
||
|
<Form layout="inline" style={{ marginBottom: 16 }}>
|
||
|
<Form.Item label="ButtonActive">
|
||
|
<Switch checked={buttonActive} onChange={this.handleActiveChange('buttonActive')} />
|
||
|
</Form.Item>
|
||
|
<Form.Item label="ButtonSize">
|
||
|
<Radio.Group value={buttonSize} onChange={this.handleSizeChange('buttonSize')}>
|
||
|
<Radio.Button value="default">Default</Radio.Button>
|
||
|
<Radio.Button value="large">Large</Radio.Button>
|
||
|
<Radio.Button value="small">Small</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
</Form.Item>
|
||
|
<Form.Item label="ButtonShape">
|
||
|
<Radio.Group value={buttonShape} onChange={this.handleShapeChange('buttonShape')}>
|
||
|
<Radio.Button value="default">Default</Radio.Button>
|
||
|
<Radio.Button value="round">Round</Radio.Button>
|
||
|
<Radio.Button value="circle">Circle</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
<Skeleton.Button active={buttonActive} size={buttonSize} shape={buttonShape} />
|
||
|
</div>
|
||
|
<br />
|
||
|
<div>
|
||
|
<Form layout="inline" style={{ marginBottom: 16 }}>
|
||
|
<Form.Item label="AvatarActive">
|
||
|
<Switch checked={avatarActive} onChange={this.handleActiveChange('avatarActive')} />
|
||
|
</Form.Item>
|
||
|
<Form.Item label="AvatarSize">
|
||
|
<Radio.Group value={avatarSize} onChange={this.handleSizeChange('avatarSize')}>
|
||
|
<Radio.Button value="default">Default</Radio.Button>
|
||
|
<Radio.Button value="large">Large</Radio.Button>
|
||
|
<Radio.Button value="small">Small</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
</Form.Item>
|
||
|
<Form.Item label="AvatarShape">
|
||
|
<Radio.Group value={avatarShape} onChange={this.handleShapeChange('avatarShape')}>
|
||
|
<Radio.Button value="square">Square</Radio.Button>
|
||
|
<Radio.Button value="circle">Circle</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
|
<Skeleton.Avatar active={avatarActive} size={avatarSize} shape={avatarShape} />
|
||
|
</div>
|
||
5 years ago
|
<br />
|
||
|
<div>
|
||
|
<Form layout="inline" style={{ marginBottom: 16 }}>
|
||
|
<Form.Item label="InputActive">
|
||
|
<Switch checked={inputActive} onChange={this.handleActiveChange('inputActive')} />
|
||
|
</Form.Item>
|
||
|
<Form.Item label="InputSize">
|
||
|
<Radio.Group value={inputSize} onChange={this.handleSizeChange('inputSize')}>
|
||
|
<Radio.Button value="default">Default</Radio.Button>
|
||
|
<Radio.Button value="large">Large</Radio.Button>
|
||
|
<Radio.Button value="small">Small</Radio.Button>
|
||
|
</Radio.Group>
|
||
|
</Form.Item>
|
||
|
</Form>
|
||
5 years ago
|
<Skeleton.Input style={{ width: '300px' }} active={inputActive} size={inputSize} />
|
||
5 years ago
|
</div>
|
||
5 years ago
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ReactDOM.render(<Demo />, mountNode);
|
||
|
```
|