Skip to content

Commit

Permalink
Migrate list to sass
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Oct 12, 2015
1 parent c5adb53 commit a866b7a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 80 deletions.
59 changes: 0 additions & 59 deletions components/constants.styl

This file was deleted.

5 changes: 2 additions & 3 deletions components/list/index.jsx
@@ -1,5 +1,4 @@
import React from 'react';

import PureRenderMixin from 'react-addons-pure-render-mixin';
import style from './style';

Expand All @@ -11,7 +10,7 @@ export default React.createClass({
propTypes: {
className: React.PropTypes.string,
dataSource: React.PropTypes.array,
ItemFactory: React.PropTypes.func,
template: React.PropTypes.func,
onClick: React.PropTypes.func,
type: React.PropTypes.string
},
Expand All @@ -38,7 +37,7 @@ export default React.createClass({
const items = this.props.dataSource.map((data, index) => {
return (
<li key={index} onClick={this.onClick.bind(null, data, index)}>
{this.props.itemFactory(data, index)}
{this.props.template(data, index)}
</li>
);
});
Expand Down
25 changes: 25 additions & 0 deletions components/list/style.scss
@@ -0,0 +1,25 @@
@import "../variables";

$list-color: unquote("rgb(#{$color-black})") !default;
$list-background: unquote("rgb(#{$color-white})") !default;

.root {
list-style: none;

&, a {
color: $list-color;
}

> li {
overflow: hidden;
background-color: $list-background;
box-shadow: $zdepth-shadow-1;
transition-timing-function: $animation-curve-default;
transition-duration: $animation-duration;
transition-property: box-shadow;

&:hover {
box-shadow: $zdepth-shadow-2;
}
}
}
15 changes: 0 additions & 15 deletions components/list/style.styl

This file was deleted.

52 changes: 52 additions & 0 deletions spec/components/list.jsx
@@ -0,0 +1,52 @@
import React from 'react';
import List from '../../components/list';

export default React.createClass({
displayName: 'ListTest',

getInitialState () {
return {
countries: [
{ value: 'ES-es', label: 'Spain', img: 'http://' },
{ value: 'TH-th', label: 'Thailand', img: 'http://' },
{ value: 'EN-gb', label: 'England', img: 'http://' },
{ value: 'EN-en', label: 'USA', img: 'http://' },
{ value: 'FR-fr', label: 'France', img: 'http://' }
],
selected: 'TH-th'
};
},

onChange (dropdown) {
console.log('[DROPDOWN]', dropdown.getValue());
},

customDropdownItem (data) {
const style = {
width: 32,
height: 32,
backgroundColor: '#ccc',
marginRight: 8
};

return (
<div data-flex="horizontal grow" data-flex-content="center">
<img src={data.img} data-flex-grow="min" style={style} />
<div data-flex-grow="max" data-flex="vertical" >
<strong>{data.label}</strong>
<small>{data.value}</small>
</div>
</div>
);
},

render () {
return (
<section>
<h5>List</h5>
<p>lorem ipsum...</p>
<List dataSource={this.state.countries} value={this.state.selected} template={this.customDropdownItem} onChange={this.onChange}/>
</section>
);
}
});
3 changes: 0 additions & 3 deletions spec/index.jsx
Expand Up @@ -16,9 +16,6 @@ import Slider from './components/slider';
import Switch from './components/switch';
import Tabs from './components/tabs';

// import FontIcon from './components/font_icon';
// import Form from './components/form';

const Test = React.createClass({
displayName: 'App',

Expand Down

0 comments on commit a866b7a

Please sign in to comment.