Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 2f0d7b3

Browse files
committed
fix online locale switch & add loading in search
1 parent 2383871 commit 2f0d7b3

File tree

20 files changed

+275
-194
lines changed

20 files changed

+275
-194
lines changed

README.md

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,6 @@
2626
</div>
2727

2828

29-
30-
## GraphQL tools
31-
[apollo-fetch](https://github.com/apollographql/apollo-fetch)
32-
[graphql-request](https://github.com/graphcool/graphql-request)
33-
[组织结构参考](https://github.com/apollographql/GitHunt-React/blob/4bbba0416c666768b375e65221236a736e50e942/ui/graphql/Comment.graphql)
34-
35-
36-
## PostgreSQL
37-
[查询客户端 franchise](https://github.com/HVF/franchise)
38-
39-
## packages
40-
[markjs](https://markjs.io/)
41-
[markdown-it](https://markdown-it.github.io/)
42-
[Autolinker](https://github.com/gregjacobs/Autolinker.js)
43-
44-
## issues
45-
next.config.js 如果导出不存在的页面可能会使 build 过程出现奇怪的错误, 如
46-
polished 报错. 只导出需要的页面
47-
4829
## Feature
4930

5031
- [x] server-side-render out of the box, power by next.js
@@ -57,142 +38,3 @@
5738
- [x] enjoyable dev experience by using modern web tools
5839
- [ ] email subscribe like [FE/Weekly](http://www.feweekly.com/) for each language?
5940

60-
## TODO
61-
62-
- [ ] phoenix [新文档地址](https://github.com/phoenixframework/phoenix/tree/master/guides/docs)
63-
- [ ] 使用 Github Rest/GraphQl api 摸索数据层方案
64-
- [ ] Search panel && login panel ----> 或许应该叫 UnverisalPanel ? --> 可以呼出
65-
debug 设置等等
66-
- [ ] [主页弄给](https://github.com/Sly777/ran)
67-
- [ ] add export config docs [see this](https://zhuanlan.zhihu.com/p/27847307)
68-
- [ ] test --> tests
69-
- [ ] add theme checker maybe? -> https://github.com/styled-components/stylelint-processor-styled-components
70-
- [ ] add page generator
71-
- [ ] remove the clock page
72-
- [ ] use bundlesize in Ci . [here](https://github.com/siddharthkp/bundlesize)
73-
- [ ] [react-loadable](https://github.com/thejameskyle/react-loadable)
74-
- [ ] *test Preact in production*
75-
- [ ] docs introduction / file-structure / theme / debug / generator / testing ... see [this](https://github.com/react-boilerplate/react-boilerplate/tree/master/docs)
76-
- [ ] launch first version with changeLog staff
77-
- [ ] and answer [this issue](https://github.com/samuelalvin/react-mobx-mobxstatetree)
78-
- [ ] [防嵌套网页](https://segmentfault.com/a/1190000004502619)
79-
- [ ] [devdocs 的离线缓存怎么做的?](https://devdocs.io/) 弄一个呗
80-
- [x] logic.js generator (only for containers)
81-
- [x] add github example using Rx.js as request lib, GraphQL if time free
82-
- [x] add Ramada example && [bebel-plugin](https://github.com/megawac/babel-plugin-ramda)
83-
- [x] Badges ( CI build / deps / coveralls / greenkeeper)
84-
- [x] prettier config
85-
- [x] styled-component example / polish
86-
- [x] prettier/lint before commit
87-
- [x] gzip: use a CDN to serve statics
88-
- [x] plop template
89-
- [x] change dir stucture for more easy test/code
90-
- [x] intl: rename messages file to lang
91-
- [x] remove the typescript support
92-
- [x] mobx-state-tree by move the shop example
93-
- [x] generator for container and store/
94-
- [x] Jest && Jest as 'cover tool'
95-
- [x] make test a individual dir
96-
- [x] debug pkg
97-
- [x] add global-css ([normalize.css](https://github.com/necolas/normalize.css))
98-
- [x] *design data layer*: [基于 RxJs 的前端数据层实践](https://juejin.im/post/59a7d6d06fb9a0247804f2aa)
99-
- [x] add Menu
100-
- [x] 使用各国标志性的建筑作为 i18n 切换图标
101-
102-
103-
### MindStorm
104-
105-
- [ ] [参考构建桌面版本](https://github.com/egoist/devdocs-desktop)
106-
- [ ] 同色系的彩虹标签?
107-
- [ ] [桌面效果的网站, 有新意](http://jasonpark.me/)
108-
- [ ] [用 monaco-editor实现一个 postman](https://github.com/Microsoft/monaco-editor)
109-
- [ ] [monaco-editor 的 diff-editor 实现协作编辑? 文档的 wiki 化?](https://github.com/Microsoft/monaco-editor)
110-
- [ ] [react-diagrams](https://github.com/projectstorm/react-diagrams)
111-
112-
113-
### tools
114-
#### [git commit emoji](https://github.com/liuchengxu/git-commit-emoji-cn)
115-
#### [lozad.js](https://github.com/ApoorvSaxena/lozad.js)
116-
#### [一键分享](https://github.com/overtrue/share.js)
117-
#### [https://github.com/jawil/blog/issues/10](https://github.com/jawil/blog/issues/10)
118-
119-
### i18n
120-
121-
0. 修改创建组件的模板
122-
1. 初始加载使用浏览器默认语言 (通过: accept.language(['en', 'zh']), 见官方例子)
123-
2. 后续过程中如果前端 locale 手动改变,则单独请求 locale 文件 (server.js 需要单
124-
独的 locale 路由)
125-
3. build 的时候用 default-lang.js 脚本生成en/zh.json文件, messages 导出后 key/id 不能重复
126-
4. 逻辑合并到数据流
127-
128-
## ui
129-
[点击 page 隐藏菜单的思路](https://stackoverflow.com/questions/152975/how-do-i-detect-a-click-outside-an-element)
130-
[rx + fetch](https://github.com/Cmdv/React-RxJS/blob/836d20a09f66f94db4c3e2206b14b203bf8836a1/src/intent/json-intent.js)
131-
132-
## Roadmap
133-
134-
- [ ] shop example
135-
- [ ] Menu
136-
- [ ] animate, [animate-components](https://github.com/nitin42/animate-components/tree/master/packages/animate-keyframes)
137-
138-
139-
## issue
140-
141-
1. next export 不支持从特定目录导出,所以不能将 ts 的代码集中到一个目录
142-
2. stores 不使用 typescript , see [this issue](https://github.com/mobxjs/mobx-state-tree/issues/276)
143-
144-
145-
## Resources
146-
147-
### Ramada
148-
[Ramda 中文网](http://ramda.cn/) (简介部分有很多文章)
149-
[Ramda 函数库参考教程 -- 阮一峰](http://www.ruanyifeng.com/blog/2017/03/ramda.html)
150-
[Pointfree 编程风格指南](http://www.ruanyifeng.com/blog/2017/03/pointfree.html)
151-
[Thinking in Ramda: 函数组合 -> 投票的例子不错](https://adispring.coding.me/2017/06/10/Thinking-in-Ramda-Combining-Functions/) --
152-
R.and / R.or / R.complement 分别是函数版本的 and / or / !
153-
[Thinking in Ramda: 控制流](https://adispring.coding.me/2017/06/11/Thinking-in-Ramda-Declarative-Programming/)
154-
155-
[Thinking in Ramda: 重构的例子,涉及很多对象的操作例子](https://adispring.coding.me/2017/06/16/Thinking-in-Ramda-Immutability-and-Objects/) --
156-
evolve 太酷了.. 数组对应的是 adjust , 以及更通用的 lens 系列
157-
[Thinking in Ramda: Lens](https://adispring.coding.me/2017/06/18/Thinking-in-Ramda-Lenses/)
158-
159-
160-
```js
161-
const lineWidth = settings.lineWidth || 80
162-
const lineWidth = defaultTo(80, settings.lineWidth)
163-
```
164-
165-
166-
### rx.js
167-
[interactive Rx](http://rxmarbles.com/)
168-
[categories-of-operators](http://reactivex.io/rxjs/manual/overview.html#categories-of-operators)
169-
[使用 RxJS 构造复杂单页应用的数据逻辑](https://github.com/xufei/blog/issues/38)
170-
[RxJS 入门指引和初步应用](https://github.com/xufei/blog/issues/44)
171-
[单页应用的数据流方案探索](https://github.com/xufei/blog/issues/47)
172-
[复杂单页应用的数据层设计](https://github.com/xufei/blog/issues/42)
173-
174-
### mobx
175-
[mobx-share (mobx 知识结构)](https://ckinmind.github.io/mobx-share/)
176-
177-
### jest
178-
[Running Jest Tests Before Each Git Commit](https://benmccormick.org/2017/02/26/running-jest-tests-before-each-git-commit/)
179-
180-
### styled-component
181-
[styled-component](https://www.styled-components.com/docs)
182-
183-
### example
184-
[react-typescript-samples](https://github.com/Lemoncode/react-typescript-samples)
185-
[typescript-react-mobx-template](https://github.com/dimafeng/typescript-react-mobx-template)
186-
187-
### js/css tips
188-
[小 tip:CSS vw让overflow:auto页面滚动条出现时不跳动](http://www.zhangxinxu.com/wordpress/2015/01/css-page-scrollbar-toggle-center-no-jumping/)
189-
[基于vw等viewport视区单位配合rem响应式排版和布局](http://www.zhangxinxu.com/wordpress/2016/08/vw-viewport-responsive-layout-typography/)
190-
[小tip:JS前端创建html或json文件并浏览器导出下载](http://www.zhangxinxu.com/wordpress/2017/07/js-text-string-download-as-html-json-file/)
191-
192-
193-
## talk idea
194-
0. 就像混泥土 -- 盖小房子随便配比 --- 但是改三峡大坝可就不行了
195-
1. [香港笼屋](https://www.zhihu.com/question/19757290)
196-
197-
198-

containers/Body/GithubRestExample.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { HorizontalCenter } from '../../components/BaseStyled'
88
const Home = () => {
99
return (
1010
<HorizontalCenter>
11-
<div>Huck</div>
1211
<UniversePanel />
1312
</HorizontalCenter>
1413
)

containers/Body/logic.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ export function changeLocale(lang) {
1515
// console.log('store.isLocaleExist: ', store.isLocaleExist(lang))
1616

1717
if (!store.isLocaleExist(lang)) {
18-
fetch(`/locale/${lang}`)
18+
debug('process.env.NODE_ENV:', process.env.NODE_ENV)
19+
const localeUrl =
20+
process.env.NODE_ENV === 'development'
21+
? `/locale/${lang}`
22+
: `/static/locales/${lang}.json`
23+
fetch(localeUrl)
1924
.then(res => res.json())
2025
.then(vals => {
21-
console.log('vals: ', vals)
2226
store.setLangMessages(lang, vals)
2327
store.changeLocale(lang)
2428
})

containers/Sidebar/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import Link from 'next/link'
99
import { inject, observer } from 'mobx-react'
1010

1111
// import styled from 'styled-components'
12-
import { FormattedMessage as I18n } from 'react-intl'
13-
import lang from './lang'
12+
// import { FormattedMessage as I18n } from 'react-intl'
13+
// import lang from './lang'
1414

1515
// import observer from '../../utils/mobx_utils'
1616

@@ -95,10 +95,6 @@ class SidebarContainer extends React.Component {
9595
pin={sidebar.pin}
9696
onClick={logic.pin}
9797
/>
98-
<I18n {...lang.title} />
99-
<div>
100-
<I18n {...lang.text} />
101-
</div>
10298
<br />
10399
<br />
104100
<br />

containers/UniversePanel/Modal.js

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
1-
import styled from 'styled-components'
1+
import styled, { keyframes } from 'styled-components'
22

33
import Img from '../../components/Img'
44

5+
import searchIcon from '../../static/search.svg'
6+
import loadingIcon from '../../static/loading.svg'
7+
8+
const rotate360 = keyframes`
9+
from {
10+
transform: rotate(0deg);
11+
}
12+
13+
to {
14+
transform: rotate(360deg);
15+
}
16+
`
17+
18+
export const SearchIcon = styled(searchIcon)`
19+
fill: #014354;
20+
width: 30px;
21+
height: 30px;
22+
margin-top: 20px;
23+
`
24+
25+
export const LoadingIcon = styled(loadingIcon)`
26+
fill: #014354;
27+
width: 30px;
28+
height: 30px;
29+
margin-top: 20px;
30+
animation: ${rotate360} 2s linear;
31+
`
32+
33+
export const AddOn = styled.div`
34+
margin-left: 15px;
35+
color: white;
36+
width: 25px;
37+
`
38+
539
// center css see: https://stackoverflow.com/questions/1776915/how-to-center-absolutely-positioned-element-in-div
640
// flex-grow example: http://zhoon.github.io/css3/2014/08/23/flex.html
741
export const PanelContainer = styled.div`
@@ -51,17 +85,6 @@ export const InfoBar = styled(BaseBar)`
5185
padding: 10px;
5286
min-height: 100px;
5387
`
54-
55-
export const AddOn = styled.div`
56-
transform: rotate(-45deg);
57-
font-size: 5vh;
58-
margin-left: 15px;
59-
color: #365760;
60-
margin-top: 5px;
61-
margin-top: 3px;
62-
width: 20px;
63-
`
64-
6588
export const InputBar = styled.input`
6689
caret-color: #365760; /*cursor color*/
6790
flex-grow: 1;

containers/UniversePanel/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
AvatarWrapper,
2727
ContentWraper,
2828
Title,
29+
SearchIcon,
30+
LoadingIcon,
2931
Desc,
3032
RepoLang,
3133
RepoStar,
@@ -38,14 +40,15 @@ const debug = makeDebugger('C:UniversePanel')
3840

3941
// const repoNotFound = R.and()
4042

41-
const SearchEditor = ({ value }) => (
43+
const SearchEditor = ({ value, searching }) => (
4244
<EditorBar>
43-
<AddOn>&#9906;</AddOn>
45+
<AddOn>{searching ? <LoadingIcon /> : <SearchIcon />}</AddOn>
4446
<InputBar
4547
spellCheck={false}
4648
autoCapitalize={false}
4749
autoCorrect="off"
4850
autoComplete="off"
51+
placeholder="Github repo search"
4952
value={value}
5053
onChange={logic.search}
5154
/>
@@ -65,15 +68,15 @@ class UniversePanelContainer extends React.Component {
6568

6669
render() {
6770
const store = this.props.store
68-
const { reposData, inputValue } = store
71+
const { reposData, inputValue, searching } = store
6972

7073
// debug('repos: ', repos)
7174
// debug('searching: ', searching)
7275
// debug('logic.repoNotFound2(store): ', logic.repoNotFound2(store))
7376

7477
return (
7578
<PanelContainer>
76-
<SearchEditor value={inputValue} />
79+
<SearchEditor value={inputValue} searching={searching} />
7780

7881
{logic.repoNotFound(store) && <AlertBar>Repo not found</AlertBar>}
7982

0 commit comments

Comments
 (0)