Skip to content

Commit ad79dbf

Browse files
author
Yury Dymov
committed
final
1 parent 4cc8faf commit ad79dbf

File tree

6 files changed

+130
-25
lines changed

6 files changed

+130
-25
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ jspm_packages
3636
# Optional REPL history
3737
.node_repl_history
3838
dist/bundle.js
39-
dist/styles.css

dist/styles.css

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#react-view {
2+
padding: 20px;
3+
}
4+
5+
.btn {
6+
display: inline-block;
7+
margin-bottom: 0;
8+
font-weight: normal;
9+
text-align: center;
10+
vertical-align: middle;
11+
-ms-touch-action: manipulation;
12+
touch-action: manipulation;
13+
cursor: pointer;
14+
background-image: none;
15+
border: 1px solid transparent;
16+
white-space: nowrap;
17+
padding: 10px 15px;
18+
font-size: 15px;
19+
line-height: 1.42857143;
20+
border-radius: 4px;
21+
-webkit-user-select: none;
22+
-moz-user-select: none;
23+
-ms-user-select: none;
24+
user-select: none;
25+
}
26+
.btn:focus,
27+
.btn:active:focus,
28+
.btn.active:focus,
29+
.btn.focus,
30+
.btn:active.focus,
31+
.btn.active.focus {
32+
outline: 5px auto -webkit-focus-ring-color;
33+
outline-offset: -2px;
34+
}
35+
.btn:hover,
36+
.btn:focus,
37+
.btn.focus {
38+
color: #ffffff;
39+
text-decoration: none;
40+
}
41+
.btn:active,
42+
.btn.active {
43+
outline: 0;
44+
background-image: none;
45+
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
46+
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
47+
}
48+
.btn.disabled,
49+
.btn[disabled],
50+
fieldset[disabled] .btn {
51+
cursor: not-allowed;
52+
opacity: 0.65;
53+
filter: alpha(opacity=65);
54+
-webkit-box-shadow: none;
55+
box-shadow: none;
56+
}
57+
a.btn.disabled,
58+
fieldset[disabled] a.btn {
59+
pointer-events: none;
60+
}
61+
.btn-default {
62+
color: #ffffff;
63+
background-color: #95a5a6;
64+
border-color: #95a5a6;
65+
}
66+
.btn-default:focus,
67+
.btn-default.focus {
68+
color: #ffffff;
69+
background-color: #798d8f;
70+
border-color: #566566;
71+
}
72+
.btn-default:hover {
73+
color: #ffffff;
74+
background-color: #798d8f;
75+
border-color: #74898a;
76+
}
77+
.btn-default:active,
78+
.btn-default.active,
79+
.open > .dropdown-toggle.btn-default {
80+
color: #ffffff;
81+
background-color: #798d8f;
82+
border-color: #74898a;
83+
}
84+
.btn-default:active:hover,
85+
.btn-default.active:hover,
86+
.open > .dropdown-toggle.btn-default:hover,
87+
.btn-default:active:focus,
88+
.btn-default.active:focus,
89+
.open > .dropdown-toggle.btn-default:focus,
90+
.btn-default:active.focus,
91+
.btn-default.active.focus,
92+
.open > .dropdown-toggle.btn-default.focus {
93+
color: #ffffff;
94+
background-color: #687b7c;
95+
border-color: #566566;
96+
}
97+
.btn-default:active,
98+
.btn-default.active,
99+
.open > .dropdown-toggle.btn-default {
100+
background-image: none;
101+
}
102+
.btn-default.disabled:hover,
103+
.btn-default[disabled]:hover,
104+
fieldset[disabled] .btn-default:hover,
105+
.btn-default.disabled:focus,
106+
.btn-default[disabled]:focus,
107+
fieldset[disabled] .btn-default:focus,
108+
.btn-default.disabled.focus,
109+
.btn-default[disabled].focus,
110+
fieldset[disabled] .btn-default.focus {
111+
background-color: #95a5a6;
112+
border-color: #95a5a6;
113+
}
114+
.btn-default .badge {
115+
color: #95a5a6;
116+
background-color: #ffffff;
117+
}

src/components/Content/Content.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ Content.propTypes = propTypes;
3030

3131
function mapStateToProps(state) {
3232
if (state.data.meta['/test']) {
33-
const questions = state.data.meta['/test'].data.map(object => build(state.data, 'question', object.id));
33+
const questions = (state.data.meta['/test'].data || []).map(object => build(state.data, 'question', object.id));
34+
const loading = state.data.meta['/test'].loading;
3435

35-
return { questions };
36+
return { questions, loading };
3637
}
3738

3839
return { questions: [] };

src/redux/middleware/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export default function (store) {
5151
return finalAction;
5252
};
5353

54-
next(actionWith({ type: API_DATA_REQUEST }));
54+
next(actionWith({ type: API_DATA_REQUEST, endpoint }));
5555

5656
return callApi(endpoint, options || {})
5757
.then(
58-
response => next(actionWith({ response, type: API_DATA_SUCCESS })),
58+
response => next(actionWith({ response, type: API_DATA_SUCCESS, endpoint })),
5959
error => next(actionWith({ type: API_DATA_FAILURE, error: error.message || 'Something bad happened' })),
6060
);
6161
};

src/redux/reducers/data.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import merge from 'lodash/merge';
2-
import { API_DATA_SUCCESS } from '../middleware/api';
2+
import { API_DATA_REQUEST, API_DATA_SUCCESS } from '../middleware/api';
33

44
const initialState = {
55
meta: {},
@@ -8,7 +8,13 @@ const initialState = {
88
export default function (state = initialState, action) {
99
switch (action.type) {
1010
case API_DATA_SUCCESS:
11-
return merge({}, state, action.response);
11+
return merge(
12+
{},
13+
state,
14+
merge({}, action.response, { meta: { [action.endpoint]: { loading: false } } }),
15+
);
16+
case API_DATA_REQUEST:
17+
return merge({}, state, { meta: { [action.endpoint]: { loading: true } } });
1218
default:
1319
return state;
1420
}

webpack.config.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ module.exports = {
3939
},
4040
module: {
4141
loaders: [
42-
/*
43-
{
44-
test: /\.css$/,
45-
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
46-
},
47-
{
48-
test: /\.less$/,
49-
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
50-
},
51-
{ test: /\.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
52-
{ test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
53-
{ test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
54-
{ test: /\.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
55-
{ test: /\.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
56-
{ test: /\.jss?x?l?$/, loader: process.env.NODE_ENV !== 'production' ? 'babel!eslint-loader' : 'babel', exclude: [/node_modules/, /public/] },
57-
{ test: /\.json$/, loader: 'json-loader' },
58-
{ test: /\.txt$/, loader: 'raw-loader' }
59-
*/
6042
{ test: /\.jss?x?l?$/, loader: process.env.NODE_ENV !== 'production' ? 'babel!eslint-loader' : 'babel', exclude: [/node_modules/, /public/] },
6143
]
6244
},

0 commit comments

Comments
 (0)