UNPKG

6.76 kBJavaScriptView Raw
1import { Con, Row, Col } from 'bee-layout';
2import { Panel } from 'bee-panel';
3import Button from 'bee-button';
4import React, { Component } from 'react';
5import ReactDOM from 'react-dom';
6
7
8const CARET = <i className="uf uf-arrow-down"></i>;
9
10const CARETUP = <i className="uf uf-arrow-up"></i>;
11
12
13var Demo1 = require("./demolist/Demo1");var Demo2 = require("./demolist/Demo2");var DemoArray = [{"example":<Demo1 />,"title":" 不同颜色的消息提醒","code":"/**\n *\n * @title 不同颜色的消息提醒\n * @description 提供10种颜色,包括黑色白色及四个语义色及四个浅语义色\n *\n */\n\nimport React, { Component } from 'react';\nimport { Message, Button, Panel , Con, Row, Col } from 'tinper-bee';\n\n const info = function () {\n let aa = Message.create({content: 'This is a Info message', color: 'info', duration: null});\n\n };\n const danger = function () {\n Message.create({content: 'This is a danger message', color: 'danger'});\n };\n const success = function () {\n Message.create({content: 'This is a success message', color: 'success'});\n };\n const warning = function () {\n Message.create({content: 'This is a warning message', color: 'warning'});\n };\n const loading = function () {\n Message.create({content: 'This is a dark message', color: 'dark'});\n };\n const light = function () {\n Message.create({content: 'This is a light message', color: 'light'});\n };\nclass Demo1 extends Component {\n constructor(props){\n super(props);\n }\n render () {\n return (\n <div className=\"paddingDemo\">\n <Button\n colors=\"info\"\n onClick={info}>\n info\n </Button>\n <Button\n colors=\"danger\"\n onClick={danger}>\n danger\n </Button>\n <Button\n colors=\"warning\"\n onClick={warning}>\n warning\n </Button>\n <Button\n colors=\"success\"\n onClick={success}>\n success\n </Button>\n <Button\n colors=\"primary\"\n onClick={loading}>\n dark\n </Button>\n <Button\n shape=\"border\"\n onClick={light}>\n light\n </Button>\n </div>\n )\n }\n}\n\n\n\n","desc":" 提供10种颜色,包括黑色白色及四个语义色及四个浅语义色","scss_code":".paddingDemo{\n button{\n margin: 10px;\n }\n}"},{"example":<Demo2 />,"title":" 不同显示位置的消息提醒","code":"/**\n *\n * @title 不同显示位置的消息提醒\n * @description 一个页面的message只能设置一中显示位置,提供六种位置选择,查看每种示例,需每次刷新\n *\n */\n\nimport React, { Component } from 'react';\nimport { Message, Button, Panel , Con, Row, Col } from 'tinper-bee';\n\n const top = function () {\n Message.create({content: 'This is a Info message', position: 'top'});\n };\n const bottom = function () {\n Message.create({content: 'This is a Info message', position: 'bottom'});\n };\n const topRight = function () {\n Message.create({content: 'This is a Info message', position: 'topRight'});\n };\n const topLeft = function () {\n Message.create({content: 'This is a Info message', position: 'topLeft'});\n };\n const bottomRight = function () {\n Message.create({content: 'This is a Info message', position: 'bottomRight'});\n };\n const bottomLeft = function () {\n Message.create({content: 'This is a Info message', position: 'bottomLeft'});\n };\nclass Demo2 extends Component {\n constructor(props){\n super(props);\n }\n render () {\n return (\n <div className=\"paddingDemo\">\n <Button\n colors=\"info\"\n onClick={top}>\n top\n </Button>\n <Button\n colors=\"info\"\n onClick={bottom}>\n bottom\n </Button>\n <Button\n colors=\"info\"\n onClick={topRight}>\n topRight\n </Button>\n <Button\n colors=\"info\"\n onClick={topLeft}>\n topLeft\n </Button>\n <Button\n colors=\"info\"\n onClick={bottomRight}>\n bottomRight\n </Button>\n <Button\n colors=\"info\"\n onClick={bottomLeft}>\n bottomLeft\n </Button>\n </div>\n )\n }\n}\n\n\n","desc":" 一个页面的message只能设置一中显示位置,提供六种位置选择,查看每种示例,需每次刷新","scss_code":".paddingDemo{\n button{\n margin: 10px;\n }\n}"}]
14
15
16class Demo extends Component {
17 constructor(props){
18 super(props);
19 this.state = {
20 open: false
21 }
22 this.handleClick = this.handleClick.bind(this);
23 }
24 handleClick() {
25 this.setState({ open: !this.state.open })
26 }
27
28 render () {
29 const { title, example, code, desc, scss_code } = this.props;
30 let caret = this.state.open ? CARETUP : CARET;
31 let text = this.state.open ? "隐藏代码" : "查看代码";
32
33 const header = (
34 <div>
35 {example}
36 <Button style={{"marginTop": "10px"}} shape="block" onClick={ this.handleClick }>
37 { caret }
38 { text }
39 </Button>
40 </div>
41 );
42 return (
43 <Col md={12} >
44 <h3>{ title }</h3>
45 <p>{ desc }</p>
46 <Panel collapsible headerContent expanded={ this.state.open } colors='bordered' header={ header } footerStyle = {{padding: 0}}>
47 <pre><code className="hljs javascript">{ code }</code></pre>
48 { !!scss_code ? <pre><code className="hljs css">{ scss_code }</code></pre> : null }
49 </Panel>
50 </Col>
51 )
52 }
53}
54
55class DemoGroup extends Component {
56 constructor(props){
57 super(props)
58 }
59 render () {
60 return (
61 <Row>
62 {DemoArray.map((child,index) => {
63
64 return (
65 <Demo example= {child.example} title= {child.title} code= {child.code} scss_code= {child.scss_code} desc= {child.desc} key= {index}/>
66 )
67
68 })}
69 </Row>
70 )
71 }
72}
73
74ReactDOM.render(<DemoGroup/>, document.getElementById('tinperBeeDemo'));