Skip to content

Commit

Permalink
css-modules infrastructure, ui components rewritten to use css-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gridsane committed Mar 27, 2017
1 parent d134f44 commit bfb5aab
Show file tree
Hide file tree
Showing 40 changed files with 600 additions and 525 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true

[*.{js,json,html,less}]
[*.{js,json,html,scss}]
indent_style = space
indent_size = 2
9 changes: 0 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
<title>Channel Hunter</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Roboto" rel="stylesheet">
<style>
body {
padding: 0;
margin: 0;
font-family: 'Roboto';
background-color: rgba(0,0,0,.05);
-webkit-font-smoothing: antialiased;
}
</style>
</head>
<body>
<div id="root"></div>
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"npm": "2.14.17"
},
"dependencies": {
"autoprefixer": "^6.3.6",
"babel": "^6.3.26",
"babel-cli": "^6.4.0",
"babel-core": "^6.4.0",
Expand All @@ -38,9 +39,14 @@
"babel-preset-stage-0": "^6.3.13",
"body-parser": "^1.14.1",
"brfs": "^1.4.3",
"classnames": "^2.2.5",
"color": "^0.11.1",
"css-loader": "^0.23.1",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^1.0.1",
"mongodb": "^2.0.49",
"node-sass": "^3.7.0",
"postcss-loader": "^0.9.1",
"radium": "^0.17.1",
"react": "^0.14.0",
"react-addons-shallow-compare": "^0.14.7",
Expand All @@ -52,13 +58,16 @@
"redux": "^3.0.4",
"redux-persist": "^2.0.1",
"redux-thunk": "^2.0.1",
"sass-loader": "^3.2.0",
"style-loader": "^0.13.1",
"superagent": "^1.4.0",
"superagent-jsonp": "0.0.6",
"transform-loader": "^0.2.3",
"webpack": "^1.12.2"
},
"devDependencies": {
"babel-eslint": "^6.0.0-beta.6",
"css-modules-require-hook": "^4.0.0",
"eslint": "2.2.x",
"eslint-plugin-react": "^4.2.2",
"expect": "^1.13.0",
Expand Down
9 changes: 9 additions & 0 deletions src/components/application/_theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$darkPrimaryColor: #303f9f;
$primaryColor: #3f51b5;
$lightPrimaryColor: #c5cae9;
$textColor: #fff;
$accentColor: #ff4081;
$primaryTextColor: #212121;
$secondaryTextColor: #727272;
$dividerColor: #b6b6b6;
$errorColor: #f44336;
1 change: 1 addition & 0 deletions src/components/application/application-container.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {Component} from 'react';
import HeaderContainer from '../header/header-container';
require('./application.scss');

export default class ApplicationContainer extends Component {
render() {
Expand Down
9 changes: 9 additions & 0 deletions src/components/application/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:global {
body {
padding: 0;
margin: 0;
font-family: 'Roboto';
background-color: rgba(0,0,0,.05);
-webkit-font-smoothing: antialiased;
}
}
27 changes: 8 additions & 19 deletions src/components/feed/feed-channels.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
import React, {Component, PropTypes} from 'react';
import {curried} from '../../utils/common';
import {colors} from '../../utils/styles';
import {List, ListItem, ListLabel, Avatar, Icon, Loader} from '../ui';
import cn from 'classnames';
import styles from './feed.scss';

export default class FeedChannels extends Component {
static propTypes = {
list: PropTypes.array.isRequired,
onToggle: PropTypes.func.isRequired,
};
}

render() {
const styles = this.getStyles();

const channels = this.props.list.map((channel) => {
return <ListItem
key={channel.id}
style={styles.channel}
className={styles.channelsItem}
primaryText={channel.name}
leftElement={<Avatar size={32} url={channel.image} />}
leftElement={<Avatar url={channel.image} className={styles.channelsItemImage} />}
leftElementHeight={32}
rightElement={this._renderRightElement(channel)}
rightElementHeight={24}
height={48}
onClick={curried(this.props.onToggle, channel)} />;
});

return <div style={this.props.style}>
return <div className={cn(styles.channels, this.props.className)}>
<ListLabel text="Your channels" />
<List>{channels}</List>
</div>;
}

_renderRightElement(channel) {
if (channel.isLoading) {
return <Loader size={24} color={colors.primaryText} />;
return <Loader size={24} />;
}

return channel.isEnabled ? <Icon size={24}>check</Icon> : null;
}

getStyles() {
return {

channel: {
fontSize: 14,
},

};
return channel.isEnabled ? <Icon size={24} glyph="check" /> : null;
}
}
4 changes: 2 additions & 2 deletions src/components/feed/feed-playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export default class FeedPlaylist extends Component {
onToggleShuffle: PropTypes.func.isRequired,
tracks: PropTypes.array.isRequired,
currentTrackId: PropTypes.string,
};
}

static defaultProps = {
compact: false,
currentTrackId: null,
isShuffle: false,
};
}

render() {
const {tracks} = this.props;
Expand Down
13 changes: 13 additions & 0 deletions src/components/feed/feed.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

.channels {
&Item {
font-size: 14px;

&Image {
width: 32px;
height: 32px;
}
}
}


30 changes: 0 additions & 30 deletions src/components/ui/avatar.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/components/ui/avatar/avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, {Component} from 'react';
import cn from 'classnames';
import styles from './avatar.scss';

export default class Avatar extends Component {
static propTypes = {
url: React.PropTypes.string.isRequired,
}

render() {
return <span
className={cn(styles.avatar, this.props.className)}
style={{...this.props.style, backgroundImage: `url(${this.props.url})`}} />;
}
}
8 changes: 8 additions & 0 deletions src/components/ui/avatar/avatar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.avatar {
display: inline-block;
width: 40px;
height: 40px;
background-size: cover;
background-position: center;
border-radius: 50%;
}
31 changes: 31 additions & 0 deletions src/components/ui/button/button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.flat {
height: 36px;
padding: 0 24px;
line-height: 16px;
font-size: 16px;
text-transform: uppercase;
border: none;
background: none;
cursor: pointer;

&:hover {
background: rgba(0,0,0,.1);
}
}

.icon {
display: inline-block;
position: relative;
background-color: transparent;
border: none;
outline: none;
margin: 0;
padding: 0;
cursor: pointer;
border-radius: 50%;

&:hover {
background: rgba(0,0,0,.1);
}

}
15 changes: 15 additions & 0 deletions src/components/ui/button/flat-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, {Component, PropTypes} from 'react';
import cn from 'classnames';
import styles from './button.scss';

export default class FlatButton extends Component {
static propTypes = {
label: PropTypes.node.isRequired,
}

render() {
return <button className={cn(styles.flat, this.props.className)}>
{this.props.label}
</button>;
}
}
23 changes: 23 additions & 0 deletions src/components/ui/button/icon-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, {Component, PropTypes} from 'react';
import cn from 'classnames';
import Icon from '../icon/icon';
import styles from './button.scss';

export default class IconButton extends Component {
static propTypes = {
glyph: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
size: PropTypes.number,
boxSize: PropTypes.number,
}

render() {
const {size, boxSize, glyph, onClick, className} = this.props;
return <button
className={cn(styles.icon, className)}
onClick={onClick}
style={this.props.style}>
<Icon size={size} boxSize={boxSize} glyph={glyph} />
</button>;
}
}
32 changes: 0 additions & 32 deletions src/components/ui/flat-button.js

This file was deleted.

51 changes: 0 additions & 51 deletions src/components/ui/icon-button.js

This file was deleted.

Loading

0 comments on commit bfb5aab

Please sign in to comment.