Skip to content

Commit

Permalink
🎨 Update files
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed May 12, 2018
1 parent afca456 commit 8dad37b
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 44 deletions.
11 changes: 9 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"presets": [
"react",
[
"env",
{
"spec": true,
"useBuiltIns": "usage",
"useBuiltIns": false,
"targets": {
"browsers": ["last 2 versions", "Firefox ESR", "> 1%", "ie >= 9", "iOS >= 8", "Android >= 4"]
}
Expand All @@ -18,6 +17,14 @@
"transform-object-assign",
"transform-class-properties",
"transform-object-rest-spread",
[
"transform-runtime",
{
"helpers": false,
"polyfill": false,
"regenerator": true
}
],
[
"transform-react-jsx",
{
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ typings/

# npm lock file
package-lock.json

# webpack build output
Assets/dist/
5 changes: 5 additions & 0 deletions Assets/src/css/pages/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
html,
body {
margin: 0;
padding: 0;
}
174 changes: 174 additions & 0 deletions Assets/src/js/pages/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import '~/css/pages/index.less';

import React from 'react';
import ReactDOM from 'react-dom';
import { Table, Icon, Switch, Radio, Form, Divider } from 'antd';
const FormItem = Form.Item;

const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
width: 150,
render: text => <a href="javascript:;">{text}</a>
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
width: 70
},
{
title: 'Address',
dataIndex: 'address',
key: 'address'
},
{
title: 'Action',
key: 'action',
width: 360,
render: (text, record) => (
<span>
<a href="javascript:;">Action 一 {record.name}</a>
<Divider type="vertical" />
<a href="javascript:;">Delete</a>
<Divider type="vertical" />
<a href="javascript:;" className="ant-dropdown-link">
More actions <Icon type="down" />
</a>
</span>
)
}
];

const data = [];
for (let i = 1; i <= 10; i++) {
data.push({
key: i,
name: 'John Brown',
age: `${i}2`,
address: `New York No. ${i} Lake Park`,
description: `My name is John Brown, I am ${i}2 years old, living in New York No. ${i} Lake Park.`
});
}

const expandedRowRender = record => <p>{record.description}</p>;
const title = () => 'Here is title';
const showHeader = true;
const footer = () => 'Here is footer';
const scroll = { y: 240 };
const pagination = { position: 'bottom' };

class Demo extends React.Component {
state = {
bordered: false,
loading: false,
pagination,
size: 'default',
expandedRowRender,
title: undefined,
showHeader,
footer,
rowSelection: {},
scroll: undefined
};

handleToggle = prop => {
return enable => {
this.setState({ [prop]: enable });
};
};

handleSizeChange = e => {
this.setState({ size: e.target.value });
};

handleExpandChange = enable => {
this.setState({ expandedRowRender: enable ? expandedRowRender : undefined });
};

handleTitleChange = enable => {
this.setState({ title: enable ? title : undefined });
};

handleHeaderChange = enable => {
this.setState({ showHeader: enable ? showHeader : false });
};

handleFooterChange = enable => {
this.setState({ footer: enable ? footer : undefined });
};

handleRowSelectionChange = enable => {
this.setState({ rowSelection: enable ? {} : undefined });
};

handleScollChange = enable => {
this.setState({ scroll: enable ? scroll : undefined });
};

handlePaginationChange = e => {
const { value } = e.target;
this.setState({
pagination: value === 'none' ? false : { position: value }
});
};

render() {
const state = this.state;
return (
<div>
<div className="components-table-demo-control-bar">
<Form layout="inline">
<FormItem label="Bordered">
<Switch checked={state.bordered} onChange={this.handleToggle('bordered')} />
</FormItem>
<FormItem label="loading">
<Switch checked={state.loading} onChange={this.handleToggle('loading')} />
</FormItem>
<FormItem label="Title">
<Switch checked={!!state.title} onChange={this.handleTitleChange} />
</FormItem>
<FormItem label="Column Header">
<Switch checked={!!state.showHeader} onChange={this.handleHeaderChange} />
</FormItem>
<FormItem label="Footer">
<Switch checked={!!state.footer} onChange={this.handleFooterChange} />
</FormItem>
<FormItem label="Expandable">
<Switch checked={!!state.expandedRowRender} onChange={this.handleExpandChange} />
</FormItem>
<FormItem label="Checkbox">
<Switch checked={!!state.rowSelection} onChange={this.handleRowSelectionChange} />
</FormItem>
<FormItem label="Fixed Header">
<Switch checked={!!state.scroll} onChange={this.handleScollChange} />
</FormItem>
<FormItem label="Size">
<Radio.Group size="default" value={state.size} onChange={this.handleSizeChange}>
<Radio.Button value="default">Default</Radio.Button>
<Radio.Button value="middle">Middle</Radio.Button>
<Radio.Button value="small">Small</Radio.Button>
</Radio.Group>
</FormItem>
<FormItem label="Pagination">
<Radio.Group
value={state.pagination ? state.pagination.position : 'none'}
onChange={this.handlePaginationChange}
>
<Radio.Button value="top">Top</Radio.Button>
<Radio.Button value="bottom">Bottom</Radio.Button>
<Radio.Button value="both">Both</Radio.Button>
<Radio.Button value="none">None</Radio.Button>
</Radio.Group>
</FormItem>
</Form>
</div>
<Table {...this.state} columns={columns} dataSource={data} />
</div>
);
}
}

ReactDOM.render(<Demo />, document.getElementById('app'));
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Index</title>
<link rel="stylesheet" type="text/css" href="./Assets/dist/css/vendors.css" />
<link rel="stylesheet" type="text/css" href="./Assets/dist/css/pages/index.css" />
</head>
<body>
<div id="app"></div>
<script src="./Assets/dist/js/runtime.js"></script>
<script src="./Assets/dist/js/react.js"></script>
<script src="./Assets/dist/js/vendors.js"></script>
<script src="./Assets/dist/js/pages/index.js"></script>
</body>
</html>
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "webpack-antd-builder",
"version": "0.0.1",
"description": "A webpack antd build configure tools.",
"private": true,
"engines": {
"node": ">=7.6.0"
},
Expand All @@ -11,7 +10,10 @@
"watch": "webpack --config webpack/webpack.config.dev.js --watch",
"build": "webpack --config webpack/webpack.config.prod.js"
},
"author": "nuintun",
"author": {
"name": "nuintun",
"email": "[email protected]"
},
"dependencies": {
"antd": "^3.5.1",
"react": "^16.3.2",
Expand All @@ -23,7 +25,7 @@
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-plugin-import": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.24.1",
Expand Down
8 changes: 8 additions & 0 deletions theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module theme
* @listens MIT
* @author nuintun
* @description Antd theme configure.
*/

module.exports = {};
47 changes: 8 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ babel-plugin-syntax-flow@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz#4c3ab20a2af26aa20cd25995c398c4eb70310c8d"

babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0:
babel-plugin-syntax-jsx@^6.8.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"

Expand Down Expand Up @@ -939,7 +939,7 @@ babel-plugin-transform-export-extensions@^6.22.0:
babel-plugin-syntax-export-extensions "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-flow-strip-types@^6.22.0, babel-plugin-transform-flow-strip-types@^6.8.0:
babel-plugin-transform-flow-strip-types@^6.8.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz#84cb672935d43714fdc32bce84568d87441cf7cf"
dependencies:
Expand All @@ -959,26 +959,6 @@ babel-plugin-transform-object-rest-spread@^6.22.0, babel-plugin-transform-object
babel-plugin-syntax-object-rest-spread "^6.8.0"
babel-runtime "^6.26.0"

babel-plugin-transform-react-display-name@^6.23.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz#67e2bf1f1e9c93ab08db96792e05392bf2cc28d1"
dependencies:
babel-runtime "^6.22.0"

babel-plugin-transform-react-jsx-self@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx-self/-/babel-plugin-transform-react-jsx-self-6.22.0.tgz#df6d80a9da2612a121e6ddd7558bcbecf06e636e"
dependencies:
babel-plugin-syntax-jsx "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-react-jsx-source@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx-source/-/babel-plugin-transform-react-jsx-source-6.22.0.tgz#66ac12153f5cd2d17b3c19268f4bf0197f44ecd6"
dependencies:
babel-plugin-syntax-jsx "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-react-jsx@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.24.1.tgz#840a028e7df460dfc3a2d29f0c0d91f6376e66a3"
Expand All @@ -997,6 +977,12 @@ babel-plugin-transform-regenerator@^6.22.0, babel-plugin-transform-regenerator@^
dependencies:
regenerator-transform "^0.10.0"

babel-plugin-transform-runtime@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee"
dependencies:
babel-runtime "^6.22.0"

babel-plugin-transform-strict-mode@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758"
Expand Down Expand Up @@ -1068,23 +1054,6 @@ babel-preset-es2015@^6.9.0:
babel-plugin-transform-es2015-unicode-regex "^6.24.1"
babel-plugin-transform-regenerator "^6.24.1"

babel-preset-flow@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-preset-flow/-/babel-preset-flow-6.23.0.tgz#e71218887085ae9a24b5be4169affb599816c49d"
dependencies:
babel-plugin-transform-flow-strip-types "^6.22.0"

babel-preset-react@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-preset-react/-/babel-preset-react-6.24.1.tgz#ba69dfaea45fc3ec639b6a4ecea6e17702c91380"
dependencies:
babel-plugin-syntax-jsx "^6.3.13"
babel-plugin-transform-react-display-name "^6.23.0"
babel-plugin-transform-react-jsx "^6.24.1"
babel-plugin-transform-react-jsx-self "^6.22.0"
babel-plugin-transform-react-jsx-source "^6.22.0"
babel-preset-flow "^6.23.0"

babel-preset-stage-1@^6.5.0:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-preset-stage-1/-/babel-preset-stage-1-6.24.1.tgz#7692cd7dcd6849907e6ae4a0a85589cfb9e2bfb0"
Expand Down

0 comments on commit 8dad37b

Please sign in to comment.