├── .babelrc
├── .coveralls.yml
├── .editorconfig
├── .fecsignore
├── .fecsrc
├── .gitignore
├── .npmignore
├── .travis.yml
├── bower.json
├── esdoc.json
├── example
├── App.js
├── BoxGroup.js
├── BoxGroup.styl
├── Breadcrumb.js
├── Breadcrumb.styl
├── Button.js
├── Button.styl
├── Chip.js
├── Chip.styl
├── Dialog.js
├── Dialog.styl
├── Drawer.js
├── Drawer.styl
├── Grid.js
├── Grid.styl
├── Icon.js
├── Icon.styl
├── Pager.js
├── Pager.styl
├── Progress.js
├── Progress.styl
├── Region.js
├── Region.styl
├── ScrollView.js
├── ScrollView.styl
├── Select.js
├── Select.styl
├── Slider.js
├── SnackBar.js
├── SnackBar.styl
├── Table.js
├── Table.styl
├── Tabs.js
├── Tabs.styl
├── TextBox.js
├── TextBox.styl
├── Tooltip.js
├── Tooltip.styl
├── Tree.js
├── Tree.styl
├── Uploader.js
├── Uploader.styl
├── Zippy.js
├── Zippy.styl
├── common
│ ├── Nav.js
│ ├── NavItem.js
│ ├── component
│ │ ├── Markdown.js
│ │ └── View.js
│ └── tpl
│ │ └── base.swig
├── config.js
├── index.html
├── index.js
├── index.styl
├── metaform.html
├── metaform.js
└── metaform.styl
├── gulpfile.js
├── package-lock.json
├── package.json
├── readme.md
├── src
├── Alert.js
├── BoxGroup.js
├── Breadcrumb.js
├── Button.js
├── Card.js
├── Chip.js
├── Confirm.js
├── Dialog.js
├── Divider.js
├── Drawer.js
├── DropDownMenu.js
├── Icon.js
├── IconMenu.js
├── Layer.js
├── Link.js
├── Mask.js
├── Menu.js
├── Navigation.js
├── Pager.js
├── Popover.js
├── Progress.js
├── Region.js
├── ScrollView.js
├── Select.js
├── SelectableTable.js
├── Slider.js
├── SnackBar.js
├── Table.js
├── Tabs.js
├── TextBox.js
├── Title.js
├── Toggle.js
├── ToolBar.js
├── Tooltip.js
├── Tree.js
├── Uploader.js
├── Zippy.js
├── boxgroup
│ └── Option.js
├── breadcrumb
│ └── Item.js
├── common
│ └── util
│ │ ├── dom.js
│ │ ├── fn.js
│ │ └── guid.js
├── css
│ ├── BoxGroup.styl
│ ├── Breadcrumb.styl
│ ├── Button.styl
│ ├── ButtonGroup.styl
│ ├── Card.styl
│ ├── Chip.styl
│ ├── Dialog.styl
│ ├── Divider.styl
│ ├── Drawer.styl
│ ├── Icon.styl
│ ├── IconMenu.styl
│ ├── Layer.styl
│ ├── Link.styl
│ ├── Mask.styl
│ ├── Menu.styl
│ ├── Navigation.styl
│ ├── Pager.styl
│ ├── Popover.styl
│ ├── Progress.styl
│ ├── Region.styl
│ ├── Ripple.styl
│ ├── ScrollView.styl
│ ├── Select.styl
│ ├── Slider.styl
│ ├── SnackBar.styl
│ ├── Table.styl
│ ├── Tabs.styl
│ ├── TextBox.styl
│ ├── Title.styl
│ ├── Toggle.styl
│ ├── ToolBar.styl
│ ├── Tooltip.styl
│ ├── Tree.styl
│ ├── Uploader.styl
│ ├── Validity.styl
│ ├── Zippy.styl
│ ├── base.styl
│ ├── colors.styl
│ ├── grid.styl
│ ├── mixin.styl
│ ├── theme
│ │ └── default
│ │ │ ├── BoxGroup.variable.styl
│ │ │ ├── Breadcrumb.variable.styl
│ │ │ ├── Button.variable.styl
│ │ │ ├── Chip.variable.styl
│ │ │ ├── Link.variable.styl
│ │ │ ├── Pager.variable.styl
│ │ │ ├── Tabs.variable.styl
│ │ │ ├── Toggle.variable.styl
│ │ │ ├── ToolBar.variable.styl
│ │ │ └── index.styl
│ └── variable.styl
├── dialog
│ ├── DialogWindow.js
│ ├── commander.js
│ └── windowScrollHelper.js
├── font
│ ├── melon.eot
│ ├── melon.svg
│ ├── melon.ttf
│ ├── melon.woff
│ └── melon.woff2
├── menu
│ └── MenuItem.js
├── navigtaion
│ ├── Header.js
│ └── Item.js
├── region
│ ├── Area.js
│ ├── City.js
│ ├── Province.js
│ ├── Selector.js
│ └── helper.js
├── ripples
│ ├── CenterRipple.js
│ ├── RippleCircle.js
│ └── TouchRipple.js
├── scrollview
│ └── Bar.js
├── select
│ ├── Option.js
│ └── OptionGroup.js
├── slider
│ ├── Bar.js
│ └── getNewValue.js
├── table
│ ├── Cell.js
│ ├── Column.js
│ ├── Row.js
│ ├── SelectorColumn.js
│ ├── SelectorRow.js
│ ├── TableBody.js
│ └── TextEditor.js
├── tabs
│ ├── Panel.js
│ └── Tab.js
├── textbox
│ ├── FloatLabel.js
│ └── Input.js
└── tree
│ └── TreeNode.js
├── test
├── components
│ ├── Alert.spec.js
│ ├── BoxGroup.spec.js
│ ├── Breadcrumb.spec.js
│ ├── Button.spec.js
│ ├── Card.spec.js
│ ├── Chip.spec.js
│ ├── Confirm.spec.js
│ ├── Dialog.spec.js
│ ├── Drawer.spec.js
│ ├── Icon.spec.js
│ ├── Layer.spec.js
│ ├── Link.spec.js
│ ├── Pager.spec.js
│ ├── ScrollView.spec.js
│ ├── Select.spec.js
│ ├── SnackBar.spec.js
│ ├── Tabs.spec.js
│ ├── TextBox.spec.js
│ ├── Title.spec.js
│ ├── Toggle.spec.js
│ ├── ToolBar.spec.js
│ ├── Tooltip.spec.js
│ ├── Tree.spec.js
│ ├── Uploader.spec.js
│ └── Zippy.spec.js
├── index.js
├── index.styl
├── karma.ci.conf.js
├── karma.conf.js
├── karma.local.conf.js
├── then.js
└── waitFor.js
└── tools
├── dll.json
├── webpack.common.js
├── webpack.dev.js
├── webpack.dll.js
└── webpack.prod.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "dev": {
4 | "presets": [
5 | "es2015",
6 | "stage-2",
7 | "react"
8 | ]
9 | },
10 | "test": {
11 | "presets": [
12 | "es2015",
13 | "stage-2",
14 | "react"
15 | ],
16 | "plugins": [
17 | "istanbul"
18 | ]
19 | },
20 | "production": {
21 | "presets": [
22 | [
23 | "es2015",
24 | {
25 | "loose": true,
26 | "modules": "umd"
27 | }
28 | ],
29 | "stage-2",
30 | "react"
31 | ]
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/.coveralls.yml:
--------------------------------------------------------------------------------
1 | service_name: travis-ci
2 | repo_token: 1pRkyandErbPD52qlOmWkEnUHJFlNs6BC
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.fecsignore:
--------------------------------------------------------------------------------
1 | dist
2 | example/*.html
--------------------------------------------------------------------------------
/.fecsrc:
--------------------------------------------------------------------------------
1 | {
2 | "eslint": {
3 | "env": {
4 | "es6": -1
5 | },
6 | "rules": {
7 | "fecs-jsx-var": [
8 | 2,
9 | {
10 | "pragma": "React"
11 | }
12 | ],
13 | "fecs-no-require": -1
14 | }
15 | },
16 | "files": ["src"]
17 | }
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dep
3 | coverage
4 | .edpproj
5 | npm-debug.log
6 | output
7 | coverage
8 | *.orig
9 | .DS_Store
10 | **/.DS_Store
11 | doc
12 | asset
13 | lib/package.json
14 | lib/readme.md
15 | browsers.json
16 | .idea
17 | lib
18 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dep
3 | coverage
4 | .edpproj
5 | src
6 | test
7 | npm-debug.log
8 | output
9 | coverage
10 | *.orig
11 | .bower.json
12 | asset
13 | package-lock.json
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 6
4 | install:
5 | |
6 | npm --version
7 | npm install --registry http://registry.npmjs.org
8 | script:
9 | - npm run test-ci
10 | after_script:
11 | - npm run coveralls
12 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "melon",
3 | "version": "0.5.13",
4 | "homepage": "http://react-melon.github.io/melon",
5 | "authors": [
6 | "ludafa@outlook.com"
7 | ],
8 | "description": "react ui components",
9 | "main": "lib",
10 | "moduleType": [
11 | "umd"
12 | ],
13 | "keywords": [
14 | "react",
15 | "ui"
16 | ],
17 | "license": "MIT",
18 | "ignore": [
19 | "**/.*",
20 | "node_modules",
21 | "bower_components",
22 | "dep",
23 | "test",
24 | "tests",
25 | "src",
26 | "doc",
27 | "example",
28 | "asset"
29 | ],
30 | "dependencies": {
31 | "melon-core": "^0.4",
32 | "react": "^15",
33 | "react-motion": "^0.4"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/esdoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "source": "./src",
3 | "destination": "./doc",
4 | "plugins": [
5 | {
6 | "name": "esdoc-es7-plugin"
7 | }
8 | ],
9 | "package": "./package.json"
10 | }
11 |
--------------------------------------------------------------------------------
/example/App.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon example main
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | import React, {Component} from 'react';
7 | import Nav from './common/Nav';
8 |
9 | export default class App extends Component {
10 | render() {
11 | const {components, name, Component} = this.props;
12 | return (
13 |
14 |
17 | );
18 | }
19 | renderContent(Component) {
20 | return Component
21 | ? React.createElement(Component)
22 | : '加载中~';
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/example/BoxGroup.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/BoxGroup.styl'
3 | @require '../src/css/Button.styl'
4 | @require '../src/css/Icon.styl'
5 | @require '../src/css/Toggle.styl'
6 |
7 | .row p
8 | margin: 10px 0
--------------------------------------------------------------------------------
/example/Breadcrumb.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Tabs
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Breadcrumb from '../src/Breadcrumb';
10 | import Icon from '../src/Icon';
11 |
12 | class View extends React.Component {
13 |
14 | constructor() {
15 | super();
16 | this.state = {href: ''};
17 | }
18 |
19 | render() {
20 |
21 | const onClick = e => {
22 | e.preventDefault();
23 | this.setState({
24 | href: e.currentTarget.href
25 | });
26 | };
27 |
28 | return (
29 |
30 |
面包屑 / Breadcrumb
31 | 文本
32 |
33 | 首页
36 | 应用中心
39 | 应用列表
42 |
44 | 我的应用
45 |
46 | 带 Icon
47 |
48 |
51 | 首页
52 |
53 |
56 | 应用中心
57 |
58 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | {this.state.href}
69 |
70 | );
71 | }
72 |
73 | }
74 |
75 | module.exports = View;
76 |
--------------------------------------------------------------------------------
/example/Breadcrumb.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Breadcrumb.styl'
3 | @require '../src/css/Icon.styl'
4 |
--------------------------------------------------------------------------------
/example/Button.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Button.styl'
3 | @require '../src/css/ButtonGroup.styl'
4 | @require '../src/css/Icon.styl'
5 |
6 | .melon-row
7 | margin: 20px 0
8 |
9 | .melon-column
10 |
11 | > .ui-button + .ui-button
12 | margin-left: 1em
13 |
--------------------------------------------------------------------------------
/example/Chip.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Chip demo
3 | * @author Ma63d(chuck7liu@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Chip from '../src/Chip';
9 | import Title from '../src/Title';
10 |
11 | export default class View extends React.Component {
12 |
13 | state = {
14 | chipArr: [1,2,3,4]
15 | }
16 |
17 | handleChipRemove = i => {
18 | let chipArr = this.state.chipArr;
19 | chipArr.splice(i, 1);
20 | this.setState({
21 | chipArr
22 | });
23 | }
24 |
25 | render() {
26 | return (
27 |
28 |
Chip 纸片
29 |
默认
30 |
31 |
32 |
33 |
34 | hello world!
35 |
36 |
37 |
38 |
39 |
40 |
带头像的Chip
41 |
42 |
43 |
44 | }>
45 | hello world!
46 |
47 |
48 |
49 |
50 |
51 |
52 |
可点击的Chip
53 |
54 |
55 |
56 | }
57 | onClick={() => {alert('the chip is clicked')}}>
58 | hello world!
59 |
60 |
61 |
62 |
63 |
带删除图标的Chip
64 |
65 |
66 |
67 | {
68 | this.state.chipArr.map((item, index) => (
69 | }
70 | key={index}
71 | onClick={() => {
72 | alert('the chip is clicked');
73 | }}
74 | onRemove={() => {
75 | this.handleChipRemove(index);
76 | }}
77 | style={{margin: '4px'}}>
78 | {`我是小新${item}号`}
79 |
80 | ))
81 | }
82 |
83 |
84 |
85 |
86 |
87 | );
88 | }
89 | }
90 |
91 |
--------------------------------------------------------------------------------
/example/Chip.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Chip.styl'
2 | @require '../src/css/Title.styl'
3 | @require '../src/css/Icon.styl'
4 |
--------------------------------------------------------------------------------
/example/Dialog.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Mask.styl'
3 | @require '../src/css/Dialog.styl'
4 | @require '../src/css/Button.styl'
--------------------------------------------------------------------------------
/example/Drawer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo SnackBar
3 | * @author cxtom(cxtom2010@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 | import Title from '../src/Title';
8 | import Button from '../src/Button';
9 | import Drawer from '../src/Drawer';
10 | import Select from '../src/Select';
11 |
12 | class View extends React.Component {
13 |
14 | constructor(props) {
15 | super(props);
16 | this.state = {
17 | open: false,
18 | position: 'left',
19 | size: '300'
20 | };
21 | }
22 |
23 | render() {
24 |
25 | const {open, position, size} = this.state;
26 |
27 | return (
28 |
29 |
Drawer
30 |
79 | );
80 | }
81 | }
82 |
83 | module.exports = View;
84 |
--------------------------------------------------------------------------------
/example/Drawer.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Drawer.styl'
2 |
--------------------------------------------------------------------------------
/example/Grid.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo button
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 |
10 | const CELL_STYLE = {
11 | backgroundColor: '#eee',
12 | display: 'flex',
13 | alignItems: 'center',
14 | justifyContent: 'center',
15 | height: '60px'
16 | };
17 |
18 | class View extends React.Component {
19 |
20 | render() {
21 | return (
22 |
23 |
按钮
24 | 预定义样式
25 | {this.renderGrid(12)}
26 |
27 | );
28 | }
29 |
30 | renderGrid(columns) {
31 |
32 | let grid = [];
33 |
34 | for (let i = 1; i < columns; ++i) {
35 |
36 | let prev = 'melon-column melon-column-' + i;
37 | let next = 'melon-column melon-column-' + (columns - i);
38 |
39 | grid[i] = (
40 |
41 |
{i}
42 |
{columns - i}
43 |
44 | );
45 |
46 | }
47 |
48 | return grid;
49 | }
50 |
51 | }
52 |
53 | module.exports = View;
54 |
--------------------------------------------------------------------------------
/example/Grid.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 |
--------------------------------------------------------------------------------
/example/Icon.styl:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/example/Pager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Pager
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Pager from '../src/Pager';
10 |
11 | class View extends React.Component {
12 |
13 | constructor() {
14 | super();
15 | this.state = {
16 | page1: 1,
17 | page2: 1
18 | };
19 | }
20 |
21 | render() {
22 | return (
23 |
24 |
翻页器
25 |
26 |
图标
27 |
28 |
29 |
30 | {this.getCurrentPage(1)}
31 |
32 |
文字
33 |
34 |
35 |
36 | {this.getCurrentPage(2)}
37 |
38 |
39 |
40 |
41 | );
42 | }
43 |
44 | getCurrentPage(index) {
45 | return (
46 |
47 |
50 |
51 | );
52 | }
53 |
54 | onChange(index, e) {
55 | this.setState({
56 | [`page${index}`]: e.page
57 | });
58 | }
59 |
60 | }
61 |
62 | module.exports = View;
63 |
--------------------------------------------------------------------------------
/example/Pager.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Pager.styl'
3 | @require '../src/css/Icon.styl'
--------------------------------------------------------------------------------
/example/Progress.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Progress
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Progress from '../src/Progress';
10 |
11 | class View extends React.Component {
12 |
13 | constructor() {
14 | super();
15 | this.state = {
16 | value: 20
17 | };
18 | }
19 |
20 | componentDidMount() {
21 | const me = this;
22 | let value = this.state.value;
23 | this.timer = setTimeout(function tick() {
24 | value += 10;
25 | if (value < 100) {
26 | me.timer = setTimeout(tick, 800);
27 | me.setState({value});
28 | }
29 | }, 800);
30 | }
31 |
32 | componentWillUnmount() {
33 | clearTimeout(this.timer);
34 | }
35 |
36 | render() {
37 | return (
38 |
39 |
Progress
40 |
41 |
42 |
Linear
43 |
determinate
44 |
45 |
indeterminate
46 |
47 |
48 |
49 |
50 |
Circle
51 |
determinate
52 |
53 |
54 |
55 |
56 |
57 |
indeterminate
58 |
59 |
60 |
61 |
62 |
63 | );
64 | }
65 |
66 | }
67 |
68 | module.exports = View;
69 |
--------------------------------------------------------------------------------
/example/Progress.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Progress.styl'
--------------------------------------------------------------------------------
/example/Region.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Region.styl'
3 |
4 | .row
5 | max-width: 800px;
--------------------------------------------------------------------------------
/example/ScrollView.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo ScrollView
3 | * @author cxtom(cxtom2010@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 | import Title from '../src/Title';
8 | import ScrollView from '../src/ScrollView';
9 |
10 | class View extends React.Component {
11 |
12 | render() {
13 | return (
14 |
15 |
ScrollView
16 |
17 |
18 |
如何让你遇见我
19 |
在我最美丽的时刻为这
20 |
我已在佛前求了五百年
21 |
求他让我们结一段尘缘
22 |
佛于是把我化作一棵树
23 |
长在你必经的路旁
24 |
阳光下慎重地开满了花
25 |
朵朵都是我前世的盼望
26 |
当你走近请你细听
27 |
那颤抖的叶是我等待的热情
28 |
而当你终于无视地走过
29 |
在你身后落了一地的
30 |
朋友啊那不是花瓣
31 |
是我凋零的心
32 |
只缘感君一回顾,使我思君暮与朝
33 |
——席慕容《古乐府》
34 |
35 |
36 |
垂柳里,兰舟当日曾系。
37 |
千帆过尽,只伊人不随书至。
38 |
怪管道着我侬心,一般思妇游子。
39 |
昨宵梦,分明记:几回飞度烟水。
40 |
西风水断伴灯花,摇摇欲坠。
41 |
宵深待到凤凰山,声声啼鴂催起。
42 |
锦书宛在怀袖底。
43 |
人迢迢、紫塞千里,算是不曾相忆。
44 |
倘有情、早合归来,休寄一纸无聊相思字!
45 |
——王国维《西河》
46 |
47 |
48 |
49 | );
50 | }
51 | }
52 |
53 | module.exports = View;
54 |
--------------------------------------------------------------------------------
/example/ScrollView.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/ScrollView.styl'
3 |
4 | .ui-scrollview
5 | line-height: 25px
--------------------------------------------------------------------------------
/example/Select.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Select.styl'
3 |
--------------------------------------------------------------------------------
/example/Slider.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Slider
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Slider from '../src/Slider';
10 |
11 | class View extends React.Component {
12 |
13 | constructor() {
14 | super();
15 |
16 | this.state = {
17 | value1: 12
18 | };
19 |
20 | this.onChange = this.onChange.bind(this);
21 | }
22 |
23 | onChange({value}) {
24 | this.setState({value1: value});
25 | }
26 |
27 | render() {
28 | return (
29 |
30 |
数值选择器
31 |
36 |
41 |
42 | 数值:{this.state.value1}
43 |
44 |
45 | );
46 | }
47 |
48 | }
49 |
50 | module.exports = View;
51 |
--------------------------------------------------------------------------------
/example/SnackBar.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/SnackBar.styl'
3 | @require '../src/css/TextBox.styl'
4 |
--------------------------------------------------------------------------------
/example/Table.styl:
--------------------------------------------------------------------------------
1 |
2 | @require 'nib'
3 | @require '../src/css/Title.styl'
4 | @require '../src/css/Table.styl'
5 | @require '../src/css/Button.styl'
6 |
7 | #app
8 | padding-bottom 200px
9 |
10 | .ui-table
11 | margin: 20px 0
12 |
--------------------------------------------------------------------------------
/example/Tabs.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Tabs
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Tabs from '../src/Tabs';
10 |
11 | /* eslint-disable no-console */
12 |
13 | const Tab = Tabs.Tab;
14 |
15 | class View extends React.Component {
16 |
17 | constructor(props) {
18 | super(props);
19 | this.state = {
20 | selectedIndex: 2
21 | };
22 | }
23 |
24 | renderPanel(content) {
25 | return (
26 |
34 | {content}
35 |
36 | );
37 | }
38 |
39 | render() {
40 | return (
41 |
42 |
Tabs
43 |
uncontrolled tabs
44 |
47 |
48 | {this.renderPanel('This is Tab A')}
49 |
50 |
51 | {this.renderPanel('This is Tab B')}
52 |
53 |
54 | {this.renderPanel()}
55 |
56 |
57 |
58 |
controlled tabs
59 |
60 | 当前选中的是第 {this.state.selectedIndex} 个 tab
61 |
62 |
this.setState({selectedIndex})}>
65 |
66 | {this.renderPanel('This is Tab A')}
67 |
68 |
69 | {this.renderPanel('This is Tab B')}
70 |
71 |
72 | {this.renderPanel()}
73 |
74 |
75 |
76 |
77 | );
78 | }
79 |
80 | }
81 |
82 | module.exports = View;
83 |
--------------------------------------------------------------------------------
/example/Tabs.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Tabs.styl'
3 |
--------------------------------------------------------------------------------
/example/TextBox.styl:
--------------------------------------------------------------------------------
1 | @require 'nib'
2 | @require '../src/css/Title.styl'
3 | @require '../src/css/TextBox.styl'
4 |
5 | .melon-row
6 | margin: 2em 0
7 |
--------------------------------------------------------------------------------
/example/Tooltip.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Tabs
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Tooltip from '../src/Tooltip';
10 | import Button from '../src/Button';
11 | import Icon from '../src/Icon';
12 |
13 | class View extends React.Component {
14 |
15 | render() {
16 |
17 | return (
18 |
19 |
Switches
20 |
21 |
22 |
23 |
方向
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
按钮组
37 |
38 |
39 |
42 |
43 |
44 |
47 |
48 |
49 |
52 |
53 |
54 |
55 | );
56 | }
57 |
58 | }
59 |
60 | module.exports = View;
61 |
--------------------------------------------------------------------------------
/example/Tooltip.styl:
--------------------------------------------------------------------------------
1 | @require "../src/css/Title.styl"
2 | @require "../src/css/Tooltip.styl"
3 | @require "../src/css/Button.styl"
4 | @require "../src/css/Icon.styl"
5 |
6 |
7 | .ui-tooltip + .ui-tooltip
8 | margin-left: 1em
9 |
--------------------------------------------------------------------------------
/example/Tree.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo Tree
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 |
8 | import Title from '../src/Title';
9 | import Tree from '../src/Tree';
10 |
11 | const TreeNode = Tree.TreeNode;
12 |
13 | class View extends React.Component {
14 |
15 | render() {
16 |
17 | const datasource = [{
18 | id: '1',
19 | text: '百度',
20 | children: [
21 | {
22 | id: '2',
23 | text: '联盟研发部',
24 | children: [
25 | {id: '21', text: 'RD'},
26 | {id: '22', text: 'FE'},
27 | {id: '23', text: 'QA'},
28 | {id: '24', text: 'PM'}
29 | ]
30 | },
31 | {
32 | id: '3',
33 | text: '贴吧事业部',
34 | children: [
35 | {
36 | id: '31',
37 | text: 'RD',
38 | children: [
39 | {id: '311', text: 'UI'},
40 | {id: '312', text: 'BS'}
41 | ]
42 | },
43 | {id: '32', text: 'FE'},
44 | {id: '33', text: 'QA'},
45 | {id: '34', text: 'PM'}
46 | ]
47 | },
48 | {
49 | id: '4',
50 | text: '百度音乐'
51 | }
52 | ]
53 | }];
54 |
55 | return (
56 |
57 |
Tree
58 |
59 |
60 |
普通
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
使用Datasource
82 |
83 | {Tree.createTreeNodes(datasource)}
84 |
85 |
86 |
87 |
88 |
defaultExpandAll
89 |
90 | {Tree.createTreeNodes(datasource)}
91 |
92 |
93 |
94 | );
95 | }
96 | }
97 |
98 | module.exports = View;
99 |
--------------------------------------------------------------------------------
/example/Tree.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Title.styl'
2 | @require '../src/css/Tree.styl'
--------------------------------------------------------------------------------
/example/Uploader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo button
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | import React from 'react';
7 | import Title from '../src/Title';
8 | import Uploader from '../src/Uploader';
9 |
10 | /* eslint-disable */
11 | const EXAMPLE_IMG_URL = [
12 | 'https://assets.materialup.com/uploads/878dbfeb-7503-4d63-a4ab-1435ac533296/attachment.png',
13 | 'http://react-melon.github.io/melon/asset/common/img/melon-logo.ffb5dd37.png'
14 | ];
15 | /* eslint-enable */
16 |
17 | function randomImageURL() {
18 | const index = Math.floor(EXAMPLE_IMG_URL.length * Math.random());
19 | return EXAMPLE_IMG_URL[index];
20 | }
21 |
22 | class View extends React.Component {
23 |
24 | constructor(props) {
25 | super(props);
26 | this.upload = this.upload.bind(this);
27 | this.state = {
28 | imgURL: randomImageURL(),
29 | fileURL: 'http://boscdn.bpc.baidu.com/mms-res/voicefe/captain/widgets/Text.zip'
30 | };
31 | }
32 |
33 | render() {
34 | return (
35 |
36 |
文件上传
37 | 待选择
38 |
43 |
48 | 图片已选择
49 | {
52 |
53 | if (!files) {
54 | this.setState({imgURL: ''});
55 | return;
56 | }
57 |
58 | }}
59 | value={this.state.imgURL} />
60 | 文件已选择
61 | {
65 |
66 | if (!files) {
67 | this.setState({fileURL: ''});
68 | return;
69 | }
70 |
71 | }}
72 | value={this.state.fileURL} />
73 |
74 | );
75 | }
76 |
77 | upload(files) {
78 |
79 | return new Promise(function (resolve, reject) {
80 |
81 | setTimeout(
82 | function () {
83 | resolve(randomImageURL());
84 | },
85 | 50000
86 | );
87 |
88 | });
89 |
90 | }
91 |
92 | }
93 |
94 | module.exports = View;
95 |
--------------------------------------------------------------------------------
/example/Uploader.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/Uploader.styl'
2 | @require '../src/css/Title.styl'
3 |
--------------------------------------------------------------------------------
/example/Zippy.styl:
--------------------------------------------------------------------------------
1 |
2 | .ui-zippy
3 | p
4 | padding: 0
5 |
--------------------------------------------------------------------------------
/example/common/Nav.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file demo nav
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | let React = require('react');
7 | let PropTypes = require('prop-types');
8 |
9 | let NavItem = require('./NavItem');
10 |
11 | class Nav extends React.Component {
12 |
13 | render() {
14 |
15 | let {components, name} = this.props;
16 |
17 | return (
18 |
31 | );
32 | }
33 |
34 | }
35 |
36 | Nav.propsTypes = {
37 | components: PropTypes.array.isRequired
38 | };
39 |
40 | module.exports = Nav;
41 |
--------------------------------------------------------------------------------
/example/common/NavItem.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon/example/NavItem
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | var React = require('react');
7 |
8 | class NavItem extends React.Component {
9 | render() {
10 | var {name, current} = this.props;
11 | return (
12 |
13 |
16 | {name}
17 |
18 |
19 | );
20 | }
21 | }
22 |
23 | module.exports = NavItem;
24 |
--------------------------------------------------------------------------------
/example/common/component/Markdown.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Markdown component
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | var React = require('react');
7 | var Remarkable = require('remarkable');
8 |
9 | class Markdown extends React.Component {
10 |
11 | render() {
12 |
13 | return (
14 | {this.getContent()}
15 | );
16 |
17 | }
18 |
19 | getContent() {
20 |
21 | var markdown = new Remarkable({
22 | html: true
23 | });
24 |
25 | return React.Children.map(this.props.children, function (child) {
26 |
27 |
28 | if (typeof child !== 'string') {
29 | return child;
30 | }
31 |
32 | child = {
33 | __html: markdown.render(child)
34 | };
35 |
36 | return ;
37 |
38 | });
39 | }
40 |
41 | }
42 |
43 | module.exports = Markdown;
44 |
--------------------------------------------------------------------------------
/example/common/component/View.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon demo view
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | var React = require('react');
7 | var Nav = require('./Nav');
8 |
9 | var View = React.createClass({
10 |
11 | render: function() {
12 |
13 | console.log(this.props);
14 |
15 | return (
16 |
17 |
18 | {this.props.children}
19 |
20 | );
21 | }
22 |
23 | });
24 |
25 | module.exports = View;
26 |
--------------------------------------------------------------------------------
/example/common/tpl/base.swig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {% block title %}melon{% endblock %}
6 |
7 |
8 |
9 |
10 |
11 |
12 |
24 |
25 |
26 |
27 |
28 |
46 | {% block script %}{% endblock %}
47 |
48 |
49 |
--------------------------------------------------------------------------------
/example/config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon example config
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | module.exports = {
7 | components: [
8 | 'BoxGroup',
9 | 'Breadcrumb',
10 | 'Button',
11 | 'Chip',
12 | 'Dialog',
13 | 'Drawer',
14 | 'Grid',
15 | 'Icon',
16 | 'Pager',
17 | 'Progress',
18 | 'Region',
19 | 'ScrollView',
20 | 'Select',
21 | 'Slider',
22 | 'SnackBar',
23 | 'Table',
24 | 'Tabs',
25 | 'TextBox',
26 | 'Tree',
27 | 'Tooltip',
28 | 'Uploader',
29 | 'Zippy'
30 | ]
31 | };
32 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | melon example
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon example index
3 | * @author leon
4 | */
5 |
6 | import React from 'react';
7 | import ReactDOM from 'react-dom';
8 | import HashLocator from 'numen/HashLocator';
9 |
10 | import BoxGroup from './BoxGroup';
11 | import Breadcrumb from './Breadcrumb';
12 | import Button from './Button';
13 | import Chip from './Chip';
14 | import Dialog from './Dialog';
15 | import Drawer from './Drawer';
16 | import Grid from './Grid';
17 | import Icon from './Icon';
18 | import Pager from './Pager';
19 | import Progress from './Progress';
20 | import Region from './Region';
21 | import ScrollView from './ScrollView';
22 | import Select from './Select';
23 | import Slider from './Slider';
24 | import SnackBar from './SnackBar';
25 | import Table from './Table';
26 | import Tabs from './Tabs';
27 | import TextBox from './TextBox';
28 | import Tooltip from './Tooltip';
29 | import Tree from './Tree';
30 | import Uploader from './Uploader';
31 | import Zippy from './Zippy';
32 |
33 | import App from './App';
34 | import config from './config';
35 | import './index.styl';
36 |
37 | const routes = {
38 | BoxGroup,
39 | Breadcrumb,
40 | Button,
41 | Chip,
42 | Dialog,
43 | Drawer,
44 | Grid,
45 | Icon,
46 | Pager,
47 | Progress,
48 | Region,
49 | ScrollView,
50 | Select,
51 | Slider,
52 | SnackBar,
53 | Table,
54 | Tabs,
55 | TextBox,
56 | Tooltip,
57 | Tree,
58 | Uploader,
59 | Zippy
60 | };
61 |
62 | /* eslint-disable no-console */
63 |
64 | function bootstrap(account) {
65 |
66 | const locator = new HashLocator();
67 |
68 | locator.on(function (location) {
69 |
70 | const name = location.pathname.slice(1) || 'Button';
71 | const Component = routes[name];
72 |
73 | ReactDOM.render(
74 | ,
78 | document.querySelector('#app')
79 | );
80 |
81 | });
82 |
83 | locator.start();
84 | }
85 |
86 | bootstrap();
87 |
--------------------------------------------------------------------------------
/example/index.styl:
--------------------------------------------------------------------------------
1 | @require 'nib'
2 | @require '../src/css/mixin.styl'
3 | @require '../src/css/theme/default'
4 |
5 | global-reset()
6 |
7 | body
8 | font-size: 16px
9 | font-family: 'Helvetica Neue', Helvetica, 'Microsoft YaHei', Arial, '宋体', SimSun, sans-serif
10 |
11 | melon-generate-grid()
12 |
13 | #app
14 | margin-left 200px
15 | padding 0 10px
16 |
17 | .nav
18 | fixed: top left bottom
19 | width: 200px
20 | background: #1b1c1d
21 | text-align: right
22 | overflow-y: auto
23 |
24 | > h1
25 | height: 2em
26 | color: rgb(0, 159, 147)
27 | font-size: 32px
28 | line-height: @height
29 | padding-right 10px
30 |
31 | > ul
32 |
33 | border: 1px solid rgba(255, 255, 255, .3)
34 | border-width: 1px 0 1px 0
35 |
36 | a
37 | display block
38 | height 3em
39 | padding-right 10px
40 | color #888
41 | line-height @height
42 | text-decoration none
43 | transition all .3s
44 |
45 | &.current, &:hover
46 | background-color: #1b1c1d + 10%
47 | color: #fff
48 |
49 | .row
50 | padding: 10px 0
51 |
52 | .line
53 | float: left
54 | box-sizing: border-box
55 | width: 25%
56 | padding: 10px
57 | text-align center
58 |
59 | .cell
60 | margin: 10px 0
61 | height: 120px
62 | font-size: 16px
63 |
64 | &:hover
65 | color: $-melon-colors.teal500
66 |
67 | >label
68 | display: block
69 | height: 30px
70 | line-height 30px
71 |
72 | .melon-row
73 | margin-top: 1em
74 |
75 | p
76 | font-size: 1.2rem
77 | color: #aaa
78 | line-height: 1.5
79 | padding: 1rem 0
80 |
81 | @require '../src/css/**'
82 | @require 'BoxGroup.styl'
83 | @require 'Breadcrumb.styl'
84 | @require 'Button.styl'
85 | @require 'Chip.styl'
86 | @require 'Dialog.styl'
87 | @require 'Drawer.styl'
88 | @require 'Pager.styl'
89 | @require 'Progress.styl'
90 | @require 'Region.styl'
91 | @require 'ScrollView.styl'
92 | @require 'Select.styl'
93 | @require 'SnackBar.styl'
94 | @require 'Table.styl'
95 | @require 'Tabs.styl'
96 | @require 'TextBox.styl'
97 | @require 'Tooltip.styl'
98 | @require 'Tree.styl'
99 | @require 'Uploader.styl'
100 | @require 'Zippy.styl'
101 | @require '../src/css/Slider.styl'
102 | @require '../src/css/Zippy.styl'
103 |
--------------------------------------------------------------------------------
/example/metaform.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | melon meta form demo
6 |
7 |
8 |
9 |
10 |
11 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/metaform.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file metaform
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | const React = require('react');
7 | const ReactDOM = require('react-dom');
8 | const Button = require('melon/Button');
9 | const Icon = require('melon/Icon');
10 | const Breadcrumb = require('melon/Breadcrumb');
11 | const Title = require('melon/Title');
12 | const Link = require('melon/Link');
13 |
14 | ReactDOM.render(
15 |
16 |
button
17 |
18 |
19 | icon
20 |
21 |
22 | 首页
23 | 应用中心
24 | 应用列表
25 | 我的应用
26 |
27 | level 1 haha
28 | a link
29 | level 2 haha
30 | level 3 haha
31 | level 4 haha
32 | level 5 haha
33 | level 6 haha
34 | ,
35 | document.querySelector('#app')
36 | );
37 |
--------------------------------------------------------------------------------
/example/metaform.styl:
--------------------------------------------------------------------------------
1 | @require '../src/css/theme/default'
2 | @require '../src/css/Button.styl'
3 | @require '../src/css/Icon.styl'
4 | @require '../src/css/Breadcrumb.styl'
5 | @require '../src/css/Title.styl'
6 | @require '../src/css/Link.styl'
7 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file gulpfile
3 | * @author leon
4 | */
5 |
6 | const gulp = require('gulp');
7 | const babel = require('gulp-babel');
8 | const clean = require('gulp-clean');
9 |
10 | const sourcemaps = require('gulp-sourcemaps');
11 |
12 | gulp.task('babel', function () {
13 | return gulp.src('src/**/*.js')
14 | .pipe(sourcemaps.init())
15 | .pipe(babel())
16 | .pipe(sourcemaps.write('.'))
17 | .pipe(gulp.dest('lib'));
18 | });
19 |
20 | gulp.task('stylus', function () {
21 | return gulp.src('src/**/*.styl').pipe(gulp.dest('lib'));
22 | });
23 |
24 | gulp.task('font', function () {
25 | return gulp.src('src/font/*').pipe(gulp.dest('lib/font'));
26 | });
27 |
28 | gulp.task('pkg', function () {
29 | return gulp.src([
30 | 'package.json',
31 | 'readme.md'
32 | ]).pipe(gulp.dest('lib'));
33 | });
34 |
35 | gulp.task('build', ['babel', 'stylus', 'font', 'pkg']);
36 |
37 | gulp.task('clean', function () {
38 | return gulp
39 | .src('dist', {read: false})
40 | .pipe(clean());
41 | });
42 |
43 | gulp.task('rebuild', ['clean', 'build']);
44 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "melon",
3 | "version": "0.6.0-alpha.3",
4 | "description": "ui components for react",
5 | "main": "./src",
6 | "scripts": {
7 | "start": "NODE_ENV=dev webpack-dev-server --config tools/webpack.dev.js",
8 | "build": "rimraf lib && NODE_ENV=production gulp build",
9 | "lint": "fecs",
10 | "docs": "esdoc -c esdoc.json",
11 | "setup": "rimraf asset && NODE_ENV=production webpack --config=tools/webpack.dll.js",
12 | "test": "NODE_ENV=test karma start ./test/karma.local.conf.js",
13 | "test-ci": "NODE_ENV=test karma start ./test/karma.ci.conf.js",
14 | "coveralls": "cat ./test/coverage/lcov/lcov.info | ./node_modules/.bin/coveralls"
15 | },
16 | "devDependencies": {
17 | "babel-core": "^6.26.0",
18 | "babel-istanbul": "^0.12.2",
19 | "babel-loader": "^6.2.5",
20 | "babel-plugin-istanbul": "^4.1.5",
21 | "babel-plugin-transform-es2015-modules-umd": "^6.12.0",
22 | "babel-plugin-transform-object-rest-spread": "^6.8.0",
23 | "babel-preset-es2015": "^6.14.0",
24 | "babel-preset-react": "^6.11.1",
25 | "babel-preset-stage-2": "^6.13.0",
26 | "connect-history-api-fallback": "^1.3.0",
27 | "coveralls": "^2.11.12",
28 | "css-loader": "^0.24.0",
29 | "enzyme": "^3.1.0",
30 | "enzyme-adapter-react-16": "^1.0.2",
31 | "esdoc": "^0.4.8",
32 | "esdoc-es7-plugin": "0.0.3",
33 | "extract-text-webpack-plugin": "^1.0.1",
34 | "fecs": "^0.8.6",
35 | "file-loader": "^0.9.0",
36 | "gulp": "^3.9.1",
37 | "gulp-babel": "^6.1.2",
38 | "gulp-clean": "^0.3.2",
39 | "gulp-sourcemaps": "^1.6.0",
40 | "html-webpack-harddisk-plugin": "0.0.2",
41 | "html-webpack-plugin": "^2.22.0",
42 | "jasmine": "^2.4.1",
43 | "json-loader": "^0.5.4",
44 | "karma": "^1.2.0",
45 | "karma-babel-preprocessor": "^6.0.1",
46 | "karma-browserstack-launcher": "^1.2.0",
47 | "karma-chrome-launcher": "^2.0.0",
48 | "karma-coverage": "^1.1.1",
49 | "karma-firefox-launcher": "^1.0.0",
50 | "karma-jasmine": "^1.0.2",
51 | "karma-jasmine-expect-jsx": "^1.0.2",
52 | "karma-sourcemap-loader": "^0.3.7",
53 | "karma-webpack": "^1.8.0",
54 | "nib": "^1.1.2",
55 | "numen": "^0.2.0",
56 | "react": "^16.0.0",
57 | "react-dom": "^16.0.0",
58 | "react-test-renderer": "^16.0.0",
59 | "rimraf": "^2.5.4",
60 | "style-loader": "^0.13.1",
61 | "stylus": "^0.54.5",
62 | "stylus-loader": "^2.3.1",
63 | "watchify": "^3.7.0",
64 | "webpack": "^1.13.1",
65 | "webpack-dev-server": "^1.16.5"
66 | },
67 | "repository": {
68 | "type": "git",
69 | "url": "git+https://github.com/react-melon/melon.git"
70 | },
71 | "peerDependencies": {
72 | "react": "^16.0.0",
73 | "react-dom": "^16.0.0"
74 | },
75 | "keywords": [
76 | "react",
77 | "ui",
78 | "components"
79 | ],
80 | "author": "ludafa@outlook.com",
81 | "license": "ISC",
82 | "bugs": {
83 | "url": "https://github.com/react-melon/melon/issues"
84 | },
85 | "homepage": "https://github.com/react-melon/melon#readme",
86 | "dependencies": {
87 | "dom-align": "^1.5.3",
88 | "lodash.omit": "^4.5.0",
89 | "melon-core": "^0.5.2",
90 | "prop-types": "^15.5.10",
91 | "react-motion": "^0.5.2"
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/Alert.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon/dialog/Alert
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 | import PropTypes from 'prop-types';
8 | import Dialog from './Dialog';
9 | import Button from './Button';
10 | import createCommand from './dialog/commander';
11 |
12 | /* eslint-disable fecs-prefer-class */
13 |
14 | /**
15 | * melon/Alert
16 | *
17 | * @class
18 | * @param {Object} props 属性
19 | * @return {ReactElement}
20 | */
21 | export default function Alert(props) {
22 |
23 | const {
24 | variants = [],
25 | buttonVariants = [],
26 | size,
27 | onConfirm,
28 | ...rest
29 | } = props;
30 |
31 | const actions = (
32 |
39 | );
40 |
41 | return (
42 |
48 | );
49 |
50 | }
51 | /* eslint-enable fecs-prefer-class */
52 |
53 | Alert.displayName = 'Alert';
54 |
55 | Alert.propTypes = {
56 | ...Dialog.propTypes,
57 | onConfirm: PropTypes.func,
58 | buttonText: PropTypes.string.isRequired,
59 | buttonVariants: PropTypes.arrayOf(PropTypes.string).isRequired
60 | };
61 |
62 | Alert.defaultProps = {
63 | ...Dialog.defaultProps,
64 | maskClickClose: false,
65 | buttonText: '确定',
66 | buttonVariants: ['primary']
67 | };
68 |
69 |
70 | /**
71 | * 命令式显示一个警告框
72 | *
73 | * @example
74 | * const clean = Alert.show({
75 | * title: 'xxx',
76 | * children: 12321
,
77 | * onConfirm: function () {
78 | * 同步操作
79 | * 异步操作.then(function () {
80 | * clean();
81 | * })
82 | * }
83 | * });
84 | * @param {Object} options 警告窗参数
85 | * @return {Function} 清理函数
86 | */
87 | Alert.show = createCommand(Alert, ['onConfirm']);
88 |
--------------------------------------------------------------------------------
/src/Breadcrumb.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon/Breadcrumb
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | import React from 'react';
7 | import {create} from 'melon-core/classname/cxBuilder';
8 | import Item from './breadcrumb/Item';
9 |
10 | const cx = create('Breadcrumb');
11 |
12 | /* eslint-disable fecs-prefer-class */
13 |
14 | /**
15 | * melon/Breadcrumb
16 | *
17 | * @class
18 | * @param {Object} props 属性
19 | * @return {ReactElement}
20 | */
21 | function Breadcrumb(props) {
22 |
23 | /* eslint-disable fecs-min-vars-per-destructure */
24 | const {
25 | children,
26 | ...rest
27 | } = props;
28 |
29 | return (
30 |
31 | {React.Children.map(
32 | children,
33 | (child, index) => (
34 | child && child.type === Item
35 | ? React.cloneElement(child, {
36 | key: index,
37 | level: index
38 | })
39 | : null
40 | )
41 | )}
42 |
43 | );
44 |
45 | }
46 | /* eslint-enable fecs-prefer-class */
47 |
48 | Breadcrumb.Item = Item;
49 |
50 | Breadcrumb.createCrumbs = function (crumbs) {
51 |
52 | return crumbs.map(function (crumb, index) {
53 |
54 | const {text, ...rest} = crumb;
55 |
56 | return (
57 | -
61 | {text}
62 |
63 | );
64 | });
65 |
66 | };
67 |
68 | export {
69 | Breadcrumb as default,
70 | Item
71 | };
72 |
--------------------------------------------------------------------------------
/src/Button.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon/Button
3 | * @author leon
4 | */
5 |
6 | import React from 'react';
7 | import PropTypes from 'prop-types';
8 | import {create} from 'melon-core/classname/cxBuilder';
9 | import TouchRipple from './ripples/TouchRipple';
10 | import omit from 'lodash/omit';
11 |
12 | const cx = create('Button');
13 |
14 | /* eslint-disable fecs-prefer-class */
15 |
16 | /**
17 | * melon/Button
18 | *
19 | * @class
20 | * @param {Object} props 属性
21 | * @param {boolean} props.disabled 是否不可点击
22 | * @param {boolean} props.hasRipple 是否有ripple动画
23 | * @return {ReactElement}
24 | */
25 | export default function Button(props) {
26 |
27 | const {
28 | hasRipple,
29 | label,
30 | children,
31 | disabled,
32 | ...others
33 | } = props;
34 |
35 | const className = cx(props)
36 | .addVariants({
37 | icon: React.Children.count(children) === 1
38 | && typeof children === 'object'
39 | && children.type.displayName === 'Icon',
40 | ripple: hasRipple && !disabled
41 | })
42 | .build();
43 |
44 | return (
45 |
52 | );
53 |
54 | }
55 | /* eslint-enable fecs-prefer-class */
56 |
57 | Button.defaultProps = {
58 | hasRipple: true,
59 | disabled: false
60 | };
61 |
62 | Button.propTypes = {
63 | hasRipple: PropTypes.bool,
64 | disabled: PropTypes.bool
65 | };
66 |
--------------------------------------------------------------------------------
/src/Card.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Card
3 | * @author leon(ludafa@outlook.com)
4 | */
5 |
6 | import React from 'react';
7 | import {create} from 'melon-core/classname/cxBuilder';
8 |
9 | const cx = create('Card');
10 |
11 | /* eslint-disable fecs-prefer-class */
12 |
13 | /**
14 | * melon/Card
15 | *
16 | * @class
17 | * @param {Object} props 属性
18 | * @return {ReactElement}
19 | */
20 | export default function Card(props) {
21 |
22 | const children = props.children;
23 |
24 | return (
25 |
26 | {children}
27 |
28 | );
29 |
30 | }
31 | /* eslint-enable fecs-prefer-class */
32 |
33 | Card.displayName = 'Card';
34 |
--------------------------------------------------------------------------------
/src/Confirm.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file melon/dialog/Confirm
3 | * @author cxtom(cxtom2008@gmail.com)
4 | */
5 |
6 | import React from 'react';
7 | import PropTypes from 'prop-types';
8 | import Dialog from './Dialog';
9 | import Button from './Button';
10 | import createCommand from './dialog/commander';
11 |
12 | /* eslint-disable fecs-prefer-class */
13 |
14 | /**
15 | * melon/Confirm
16 | *
17 | * @extends {React.Component}
18 | * @class
19 | * @param {Object} props 属性
20 | */
21 | export default function Confirm(props) {
22 |
23 |
24 | const {
25 | size,
26 | buttonVariants,
27 | variants = [],
28 | onConfirm,
29 | onCancel,
30 | cancelButtonText,
31 | confirmButtonText,
32 | ...rest
33 | } = props;
34 |
35 | const actions = [
36 |