Browse Source

docs: Rewrite Badge demos to ES6 component

pull/4942/head
Wei Zhu 8 years ago
parent
commit
1fc8990531
  1. 34
      components/badge/demo/change.md
  2. 18
      components/badge/demo/dot.md
  3. 12
      components/badge/demo/no-wrapper.md
  4. 30
      components/badge/demo/overflow.md

34
components/badge/demo/change.md

@ -17,27 +17,29 @@ The count will be animated as it changes.
import { Badge, Button, Icon, Switch } from 'antd'; import { Badge, Button, Icon, Switch } from 'antd';
const ButtonGroup = Button.Group; const ButtonGroup = Button.Group;
const Test = React.createClass({ class Demo extends React.Component {
getInitialState() { state = {
return { count: 5,
count: 5, show: true,
show: true, }
};
}, increase = () => {
increase() {
const count = this.state.count + 1; const count = this.state.count + 1;
this.setState({ count }); this.setState({ count });
}, }
decline() {
decline = () => {
let count = this.state.count - 1; let count = this.state.count - 1;
if (count < 0) { if (count < 0) {
count = 0; count = 0;
} }
this.setState({ count }); this.setState({ count });
}, }
onChange(show) {
onChange = (show) => {
this.setState({ show }); this.setState({ show });
}, }
render() { render() {
return ( return (
<div> <div>
@ -62,8 +64,8 @@ const Test = React.createClass({
</div> </div>
</div> </div>
); );
}, }
}); }
ReactDOM.render(<Test />, mountNode); ReactDOM.render(<Demo />, mountNode);
```` ````

18
components/badge/demo/dot.md

@ -16,14 +16,16 @@ This will simply display a red badge, without a specific count.
````jsx ````jsx
import { Badge, Icon } from 'antd'; import { Badge, Icon } from 'antd';
ReactDOM.render(<div> ReactDOM.render(
<Badge dot> <div>
<Icon type="notification" /> <Badge dot>
</Badge> <Icon type="notification" />
<Badge dot> </Badge>
<a href="#">Link something</a> <Badge dot>
</Badge> <a href="#">Link something</a>
</div>, mountNode); </Badge>
</div>
, mountNode);
```` ````
<style> <style>

12
components/badge/demo/no-wrapper.md

@ -18,9 +18,11 @@ Used in standalone when children is empty.
````jsx ````jsx
import { Badge } from 'antd'; import { Badge } from 'antd';
ReactDOM.render(<div> ReactDOM.render(
<Badge count={25} /> <div>
<Badge count={4} style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }} /> <Badge count={25} />
<Badge count={109} style={{ backgroundColor: '#87d068' }} /> <Badge count={4} style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }} />
</div>, mountNode); <Badge count={109} style={{ backgroundColor: '#87d068' }} />
</div>
, mountNode);
```` ````

30
components/badge/demo/overflow.md

@ -16,18 +16,20 @@ title:
````jsx ````jsx
import { Badge } from 'antd'; import { Badge } from 'antd';
ReactDOM.render(<div> ReactDOM.render(
<Badge count={99}> <div>
<a href="#" className="head-example" /> <Badge count={99}>
</Badge> <a href="#" className="head-example" />
<Badge count={100}> </Badge>
<a href="#" className="head-example" /> <Badge count={100}>
</Badge> <a href="#" className="head-example" />
<Badge count={99} overflowCount={10}> </Badge>
<a href="#" className="head-example" /> <Badge count={99} overflowCount={10}>
</Badge> <a href="#" className="head-example" />
<Badge count={1000} overflowCount={999}> </Badge>
<a href="#" className="head-example" /> <Badge count={1000} overflowCount={999}>
</Badge> <a href="#" className="head-example" />
</div>, mountNode); </Badge>
</div>
, mountNode);
```` ````

Loading…
Cancel
Save