Skip to content

Commit 6b83da8

Browse files
committed
update compontent styles
1 parent 46bbc41 commit 6b83da8

12 files changed

Lines changed: 262 additions & 166 deletions

‎src/components/SearchBar.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default class SearchBar extends React.Component {
107107
<Input ref={this.input}
108108
className={`search-bar__input${this.props.variableList.length ? ' search-bar__input--dark' : ''}`}
109109
icon fluid placeholder={this.props.placeholder} size={this.state.inputSize}>
110-
<Dropdown text='' icon='filter' className='search-bar__dropdown'>
110+
<Dropdown floating text='' icon='filter' className='search-bar__dropdown'>
111111
<Dropdown.Menu>
112112
<Dropdown.Item icon='undo' text='All 90 Languages (Reset)' onClick={this.handleRestLang}/>
113113
<Dropdown.Menu scrolling>

‎src/components/Sourcecode.js‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from 'react';
2+
import {Modal, Button, Dropdown, Label} from 'semantic-ui-react';
3+
import * as Tools from '../utils/Tools';
4+
5+
export default class Sourcecode extends React.Component {
6+
7+
constructor(props) {
8+
super(props);
9+
}
10+
11+
render() {
12+
return (
13+
<Modal defaultOpen={this.props.sourcecodeVisible} centered={false} closeIcon className='sourcecode'>
14+
<Modal.Header>
15+
<Dropdown floating labeled button blurring text='Matched results' className='mini icon'>
16+
<Dropdown.Menu>
17+
<Dropdown.Menu scrolling>
18+
<Dropdown.Item>
19+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
20+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
21+
</Dropdown.Item>
22+
<Dropdown.Item>
23+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
24+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
25+
</Dropdown.Item>
26+
<Dropdown.Item>
27+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
28+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
29+
</Dropdown.Item>
30+
<Dropdown.Item>
31+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
32+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
33+
</Dropdown.Item>
34+
<Dropdown.Item>
35+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
36+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
37+
</Dropdown.Item>
38+
<Dropdown.Item>
39+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
40+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
41+
</Dropdown.Item>
42+
<Dropdown.Item>
43+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
44+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
45+
</Dropdown.Item>
46+
<Dropdown.Item>
47+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
48+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
49+
</Dropdown.Item>
50+
<Dropdown.Item>
51+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
52+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
53+
</Dropdown.Item>
54+
<Dropdown.Item>
55+
<Button size='mini'>Codes</Button><Button size='mini'>Repo</Button>
56+
<Label size='mini' circular color={Tools.randomLabelColor()}>HTML</Label>
57+
</Dropdown.Item>
58+
</Dropdown.Menu>
59+
</Dropdown.Menu>
60+
</Dropdown>
61+
<Button size='mini'>Repo</Button>
62+
</Modal.Header>
63+
<Modal.Content image>
64+
<Modal.Description>
65+
<p>This is an example of expanded content that will cause the modal's dimmer to scroll</p>
66+
</Modal.Description>
67+
</Modal.Content>
68+
</Modal>
69+
)
70+
}
71+
}

‎src/containers/MainContainer.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import Donate from '../components/Donate';
1111
import NoticeLinks from '../components/NoticeLinks';
1212
import Suggestion from '../components/Suggestion';
1313
import NavBar from '../components/NavBar';
14+
import Sourcecode from '../components/Sourcecode';
1415

1516
export default class MainContainer extends React.Component {
1617
state = {
18+
sourcecodeVisible: false,
1719
isZH: false,
1820
isError: false,
1921
isSearchingVariable: false,
@@ -108,6 +110,7 @@ export default class MainContainer extends React.Component {
108110
{this.state.variableList.length ? <Donate {...this.state}/> : ''}
109111
<NoticeLinks/>
110112
<NavBar/>
113+
<Sourcecode {...this.state}/>
111114
</Container>
112115
)
113116
}

‎src/models/SearchcodeModel.js‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class SearchcodeModel extends BaseModel {
8989
(lineStr.match(reg) || []).forEach(val => {
9090
//remove "-" and "/" from the start and the end
9191
val = val.replace(/^(\-|\/)*/, '').replace(/(\-|\/)*$/, '');
92+
this._updateVariableRepoMapping(val, res);
9293
if (
9394
!/\//g.test(val) /*exclude links*/
9495
&& vals.indexOf(val) === -1
@@ -97,36 +98,45 @@ class SearchcodeModel extends BaseModel {
9798
&& val.length < 64 /*too long*/
9899
) {
99100
vals.push(val);
100-
this._updateVariableRepoMapping(val, res);
101101
//render variable labels
102102
variables.push({
103103
keyword: val,
104104
repo: res,
105-
repoLen: this._variableRepoMapping[val].length,
106105
color: Tools.randomLabelColor()
107106
});
108107
}
109108
});
110109
});
111110
});
112-
return variables;
111+
return variables.map(val => {
112+
val.repoLen = this._getVariableRepoMappingLength(val.keyword);
113+
return val;
114+
});
113115
}
114116

115117
_parseSuggestion(keywords, curr) {
116118
let suggestion = curr || this.suggestion;
117119
if (keywords) {
118120
suggestion = keywords.concat(suggestion);
119121
}
120-
return [...new Set(suggestion)].filter((item, i) => !this._isZH(item) && i < 12);
122+
return [...new Set(suggestion)].filter((item, i) => !this._isZH(item));
121123
}
122124

123125
_updateVariableRepoMapping(val, repo) {
124-
this._variableRepoMapping[val] = this._variableRepoMapping[val] || [];
125-
if (!this._variableRepoMapping[val].find(key => key.id === repo.id)) {
126-
this._variableRepoMapping[val].push(repo);
126+
if (!/\//g.test(val) /*exclude links*/ && val.length < 64 /*too long*/) {
127+
val = `__${val.toLowerCase()}`;
128+
this._variableRepoMapping[val] = this._variableRepoMapping[val] || [];
129+
if (!this._variableRepoMapping[val].find(key => key.id == repo.id)) {
130+
this._variableRepoMapping[val].push(repo);
131+
}
127132
}
128133
}
129134

135+
_getVariableRepoMappingLength(val) {
136+
val = `__${val.toLowerCase()}`;
137+
return this._variableRepoMapping[val].length;
138+
}
139+
130140
_isZH(val) {
131141
let isZH = false;
132142
val.replace(/\s+/ig, '+').split('+').forEach((key) => {

‎styles/_components.scss‎

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
1-
/*https://github.com/tobiasahlin/SpinKit*/
2-
/* start spinner */
3-
.spinner {
4-
animation: sk-rotateplane 1.2s infinite cubic-bezier(0.4, 0, 0.2, 1);
5-
}
6-
7-
@-webkit-keyframes sk-rotateplane {
8-
0% {
9-
-webkit-transform: perspective(120px);
10-
}
11-
12-
50% {
13-
-webkit-transform: perspective(120px) rotateY(180deg);
14-
}
15-
16-
100% {
17-
-webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg);
18-
}
19-
}
20-
21-
22-
@keyframes sk-rotateplane {
23-
0% {
24-
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
25-
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
26-
}
27-
28-
50% {
29-
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
30-
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
31-
}
32-
33-
100% {
34-
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
35-
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
36-
}
37-
}
38-
/*end spinner*/
39-
.logo {
40-
margin: 1rem auto;
41-
width: 3rem;
42-
height: 3rem;
43-
44-
img {
45-
display: inherit;
46-
width: 100%;
47-
height: 100%;
48-
border-radius: 20%;
49-
}
50-
}
1+
@import "spinner";
2+
@import "logo";
3+
@import "donate";
4+
@import "nav-bar";
5+
@import "notice-links";
6+
@import "sourcecode";

‎styles/_donate.scss‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.donate {
2+
padding: 2rem 0;
3+
text-align: center;
4+
5+
form {
6+
display: inline-block;
7+
}
8+
9+
.hd {
10+
padding-bottom: .8rem;
11+
text-align: center;
12+
}
13+
14+
.bd {
15+
display: flex;
16+
flex-direction: row;
17+
align-items: center;
18+
}
19+
20+
.zhifubao,
21+
.wechatpay,
22+
.paypal {
23+
margin: 0 0.5rem;
24+
width: 5rem;
25+
background: #fff;
26+
border-radius: 0.1rem;
27+
}
28+
}

‎styles/_logo.scss‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.logo {
2+
margin: 1rem auto;
3+
width: 3rem;
4+
height: 3rem;
5+
6+
img {
7+
display: inherit;
8+
width: 100%;
9+
height: 100%;
10+
border-radius: 20%;
11+
}
12+
}

‎styles/_main-containers.scss‎

Lines changed: 2 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@
119119
display: flex;
120120
justify-content: center;
121121
align-items: center;
122-
margin-top: -0.6rem;
122+
margin-top: -0.4rem;
123123
margin-left: 1rem;
124124

125125
i {
126126
opacity: 0.5;
127-
127+
font-size: 1.2rem;
128128
&:hover {
129129
opacity: 1;
130130
}
@@ -195,110 +195,4 @@
195195
height: auto;
196196
}
197197
}
198-
199-
.donate {
200-
padding: 2rem 0;
201-
text-align: center;
202-
203-
form {
204-
display: inline-block;
205-
}
206-
207-
.hd {
208-
padding-bottom: .8rem;
209-
text-align: center;
210-
}
211-
212-
.bd {
213-
display: flex;
214-
flex-direction: row;
215-
align-items: center;
216-
}
217-
218-
.zhifubao,
219-
.wechatpay,
220-
.paypal {
221-
margin: 0 0.5rem;
222-
width: 5rem;
223-
background: #fff;
224-
border-radius: 0.1rem;
225-
}
226-
}
227-
228-
.notice-links {
229-
position: fixed;
230-
bottom: 0;
231-
left: 0;
232-
width: 100%;
233-
padding-bottom: 1.5rem;
234-
padding-top: 0.5rem;
235-
text-align: center;
236-
transition: background-color $anim-default-time ease-in-out;
237-
@at-root {
238-
body.dark .notice-links {
239-
background: $dark;
240-
}
241-
}
242-
a {
243-
display: none;
244-
color: #70B7FD;
245-
&.show {
246-
display: block;
247-
}
248-
}
249-
}
250-
.nav-bar{
251-
position: absolute;
252-
top: -0.55rem;;
253-
right: 0;
254-
z-index: 10;
255-
display: inline-block;
256-
transition: all 1s;
257-
>*{
258-
float: left;
259-
display: inline-block;
260-
cursor: pointer;
261-
margin-right: 0.4rem;
262-
}
263-
&:last-child{
264-
margin-right: 0;
265-
}
266-
i{
267-
width: auto;
268-
height: auto;
269-
margin: 0 !important;
270-
font-size: 2rem;
271-
color: #70B7FD;
272-
&:hover,&:active{
273-
color: #59AAF9;
274-
}
275-
}
276-
.github-corner {
277-
margin-top: -0.2rem;
278-
i {
279-
font-size: 2.3rem;
280-
}
281-
}
282-
@media screen and (min-width: 800px) {
283-
i{
284-
width: auto;
285-
height: 3.4rem;
286-
font-size: 3rem;
287-
}
288-
.github-corner {
289-
margin-top: -0.2rem;
290-
i {
291-
font-size: 3.3rem;
292-
}
293-
}
294-
}
295-
$anim-delay: 150ms;
296-
$anim-duration: 500ms;
297-
@for $i from 1 through 5 {
298-
>*:nth-child(#{$i}) {
299-
animation-duration: $anim-duration;
300-
animation-delay: 500 + $anim-delay*($i - 1);
301-
}
302-
}
303-
}
304198
}

0 commit comments

Comments
 (0)