Skip to content

Commit 4751aba

Browse files
committed
feat: Create app
1 parent 0d8f4f0 commit 4751aba

File tree

40 files changed

+1991
-357
lines changed

40 files changed

+1991
-357
lines changed

config/i18n.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const translations = {
33
translation: require('../src/locales/en/translation.json')
44
},
55
zh: {
6-
translation: require('../src/locales/zh/translation.json')
6+
translation: Object.assign(
7+
{},
8+
require('../src/locales/zh/apps.json'),
9+
require('../src/locales/zh/translation.json')
10+
)
711
}
812
};
913

src/components/Base/Input/input.jsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,74 @@
11
import React from 'react';
22
import classnames from 'classnames';
33
import PropTypes from 'prop-types';
4+
import { observer } from 'mobx-react';
5+
import _ from 'lodash';
46

57
import Icon from '../Icon';
68

79
import styles from './index.scss';
810

11+
@observer
912
export default class Input extends React.Component {
1013
static propTypes = {
1114
className: PropTypes.string,
1215
disabled: PropTypes.bool,
1316
icon: PropTypes.string,
1417
iconSize: PropTypes.number,
15-
iconType: PropTypes.string
18+
iconType: PropTypes.string,
19+
valueChange: PropTypes.func
1620
};
1721

1822
static defaultProps = {
1923
className: '',
2024
icon: '',
2125
iconType: 'light',
2226
iconSize: 16,
27+
valueChange: _.noop,
28+
onChange: _.noop,
2329
disabled: false
2430
};
2531

32+
constructor(props) {
33+
super(props);
34+
this.onChange = this.onChange.bind(this);
35+
}
36+
37+
onChange(event) {
38+
const { target } = event;
39+
const value = target.type === 'checkbox' ? target.checked : target.value;
40+
const name = target.name;
41+
42+
this.props.valueChange(name, value);
43+
this.props.onChange(event);
44+
}
45+
2646
render() {
2747
const {
28-
className, icon, iconType, iconSize, ...rest
48+
className,
49+
icon,
50+
iconType,
51+
iconSize,
52+
onChange,
53+
valueChange,
54+
...rest
2955
} = this.props;
3056

3157
if (icon) {
3258
return (
3359
<div className={classnames(styles.inputGroup, className)}>
3460
<Icon name={icon} type={iconType} size={iconSize} />
35-
<input className={styles.input} {...rest} />
61+
<input className={styles.input} onChange={this.onChange} {...rest} />
3662
</div>
3763
);
3864
}
3965

40-
return <input className={classnames(styles.input, className)} {...rest} />;
66+
return (
67+
<input
68+
className={classnames(styles.input, className)}
69+
onChange={this.onChange}
70+
{...rest}
71+
/>
72+
);
4173
}
4274
}

src/components/Base/Link/index.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Link } from 'react-router-dom';
4+
import { translate } from 'react-i18next';
5+
6+
import links from 'config/doc-link';
7+
8+
@translate()
9+
export default class Loading extends Component {
10+
static propTypes = {
11+
children: PropTypes.node,
12+
className: PropTypes.string,
13+
to: PropTypes.string,
14+
type: PropTypes.string
15+
};
16+
17+
static defaultProps = {
18+
children: null,
19+
className: '',
20+
type: ''
21+
};
22+
23+
render() {
24+
const {
25+
t, to, type, children, className
26+
} = this.props;
27+
let text = t(`LINK_${type}`);
28+
const linkTo = to || links[type];
29+
if (text === `LINK_${type}`) {
30+
text = linkTo;
31+
}
32+
if (children) {
33+
text = children;
34+
}
35+
if (!text) {
36+
return null;
37+
}
38+
if (!linkTo) {
39+
console.error(
40+
"You should edit a link url in the file of 'config/doc-links'"
41+
);
42+
}
43+
44+
return (
45+
<Link className={className} to={linkTo}>
46+
{text}
47+
</Link>
48+
);
49+
}
50+
}

src/components/Base/Upload/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class Upload extends Component {
4040

4141
state = {
4242
uid: getUid(),
43-
isDraging: true
43+
isDraging: false
4444
};
4545

4646
componentDidMount() {

src/components/Base/Upload/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
cursor: not-allowed;
99
pointer-events: none;
1010
}
11+
&.upload-dragover {
12+
opacity: 0.3;
13+
box-shadow: 0 1px 4px 0 rgba(73, 33, 173, 0.06), 0 4px 8px 0 rgba(35, 35, 36, 0.04);
14+
}
1115
}
1216
}

src/components/Base/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export Timeline from './Timeline';
1616
export Tooltip from './Tooltip';
1717
export Image from './Image';
1818
export Upload from './Upload';
19+
export Link from './Link';
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import classnames from 'classnames';
4+
import { translate } from 'react-i18next';
5+
import { noop } from 'lodash';
6+
7+
import { Link } from 'react-router-dom';
8+
import { Icon, Button, Input } from 'components/Base';
9+
10+
import styles from './index.scss';
11+
12+
@translate()
13+
export default class HeaderDashboard extends Component {
14+
static propTypes = {
15+
className: PropTypes.string,
16+
isFixed: PropTypes.bool,
17+
name: PropTypes.string,
18+
noSearchBox: PropTypes.bool,
19+
placeholder: PropTypes.string,
20+
store: PropTypes.shape({
21+
searchWord: PropTypes.string,
22+
onClear: PropTypes.func,
23+
onSearch: PropTypes.func
24+
}),
25+
withCreateBtn: PropTypes.shape({
26+
linkTo: PropTypes.string,
27+
onClick: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
28+
})
29+
};
30+
31+
static defaultProps = {
32+
className: '',
33+
name: '',
34+
isFixed: false,
35+
store: {
36+
searchWord: '',
37+
onSearch: noop,
38+
onClear: noop
39+
},
40+
placeholder: '',
41+
inputMaxLen: 50,
42+
withCreateBtn: {
43+
linkTo: '',
44+
onClick: ''
45+
},
46+
noSearchBox: false
47+
};
48+
49+
render() {
50+
const {
51+
className,
52+
isFixed,
53+
name,
54+
store,
55+
placeholder,
56+
inputMaxLen,
57+
withCreateBtn,
58+
noSearchBox,
59+
t
60+
} = this.props;
61+
const { onSearch, onClear, searchWord } = store;
62+
63+
return (
64+
<div
65+
className={classnames(className, styles.header, {
66+
[styles.fixedHeader]: isFixed
67+
})}
68+
>
69+
<div className={styles.name}>{name}</div>
70+
{!noSearchBox && (
71+
<Input.Search
72+
className={styles.search}
73+
placeholder={placeholder}
74+
value={searchWord}
75+
onSearch={onSearch}
76+
onClear={onClear}
77+
maxLength={inputMaxLen}
78+
/>
79+
)}
80+
{withCreateBtn.linkTo && (
81+
<Link to={withCreateBtn.linkTo}>
82+
<Button className={styles.btnCreate} type="primary">
83+
<Icon name="add" size={20} type="white" />
84+
<span className={styles.btnText}>
85+
{' '}
86+
{withCreateBtn.name || t('Create')}{' '}
87+
</span>
88+
</Button>
89+
</Link>
90+
)}
91+
{withCreateBtn.onClick && (
92+
<Button
93+
className={styles.btnCreate}
94+
type="primary"
95+
onClick={withCreateBtn.onClick}
96+
>
97+
<Icon name="add" size={20} type="white" />
98+
<span className={styles.btnText}>
99+
{' '}
100+
{withCreateBtn.name || t('Create')}{' '}
101+
</span>
102+
</Button>
103+
)}
104+
</div>
105+
);
106+
}
107+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@import '~scss/vars';
2+
3+
.header {
4+
display: flex;
5+
padding: 0 20px;
6+
height: 64px;
7+
background: $N0;
8+
align-items: center;
9+
10+
.name {
11+
flex: 1;
12+
}
13+
14+
.search {
15+
width: 232px;
16+
margin-right: 12px;
17+
}
18+
19+
.btnCreate {
20+
display: flex;
21+
justify-content: center;
22+
align-items: center;
23+
}
24+
25+
:global {
26+
.icon {
27+
margin-right: 4px;
28+
}
29+
}
30+
}
31+
.header.fixedHeader {
32+
position: fixed;
33+
top: 0;
34+
left: 60px;
35+
right: 0;
36+
37+
z-index: 10;
38+
}

src/components/Dashboard/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export Header from './Header';

0 commit comments

Comments
 (0)