-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
178 changed files
with
14,287 additions
and
207 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
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,40 @@ | ||
{ | ||
"name": "man.web", | ||
"logo": "https://raw.githubusercontent.com/Nebo15/man.web/master/assets/images/logo.png", | ||
"scripts": { | ||
}, | ||
"env": { | ||
"PREBUILD": { | ||
"description": "RUN postinstall script. MUST be `true`", | ||
"required": true, | ||
"value": "true" | ||
}, | ||
"API_ENDPOINT": { | ||
"description": "Mán API host", | ||
"required": true, | ||
"value": "https://man-api.herokuapp.com" | ||
}, | ||
"SITEMAP_HOSTNAME": { | ||
"description": "SITEMAP_HOSTNAME will be used as hostname in sitemap URLs", | ||
"required": false, | ||
"value": "" | ||
}, | ||
"LANG_COOKIE_NAME": { | ||
"description": "Name of the cookie, where storing language variable", | ||
"value": "lang" | ||
} | ||
}, | ||
"formation": { | ||
"web": { | ||
"quantity": 1 | ||
} | ||
}, | ||
"addons": [ | ||
|
||
], | ||
"buildpacks": [ | ||
{ | ||
"url": "heroku/nodejs" | ||
} | ||
] | ||
} |
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,87 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router'; | ||
import classnames from 'classnames'; | ||
import withStyles from 'nebo15-isomorphic-style-loader/lib/withStyles'; | ||
|
||
import Icon, { icons } from 'components/Icon'; | ||
|
||
import styles from './styles.scss'; | ||
|
||
const URL_TEST_REG_EXP = /^((?:[a-z]+:)?\/\/)|mailto:/i; | ||
|
||
const Button = (props) => { | ||
const { | ||
theme = 'fill', | ||
size = 'middle', | ||
color = 'orange', | ||
active = false, | ||
disabled = false, | ||
block = false, | ||
inheritColor = false, | ||
type = 'button', | ||
to, children, onClick, id, icon, name, | ||
} = props; | ||
|
||
const className = classnames( | ||
styles.button, | ||
styles[`theme-${theme}`], | ||
styles[`color-${color}`], | ||
styles[`size-${size}`], | ||
active && styles.active, | ||
disabled && styles.disabled, | ||
block && styles.block, | ||
inheritColor && styles['inherit-color'], | ||
); | ||
|
||
const content = ( | ||
<div> | ||
{icon && <span className={styles.icon}><Icon name={icon} /></span>} | ||
{children} | ||
</div> | ||
); | ||
|
||
if (to === undefined) { | ||
return ( | ||
<button name={name} id={id} onClick={onClick} type={type} className={className}> | ||
{content} | ||
</button> | ||
); | ||
} | ||
if (URL_TEST_REG_EXP.test(to)) { | ||
return ( | ||
<a id={id} href={to} onClick={onClick} className={className}> | ||
{content} | ||
</a> | ||
); | ||
} | ||
|
||
return ( | ||
<Link id={id} to={to} onClick={onClick} className={className}>{content}</Link> | ||
); | ||
}; | ||
|
||
Button.propTypes = { | ||
theme: React.PropTypes.oneOf(['fill', 'border', 'link']), | ||
size: React.PropTypes.oneOf(['small', 'middle']), | ||
color: React.PropTypes.oneOf(['orange', 'blue', 'green', 'red']), | ||
type: React.PropTypes.string, | ||
active: React.PropTypes.bool, | ||
disabled: React.PropTypes.bool, | ||
block: React.PropTypes.bool, | ||
inheritColor: React.PropTypes.bool, | ||
to: React.PropTypes.string, | ||
id: React.PropTypes.string, | ||
icon: React.PropTypes.oneOf(icons), | ||
onClick: React.PropTypes.func, | ||
}; | ||
|
||
export default withStyles(styles)(Button); | ||
export const ButtonsGroup = withStyles(styles)( | ||
({ children, ...props }) => (<div {...props} className={styles.buttonsGroup}> | ||
{ | ||
React.Children.toArray(children).map((i, key) => | ||
<div className={styles.buttonsGroupItem} key={key}>{i}</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,87 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import { shallow, mount } from 'enzyme'; | ||
import spies from 'chai-spies'; | ||
|
||
import Button from './index'; | ||
import styles from './styles.scss'; | ||
|
||
chai.use(spies); | ||
|
||
describe('Button', () => { | ||
it('children', () => { | ||
const elem = shallow(<Button><span>My button</span></Button>); | ||
expect(elem.contains(<span>My button</span>)).to.equal(true); | ||
}); | ||
|
||
describe('props', () => { | ||
const elem = shallow(<Button theme="border" size="small" color="blue" active disabled />); | ||
|
||
it('theme', () => { | ||
expect(elem.render().find(`button.${styles['theme-border']}`)).to.have.length(1); | ||
}); | ||
|
||
it('size', () => { | ||
expect(elem.render().find(`button.${styles['size-small']}`)).to.have.length(1); | ||
}); | ||
|
||
it('color', () => { | ||
expect(elem.render().find(`button.${styles['color-blue']}`)).to.have.length(1); | ||
}); | ||
|
||
it('disabled', () => { | ||
expect(elem.render().find(`button.${styles.disabled}`)).to.have.length(1); | ||
}); | ||
|
||
it('active', () => { | ||
expect(elem.render().find(`button.${styles.active}`)).to.have.length(1); | ||
}); | ||
|
||
it('icon', () => { | ||
const elem = mount(<Button icon="plus" />); | ||
expect(elem.find('Icon').props().name).to.equal('plus'); | ||
}); | ||
|
||
describe('type', () => { | ||
it('should be button by default', () => { | ||
const wrapper = mount(<Button />); | ||
expect(wrapper.find('button').prop('type')).to.equal('button'); | ||
}); | ||
it('should be passed to button', () => { | ||
const wrapperType = mount(<Button type="test" />); | ||
expect(wrapperType.find('button').prop('type')).to.equal('test'); | ||
}); | ||
}); | ||
|
||
describe('onClick', () => { | ||
let handleClick; | ||
beforeEach(() => { | ||
handleClick = chai.spy(() => {}); | ||
}); | ||
|
||
it('should work', () => { | ||
const elem = shallow(<Button onClick={handleClick} />); | ||
elem.simulate('click'); | ||
expect(handleClick).to.have.been.called.once; | ||
}); | ||
|
||
it('should not be called if button disabled', () => { | ||
const elem = shallow(<Button disabled onClick={handleClick} />); | ||
elem.simulate('click'); | ||
expect(handleClick).to.have.not.been.called; | ||
}); | ||
}); | ||
|
||
describe('to', () => { | ||
it('should work inner link', () => { | ||
const elem = mount(<Button to="/" />); | ||
expect(elem.find('Link')).to.have.length(1); | ||
}); | ||
|
||
it('should work outer link', () => { | ||
const elem = shallow(<Button to="http://google.com" />); | ||
expect(elem.render().find('a[href="http://google.com"]')).to.have.length(1); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.