Skip to content

Commit 075128e

Browse files
author
¨Alexandra
committed
Add css loaders and replace inline css
1 parent cfb436a commit 075128e

File tree

7 files changed

+54
-11
lines changed

7 files changed

+54
-11
lines changed

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@
3737
"babel-preset-es2015": "^6.24.1",
3838
"babel-preset-react": "^6.24.1",
3939
"babel-preset-stage-2": "^6.24.1",
40+
"css-loader": "^0.28.7",
41+
"file-loader": "^1.1.5",
42+
"less": "^3.0.0-alpha.3",
43+
"less-loader": "^4.0.5",
44+
"style-loader": "^0.19.0",
4045
"webpack": "^3.6.0",
46+
"webpack-combine-loaders": "^2.0.3",
4147
"webpack-dev-server": "^2.9.1"
4248
}
4349
}

src/app/components/List.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import PropTypes from 'prop-types'; // ES6
3+
import "../styles/components/List.less"
34

45
export class List extends React.Component {
56

@@ -23,7 +24,7 @@ export class List extends React.Component {
2324
<tr key={i}>
2425
<td>
2526
{link.shortcode}
26-
<p style={{color: 'gray'}}>
27+
<p className="url">
2728
url: {link.url}
2829
</p>
2930
</td>

src/app/components/ShortenLink.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React from "react";
22
import PropTypes from 'prop-types'
3+
import "../styles/components/shortenLink.less"
34

45
export class ShortenLink extends React.Component {
5-
6-
static propTypes = {
7-
shortenUrl: PropTypes.func.isRequired,
8-
};
9-
106
state = {
117
url: ''
128
};
@@ -23,7 +19,7 @@ export class ShortenLink extends React.Component {
2319
render() {
2420

2521
return (
26-
<div style={{marginBottom: '8%'}}>
22+
<div>
2723
<form name="shortenUrl" onSubmit={this.handleSubmit} className="form-inline">
2824
<div className="form-group">
2925
<input type="text"
@@ -32,7 +28,7 @@ export class ShortenLink extends React.Component {
3228
onChange={this.handleChange}
3329
value={this.state.url}
3430
/>
35-
<button style={{marginLeft: '20px', backgroundColor: '#EB4A42', color:'#FFFFFF'}} className="btn btn-lg" type="submit">
31+
<button className="btn btn-lg disabled" type="submit">
3632
Shorten url
3733
</button>
3834
</div>
@@ -41,3 +37,7 @@ export class ShortenLink extends React.Component {
4137
)
4238
}
4339
}
40+
41+
ShortenLink.propTypes = {
42+
shortenUrl: PropTypes.func.isRequired
43+
};

src/app/containers/App.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import { submitUrl, getShortCodeStats } from "../actions/shortenedLinkActions";
77

88
import { ShortenLink } from "../components/ShortenLink";
99
import { List } from "../components/List";
10+
import app from "../styles/containers/App.less"
1011

1112

1213
class App extends React.Component {
1314

1415
render () {
1516

1617
return (
17-
<div style={{color: '#555555'}}>
18+
<div style={app}>
1819
<div className="container">
1920
<div className="row">
2021
<div className="col-xs-10 col-xs-offset-1">
21-
<h1 style={{color: '#EB4A42', textDecoration:'underline'}}>Shooooort</h1>
22+
<h1>Shooooort</h1>
2223
<p> This link shortner with a long name </p>
2324
</div>
2425
</div>

src/app/styles/components/List.less

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.url {
2+
color: #888888;
3+
}
4+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
.btn {
3+
margin-left: 20px;
4+
background-color: #EB4A42;
5+
color: #FFFFFF;
6+
&:hover {
7+
background-color: lighten(#EB4A42, 20%);
8+
}
9+
&.active {
10+
background-color: #EB4A42;
11+
}
12+
&.disabled {
13+
background-color: #BFBFBF;
14+
color: #E0E0E0;
15+
}
16+
}

webpack.config.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
var path = require("path");
2+
var combineLoaders = require('webpack-combine-loaders');
3+
24

35
var DIST_DIR = path.resolve(__dirname, "dist");
46
var SRC_DIR = path.resolve(__dirname, "src");
@@ -20,7 +22,20 @@ var config = {
2022
query: {
2123
presets: ["react", "es2015", "stage-2"]
2224
}
23-
}
25+
}, {
26+
test: /\.less$/,
27+
use: [{
28+
loader: "style-loader"
29+
}, {
30+
loader: "css-loader"
31+
}, {
32+
loader: "less-loader", options: {
33+
paths: [
34+
path.resolve(SRC_DIR, "node_modules")
35+
]
36+
}
37+
}]
38+
}
2439
]
2540
}
2641
};

0 commit comments

Comments
 (0)