forked from unbug/codelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
2,641 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ docs/html | |
app/css | ||
app/js | ||
app/images | ||
app/fonts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import MainContainer from './containers/MainContainer'; | ||
|
||
class App extends React.Component { | ||
render() { | ||
return <MainContainer/> | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
<App name="App"/>, | ||
<MainContainer/>, | ||
document.querySelector('.app') | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import {Dropdown, Icon, Input} from 'semantic-ui-react'; | ||
|
||
export default class SearchBar extends React.Component { | ||
input = React.createRef(); | ||
select = React.createRef(); | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
type: 'title', | ||
prevProps: props | ||
} | ||
} | ||
|
||
static getDerivedStateFromProps(nextProps, prevState) { | ||
// avoid calculating expensive derived data | ||
if (prevState.prevProps === nextProps) { return null} | ||
let newState = { | ||
prevProps: nextProps // prevProps memoization | ||
} | ||
// derived state from props | ||
if (prevState.prevProps.searchType != nextProps.searchType) { | ||
newState.type = nextProps.searchType; | ||
} | ||
return newState; | ||
} | ||
|
||
handleSearch = () => { | ||
this.props.onSearch({ | ||
type: this.state.type, | ||
value: this.input.current.inputRef.value | ||
}); | ||
} | ||
|
||
handleTypeChange = (e, { value }) => this.setState({ type: value }); | ||
|
||
render() { | ||
return ( | ||
<div className='search-bar'> | ||
<div className='search-bar__desc'> | ||
Search over GitHub, Bitbucket, GitLab to find real-world usage variable names | ||
</div> | ||
<Input className='search-bar__input' | ||
icon fluid placeholder={this.props.placeholder} size={document.body.offsetWidth > 800 ? 'huge' : ''}> | ||
<Dropdown text='' icon='filter' className='search-bar__dropdown'> | ||
<Dropdown.Menu> | ||
<Dropdown.Item icon='undo' text='All 90 Languages (Reset)' /> | ||
<Dropdown.Menu scrolling> | ||
<Dropdown.Item text='Open...' description='ctrl + o' /> | ||
<Dropdown.Item text='Save as...' description='ctrl + s' /> | ||
<Dropdown.Item text='Rename' description='ctrl + r' /> | ||
<Dropdown.Item text='Make a copy' /> | ||
<Dropdown.Item icon='folder' text='Move to folder' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
<Dropdown.Item icon='trash' text='Move to trash' /> | ||
</Dropdown.Menu> | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
<input defaultValue={this.props.searchValue} | ||
onKeyPress={e => {e.key === 'Enter' && this.handleSearch()}}/> | ||
<Icon name='search' link onClick={() => this.handleSearch()}/> | ||
</Input> | ||
<div className='search-bar__helper'> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
export default class Title extends React.Component { | ||
|
||
render() { | ||
return ( | ||
<header className='title animated'> | ||
<h1><a href="./"><span>C</span><span>O</span><span>D</span><span>E</span><span>L</span><span>F</span></a></h1> | ||
</header> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import {Dropdown, Icon, Input } from 'semantic-ui-react'; | ||
|
||
export default class VariableList extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className='search-bar'> | ||
|
||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import React from 'react'; | ||
import Button from '../components/Button' | ||
import {Container} from 'semantic-ui-react'; | ||
import SearchBar from '../components/SearchBar'; | ||
import Title from '../components/Title'; | ||
|
||
export default class MainContainer extends React.Component { | ||
state = { | ||
searchValue: null, | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
if (this.props.location !== prevProps.location) { | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
document.body.classList.add('dark') | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<div>Hello World!</div> | ||
<Button name="click me!"/> | ||
</div> | ||
<Container className='main'> | ||
<Title {...this.state}/> | ||
<SearchBar placeholder='AI 人工智能' {...this.state}/> | ||
</Container> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import EventEmitter from 'events'; | ||
|
||
class Mutation { | ||
constructor(data) { | ||
this._data = data; | ||
this._serialize(); | ||
this.has = this.has.bind(this); | ||
} | ||
|
||
_serialize() { | ||
Object.keys(this._data).forEach(key => { | ||
this[key] = true; | ||
}); | ||
} | ||
|
||
get() { | ||
return this._data; | ||
} | ||
|
||
has(fields) { | ||
if (/string/i.test(typeof fields)) { | ||
fields = fields.split(','); | ||
} | ||
if (Array.isArray(fields)) { | ||
return fields.every((key) => { | ||
key = key.trim(); | ||
return this[key]; | ||
}); | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
class BaseModel extends EventEmitter { | ||
constructor() { | ||
super(); | ||
this.on('error', () => {}); | ||
this.setMaxListeners(99); | ||
this._updateEventName = 'update'; | ||
this._data = {}; | ||
} | ||
|
||
set(data) { | ||
let prevData = Object.assign({}, this._data); | ||
this._data = data || {}; | ||
this.notify(prevData, Object.assign({}, prevData, data, {isReset: true})); | ||
} | ||
|
||
get() { | ||
return this._data; | ||
} | ||
|
||
create(data) { | ||
let instance = Object.create(Object.getPrototypeOf(this)); | ||
instance._data = data; | ||
return instance; | ||
} | ||
|
||
notify(prevData, mutationData) { | ||
let data = Object.assign({}, this._data); | ||
this.emit(this._updateEventName, data, prevData || data, new Mutation(mutationData)); | ||
} | ||
|
||
update(data) { | ||
let prevData = Object.assign({}, this._data); | ||
Object.assign(this._data, data); | ||
this.notify(prevData, data); | ||
} | ||
|
||
onUpdated(listener) { | ||
this.on(this._updateEventName, listener); | ||
} | ||
|
||
offUpdated(listener) { | ||
this.removeListener(this._updateEventName, listener); | ||
} | ||
} | ||
|
||
export default BaseModel; |
Oops, something went wrong.