Skip to content

Commit 7b1b09d

Browse files
committed
add notice, suggestion, plugin links, donate
1 parent f1e0b95 commit 7b1b09d

14 files changed

Lines changed: 304 additions & 88 deletions

‎.eslintrc.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ module.exports = {
77
'no-unused-vars': [2, {'vars': 'all', 'args': 'none'}],
88
'no-empty': [0],
99
'react/prop-types': [0],
10-
'react/no-unescaped-entities': [0]
10+
'react/no-unescaped-entities': [0],
11+
'no-useless-escape': [0],
12+
'no-control-regex': [0]
1113
},
1214
'env': {
1315
'es6': true,

‎package.json‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
"dist": "NODE_ENV=production gulp build && gulp dist"
1717
},
1818
"devDependencies": {
19-
"@babel/core": "^7.1.2",
20-
"@babel/plugin-proposal-class-properties": "^7.1.0",
21-
"@babel/preset-env": "^7.1.0",
19+
"@babel/core": "^7.2.2",
20+
"@babel/plugin-proposal-class-properties": "^7.2.3",
21+
"@babel/preset-env": "^7.2.3",
2222
"@babel/preset-react": "^7.0.0",
2323
"ansi-colors": "^2.0.5",
2424
"babel-eslint": "^8.2.6",
2525
"babel-loader": "^8.0.4",
2626
"browser-sync": "^2.26.3",
27-
"css-loader": "^1.0.0",
28-
"cssnano": "^4.1.4",
27+
"css-loader": "^1.0.1",
28+
"cssnano": "^4.1.7",
2929
"del": "^3.0.0",
30-
"eslint": "^5.7.0",
30+
"eslint": "^5.10.0",
3131
"eslint-plugin-react": "^7.10.0",
32-
"fancy-log": "^1.3.2",
32+
"fancy-log": "^1.3.3",
3333
"gulp": "^3.9.1",
3434
"gulp-autoprefixer": "^5.0.0",
3535
"gulp-cachebust": "0.0.10",
@@ -49,28 +49,31 @@
4949
"gulp-watch": "^5.0.1",
5050
"imagemin-pngquant": "^6.0.0",
5151
"minimist": "^1.2.0",
52-
"node-sass": "^4.9.4",
52+
"node-sass": "^4.11.0",
5353
"plugin-error": "^1.0.1",
54-
"require-dir": "^1.1.0",
54+
"require-dir": "^1.2.0",
5555
"run-sequence": "^2.2.1",
5656
"sass-loader": "^7.1.0",
5757
"serve-index": "^1.9.1",
58-
"webpack": "^4.20.2",
58+
"webpack": "^4.28.1",
5959
"webpack-cli": "^3.1.2",
60-
"webpack-dev-server": "^3.1.9",
60+
"webpack-dev-server": "^3.1.10",
6161
"webpack-hot-middleware": "^2.24.3",
62-
"webpack-merge": "^4.1.4"
62+
"webpack-merge": "^4.1.5"
6363
},
6464
"dependencies": {
65-
"@babel/polyfill": "^7.0.0",
65+
"@babel/polyfill": "^7.2.3",
6666
"animate.css": "^3.7.0",
67-
"clipboard": "^2.0.4",
6867
"events": "^3.0.0",
69-
"react": "^16.5.2",
70-
"react-dom": "^16.5.2",
68+
"file-saver": "^2.0.0",
69+
"lodash": "^4.17.11",
70+
"nprogress": "^0.2.0",
71+
"react": "^16.7.0",
72+
"react-dom": "^16.7.0",
7173
"react-router-dom": "^4.3.1",
7274
"semantic-ui-css": "^2.4.1",
7375
"semantic-ui-react": "^0.82.5",
76+
"clipboard": "^2.0.4",
7477
"whatwg-fetch": "^3.0.0"
7578
}
7679
}

‎src/components/Donate.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
3+
export default class Donate extends React.Component {
4+
5+
constructor(props) {
6+
super(props);
7+
}
8+
9+
render() {
10+
let text = <h4 className='lang'>Buy <a href='https://twitter.com/unbug' rel='noopener noreferrer' target='_blank'>@unbug</a> a drink</h4>;
11+
if (this.props.isZH) {
12+
text = <h4 className='lang cn'>赞助 <a href='https://weibo.com/unbug/' rel='noopener noreferrer' target='_blank'>@听奏</a> 这个月的房租</h4>;
13+
}
14+
return (
15+
<div className='donate'>
16+
<div className='hd'>{text}</div>
17+
<div className='bd'>
18+
<img src='images/wechatpay.jpg' className='wechatpay' title='微信付款'/>
19+
<img src='images/zhifubao.png' className='zhifubao' title='支付宝转账'/>
20+
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>
21+
<input type='hidden' name='cmd' value='_s-xclick'/>
22+
<input type='hidden' name='hosted_button_id' value='43H7K8PWR4VV4'/>
23+
<input type='image' className='paypal' src='images/paypal.png' border='0' name='submit'
24+
title='Paypal'/>
25+
</form>
26+
</div>
27+
</div>
28+
)
29+
}
30+
}

‎src/components/NoticeLinks.js‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react';
2+
import {Icon} from 'semantic-ui-react';
3+
4+
export default class NoticeLinks extends React.Component {
5+
6+
list = React.createRef();
7+
active = 1;
8+
constructor(props) {
9+
super(props);
10+
}
11+
12+
componentDidMount() {
13+
setInterval(() => this.renderItem(this.list.current.children), 5000);
14+
}
15+
16+
renderItem(list) {
17+
Array.prototype.forEach.call(list, (item, i) => {
18+
if (i === this.active) {
19+
item.classList.add('show');
20+
} else {
21+
item.classList.remove('show');
22+
}
23+
});
24+
this.active++;
25+
if (this.active >= list.length) {
26+
this.active = 0;
27+
}
28+
}
29+
30+
render() {
31+
return (
32+
<div className='notice-links' ref={this.list}>
33+
<a className='animated fadeIn show' target='_blank' rel='noopener noreferrer'
34+
href='https://github.com/unbug/snts'>
35+
<Icon name='heart'/> SAY NO TO SUICIDE PUBLIC LICENSE
36+
</a>
37+
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer' href='//mihtool.com/'>
38+
<Icon name='code'/> [MIHTool] iOS 上调试和优化页面的工具
39+
</a>
40+
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer' href='https://www.wasmrocks.com/'>
41+
<Icon name='hand rock'/> WebAssembly Rocks
42+
</a>
43+
<a className='animated fadeIn' target='_blank' rel='noopener noreferrer'
44+
href='https://www.gitbook.com/book/unbug/react-native-training/details'>
45+
<Icon name='video'/> [开源] React Native 开发培训资料和视频
46+
</a>
47+
</div>
48+
)
49+
}
50+
}

‎src/components/SearchBar.js‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {Dropdown, Icon, Input, Checkbox} from 'semantic-ui-react';
2+
import {Dropdown, Icon, Input} from 'semantic-ui-react';
33

44
// http://githut.info/
55
const topProgramLan = [
@@ -28,8 +28,6 @@ const topProgramLan = [
2828
{id: 42, language: 'ActionScript'}
2929
];
3030

31-
32-
3331
export default class SearchBar extends React.Component {
3432
input = React.createRef();
3533
select = React.createRef();
@@ -124,7 +122,16 @@ export default class SearchBar extends React.Component {
124122
<Icon name={this.props.variableList.length ? 'search plus' : 'search'}
125123
link onClick={() => this.handleSearch()}/>
126124
</Input>
127-
<div className='search-bar__helper'>
125+
<div className='search-bar__plugins'>
126+
<Icon name='plug'/>For:&nbsp;
127+
<a href='https://github.com/unbug/codelf#codelf-for-vs-code'
128+
target='_blank' rel='noopener noreferrer'>VS Code</a>,&nbsp;
129+
<a className='text-muted' href='https://atom.io/packages/codelf'
130+
target='_blank' rel='noopener noreferrer'>Atom</a>,&nbsp;
131+
<a className='text-muted' href='https://github.com/unbug/codelf#codelf-for-sublime-text'
132+
target='_blank' rel='noopener noreferrer'>Sublime Text</a>,&nbsp;
133+
<a href='https://chrome.google.com/webstore/detail/codelf-best-github-stars/jnmjaglhmmcplekpfnblniiammmdpaan'
134+
target='_blank' rel='noopener noreferrer'>Chrome</a>
128135
</div>
129136
</div>
130137
)

‎src/components/SearchError.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class SearchError extends React.Component {
99
render() {
1010
return (
1111
<div className='search-error'>
12-
<div>Nothing found, please come back later, or try <Label>Suggestions</Label> :)</div>
12+
<div>Nothing found, please try <Label color='grey' size='mini'>Quick Search</Label> or come back later :)</div>
1313
</div>
1414
);
1515
}

‎src/components/Suggestion.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import {Label} from 'semantic-ui-react';
3+
4+
export default class Suggestion extends React.Component {
5+
6+
constructor(props) {
7+
super(props);
8+
}
9+
10+
render() {
11+
if (!this.props.suggestion || !this.props.suggestion.length) { return null; }
12+
const list = this.props.suggestion.map((item, i) => {
13+
return <Label key={i} circular size='mini' color='grey' as='a' href={`#${item}`}>{item}</Label>
14+
});
15+
return (
16+
<div className='suggestion'>
17+
<Label color='grey' size='mini'>Quick Search:</Label> {list}
18+
</div>
19+
)
20+
}
21+
}

‎src/components/VariableList.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Variable extends React.Component {
4949
export default class VariableList extends React.Component {
5050

5151
lastPageLen = 0;
52+
animationName = Math.random() > 0.5 ? 'zoomInDown' : 'zoomInUp';
5253

5354
constructor(props) {
5455
super(props);
@@ -60,15 +61,14 @@ export default class VariableList extends React.Component {
6061
const pageLen = this.props.variableList.length;
6162
this.props.variableList.forEach((list, i) => {
6263
const isLast = i === pageLen - 1 && this.lastPageLen != pageLen;
63-
const variables = list.map(variable => {
64-
let style = {}, className = '';
64+
const variables = list.map((variable, j) => {
65+
let style = {}, className = '', duration = (list.length - j) / list.length;
6566
if (isLast) {
6667
className = 'animated';
6768
style = {
68-
opacity: 0,
69-
animationName: 'fadeIn',
70-
animationDelay: 0.1 + Math.random() + 's',
71-
animationDuration: 0.35 + Math.random() + 's'
69+
animationName: this.animationName,
70+
animationDelay: duration + 's',
71+
animationDuration: duration + Math.random() + 's'
7272
};
7373
}
7474
return <Variable key={Tools.uuid()} {...variable} {...this.props} style={style} className={className}/>

‎src/containers/MainContainer.js‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ import HashHandler from '../utils/HashHandler';
77
import VariableList from '../components/VariableList';
88
import SearchError from '../components/SearchError';
99
import Loading from '../components/Loading';
10+
import Donate from "../components/Donate";
11+
import NoticeLinks from "../components/NoticeLinks";
12+
import Suggestion from "../components/Suggestion";
1013

1114
export default class MainContainer extends React.Component {
1215
state = {
16+
isZH: false,
1317
isError: false,
1418
isSearchingVariable: false,
1519
searchValue: SearchcodeModel.searchValue,
1620
searchLang: SearchcodeModel.searchLang,
1721
page: SearchcodeModel.page,
18-
variableList: SearchcodeModel.variableList
22+
variableList: SearchcodeModel.variableList,
23+
suggestion: SearchcodeModel.suggestion
1924
}
2025

2126
constructor(props) {
@@ -40,12 +45,14 @@ export default class MainContainer extends React.Component {
4045

4146
handleSearchcodeModelUpdate = (curr, prev, mutation) => {
4247
this.setState({
48+
isZH: SearchcodeModel.isZH || this.state.isZH,
4349
isError: this.checkError(curr),
4450
isSearchingVariable: !mutation.variableList,
4551
searchValue: SearchcodeModel.searchValue,
4652
searchLang: SearchcodeModel.searchLang,
4753
page: SearchcodeModel.page,
48-
variableList: SearchcodeModel.variableList
54+
variableList: SearchcodeModel.variableList,
55+
suggestion: SearchcodeModel.suggestion
4956
});
5057
}
5158

@@ -76,24 +83,29 @@ export default class MainContainer extends React.Component {
7683
let page = this.state.page;
7784
if (val === this.state.searchValue) {
7885
page += 1;
86+
} else {
87+
page = 0;
7988
}
8089
this.setState({searchValue: val, isSearchingVariable: true});
8190
SearchcodeModel.requestVariable(val, page, lang || this.state.searchLang);
8291
}
8392

84-
renderDefault() {
93+
renderSloganImage() {
8594
if (this.state.page > 0 || this.state.variableList.length) { return ''; }
86-
return <div className='default'><img src="images/twohardtings.jpg"/></div>;
95+
return <div className='slogan-image'><img src="images/twohardtings.jpg"/></div>;
8796
}
8897

8998
render() {
9099
return (
91100
<Container className='main'>
92101
<Title {...this.state}/>
93102
<SearchBar placeholder='AI 人工智能' {...this.state} onSearch={this.handleSearch}/>
103+
<Suggestion {...this.state}/>
94104
{this.state.isSearchingVariable ? <Loading/> : (this.state.isError ? <SearchError/> : '')}
95-
{this.renderDefault()}
105+
{this.renderSloganImage()}
96106
<VariableList {...this.state}/>
107+
{this.state.variableList.length ? <Donate {...this.state}/> : ''}
108+
<NoticeLinks/>
97109
</Container>
98110
)
99111
}

0 commit comments

Comments
 (0)