Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from mysticPrg/feature/neon
Feature/neon
- Loading branch information
Showing
29 changed files
with
744 additions
and
188 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"presets": [ | ||
"react-app" | ||
], | ||
"plugins": [ | ||
[ | ||
"babel-plugin-root-import", | ||
{ | ||
"rootPathSuffix": "./src/" | ||
} | ||
] | ||
] | ||
} |
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
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,33 @@ | ||
import React, { Component } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
export const Button = styled.button` | ||
font: 13px Arial; | ||
color: #00BCD4; | ||
background-color: rgba(0, 188, 212, 0.45); | ||
border: 1px solid #56ffd8; | ||
box-shadow: none; | ||
border: 1px solid #56ffd8; | ||
outline: none; | ||
border-radius: 5px; | ||
padding: 5px; | ||
margin: 7px; | ||
transition: box-shadow 0.3s; | ||
transition: background-color 0.3s; | ||
transition: color 0.3s; | ||
&:hover, &:focus { | ||
box-shadow: 0 0 18px 3px #00BCD4; | ||
background-color: rgba(0, 188, 212, 0.8); | ||
color: white; | ||
} | ||
&:active { | ||
box-shadow: 0 0 18px 3px white; | ||
transition: box-shadow 0.1s; | ||
color: #00BCD4; | ||
background-color: rgba(0, 188, 212, 0.45); | ||
} | ||
`; | ||
|
||
export default Button; |
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,33 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import Button from './Button'; | ||
import { getRandomString } from '~/utils/common'; | ||
|
||
describe('TextField', () => { | ||
it('should be render without crash', () => { | ||
expect(() => { | ||
shallow(<Button/>); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('should be initialized to the input value', () => { | ||
const inputValue = getRandomString(20); | ||
|
||
const target = shallow(<Button>{inputValue}</Button>); | ||
|
||
const value = target.find('button').text(); | ||
|
||
expect(value).toEqual(inputValue); | ||
}); | ||
|
||
it('should call the registered handler when the click event occurs', () => { | ||
const onClick = jasmine.createSpy(); | ||
|
||
const target = shallow(<Button onClick={onClick}/>); | ||
|
||
target.simulate('click'); | ||
|
||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
}); |
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, { Component } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
class UnstyledCheckBox extends Component { | ||
render() { | ||
return ( | ||
<label className={this.props.className}> | ||
<input type="checkbox"/> | ||
{this.props.children} | ||
</label> | ||
); | ||
} | ||
} | ||
|
||
export const CheckBox = styled(UnstyledCheckBox)` | ||
color: green; | ||
`; | ||
|
||
export default CheckBox; |
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'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import CheckBox from './CheckBox'; | ||
|
||
describe('CheckBox', () => { | ||
it('should be render without crash', () => { | ||
expect(() => { | ||
shallow(<CheckBox/>); | ||
}).not.toThrow(); | ||
}); | ||
}); |
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,44 @@ | ||
import React, { Component } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
/* | ||
ToDo | ||
1. use theme | ||
2. use rem (for flexible UI) | ||
*/ | ||
|
||
export const TextField = styled.input` | ||
margin: 7px; | ||
font: 13px Arial; | ||
order: 0; | ||
padding: 5px; | ||
display: block; | ||
color: #00BCD4; | ||
outline: none; | ||
border: 1px solid #56ffd8; | ||
background-color: transparent; | ||
box-shadow: none; | ||
transition: box-shadow 0.3s; | ||
border-radius: 5px; | ||
&:focus, &:hover { | ||
box-shadow: 0 0 18px 3px #00BCD4; | ||
} | ||
&:active { | ||
box-shadow: 0 0 18px 3px white; | ||
} | ||
&::placeholder { | ||
font: 13px Arial; | ||
color: rgba(0, 188, 212, 0.8); | ||
opacity: 1; | ||
transition: opacity 0.5s; | ||
} | ||
&:focus::placeholder { | ||
opacity: 0; | ||
} | ||
`; | ||
|
||
export default TextField; |
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,65 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
|
||
import TextField from './TextField'; | ||
import { getRandomString } from '~/utils/common'; | ||
|
||
describe('TextField', () => { | ||
it('should be render without crash', () => { | ||
expect(() => { | ||
shallow(<TextField/>); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it('should be initialized to the input value', () => { | ||
const inputValue = getRandomString(20); | ||
|
||
const target = mount( | ||
<TextField defaultValue={inputValue}></TextField> | ||
); | ||
|
||
const readData = target.find('input').get(0).value; | ||
expect(readData).toEqual(inputValue); | ||
}); | ||
|
||
it('should display the text when it is typed', () => { | ||
const value = getRandomString(20); | ||
const event = { | ||
target: { | ||
value | ||
} | ||
}; | ||
const onChange = jasmine.createSpy(); | ||
let input = null; | ||
|
||
const target = mount( | ||
<TextField | ||
innerRef={ref => input = ref} | ||
onChange={onChange} | ||
/> | ||
); | ||
|
||
target.simulate('change', event); | ||
expect(onChange.calls.first().args[0].target.value).toEqual(value); | ||
}); | ||
|
||
it('should call the registered handler when the focus event occurs', () => { | ||
const focusHandler = jasmine.createSpy(); | ||
const blurHandler = jasmine.createSpy(); | ||
|
||
const target = mount( | ||
<TextField | ||
onFocus={focusHandler} | ||
onBlur={blurHandler} | ||
/> | ||
); | ||
|
||
const input = target.find('input'); | ||
|
||
input.simulate('focus'); | ||
expect(focusHandler).toHaveBeenCalled(); | ||
|
||
input.simulate('blur'); | ||
expect(blurHandler).toHaveBeenCalled(); | ||
}); | ||
}); |
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,3 @@ | ||
export * from './TextField'; | ||
export * from './Button'; | ||
export * from './CheckBox'; |
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
Oops, something went wrong.