Skip to content

Commit 9a3762f

Browse files
committed
react-redux app's state
0 parents  commit 9a3762f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+11902
-0
lines changed

.babelrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"presets":[
3+
"env", "react", "react-optimize", "stage-1"
4+
],
5+
"env": {
6+
"development": {
7+
"plugins": [
8+
["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ]
9+
]
10+
},
11+
"production": {
12+
"plugins": [
13+
["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ]
14+
]
15+
}
16+
},
17+
"plugins": [
18+
["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ],
19+
["babel-plugin-styled-components", {
20+
"displayName": true
21+
}],
22+
"syntax-dynamic-import",
23+
["babel-plugin-root-import", {
24+
"rootPathPrefix": "~",
25+
"rootPathSuffix": "src"
26+
}]
27+
]
28+
}

.eslintrc.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// 0 - Off
2+
// 1 - Warn
3+
// 2 - Error
4+
5+
module.exports = {
6+
'plugins': [
7+
'react'
8+
],
9+
'extends': [
10+
'airbnb'
11+
],
12+
env: {
13+
es6: true,
14+
node: true,
15+
browser: true
16+
},
17+
settings: {
18+
"import/resolver": "babel-plugin-root-import"
19+
},
20+
parser: 'babel-eslint',
21+
parserOptions: {
22+
ecmaVersion: 8,
23+
sourceType: 'module',
24+
ecmaFeatures: {
25+
jsx: true,
26+
},
27+
},
28+
'rules': {
29+
// General JS'
30+
"linebreak-style": 0,
31+
'no-empty': 0,
32+
'no-bitwise': 0,
33+
'dot-notation': [2, {
34+
'allowPattern': '^(START|FINISH|INIT|DONE|NOT_MODIFIED|304|FAIL)$',
35+
}],
36+
'no-console': 0,
37+
'arrow-parens': 0,
38+
'no-extra-semi': 0,
39+
'global-require': 0,
40+
'arrow-body-style': 0,
41+
'no-empty-function': 0,
42+
'no-confusing-arrow': 0,
43+
'template-curly-spacing': 0,
44+
'no-prototype-builtins': 0,
45+
'no-param-reassign': 0,
46+
'class-methods-use-this': 0,
47+
'comma-dangle': [2, 'always-multiline'],
48+
'no-use-before-define': [2, {
49+
'functions': false,
50+
}],
51+
'no-unused-expressions': [2, {
52+
allowTaggedTemplates: true,
53+
}],
54+
'no-underscore-dangle': 0,
55+
'max-len': [1, 120],
56+
'consistent-return': 0,
57+
'space-before-function-paren': 0,
58+
'func-names': 0,
59+
'no-shadow': 0,
60+
61+
// Import
62+
'import/first': 0,
63+
'import/extensions': 0,
64+
'import/no-unresolved': 0,
65+
'import/no-dynamic-require': 0,
66+
'import/newline-after-import': 0,
67+
'import/prefer-default-export': 0,
68+
'import/no-webpack-loader-syntax': 0,
69+
'import/no-extraneous-dependencies': 0,
70+
71+
// React
72+
'react/forbid-prop-types': 0,
73+
'react/jsx-filename-extension': [2, {
74+
'extensions': ['.js', '.jsx'],
75+
}],
76+
'react/prefer-stateless-function': 0,
77+
'react/jsx-boolean-value': 0,
78+
'react/prop-types': 0,
79+
'react/jsx-no-bind': 1,
80+
'react/no-unused-prop-types': 0,
81+
'react/sort-comp': [2, {
82+
order: [
83+
'static-methods',
84+
'lifecycle',
85+
'everything-else',
86+
],
87+
}],
88+
89+
'jsx-a11y/no-static-element-interactions': 0,
90+
'jsx-a11y/img-has-alt': 0,
91+
'jsx-a11y/href-no-hash': 0,
92+
"jsx-a11y/label-has-for": [ 2, {
93+
"components": [ "Label" ],
94+
"required": {
95+
"every": [ "nesting", "id" ]
96+
},
97+
"allowChildren": false
98+
}]
99+
}
100+
}

.flowconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[ignore]
2+
.*/node_modules
3+
4+
[include]
5+
src
6+
7+
[libs]
8+
9+
[lints]
10+
11+
[options]
12+
module.system.node.resolve_dirname=node_modules
13+
module.system.node.resolve_dirname=src
14+
15+
esproposal.class_instance_fields=enable
16+
esproposal.class_static_fields=enable
17+
18+
[strict]

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
# mockups
24+
/psd/

README.md

Whitespace-only changes.

package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "client",
3+
"version": "0.1.0",
4+
"description": "",
5+
"license": "mit",
6+
"main": "index.jsx",
7+
"scripts": {
8+
"watch": "webpack --watch",
9+
"dev": "webpack-dev-server",
10+
"prod": "cross-env NODE_ENV=production webpack -p "
11+
},
12+
"dependencies": {
13+
"babel-eslint": "^8.2.1",
14+
"flow": "^0.2.3",
15+
"react": "^16.1.1",
16+
"react-dom": "^16.1.1",
17+
"react-icons": "^2.2.7",
18+
"react-motion": "^0.5.2",
19+
"react-redux": "^5.0.7",
20+
"redux": "^3.7.2",
21+
"react-responsive-modal": "^2.0.1",
22+
"react-router": "^4.2.0",
23+
"react-router-dom": "^4.2.2",
24+
"react-tabs": "^2.2.1",
25+
"styled-components": "^3.1.6"
26+
},
27+
"devDependencies": {
28+
"babel-cli": "^6.26.0",
29+
"babel-core": "^6.26.0",
30+
"babel-loader": "^7.1.2",
31+
"babel-plugin-root-import": "^5.1.0",
32+
"babel-plugin-styled-components": "^1.5.0",
33+
"babel-plugin-syntax-dynamic-import": "^6.18.0",
34+
"babel-polyfill": "^6.26.0",
35+
"babel-preset-env": "^1.6.1",
36+
"babel-preset-react": "^6.24.1",
37+
"babel-preset-react-optimize": "^1.0.1",
38+
"babel-preset-stage-1": "^6.24.1",
39+
"clean-webpack-plugin": "^0.1.17",
40+
"compression-webpack-plugin": "^1.0.1",
41+
"cross-env": "^5.1.1",
42+
"css-loader": "^0.28.7",
43+
"eslint": "^4.12.1",
44+
"eslint-config-airbnb": "^16.1.0",
45+
"eslint-import-resolver-babel-root-import": "^0.0.2",
46+
"eslint-plugin-import": "^2.8.0",
47+
"eslint-plugin-jsx-a11y": "^6.0.2",
48+
"eslint-plugin-react": "^7.5.1",
49+
"extract-text-webpack-plugin": "^3.0.2",
50+
"favicons-webpack-plugin": "0.0.7",
51+
"file-loader": "^1.1.5",
52+
"flow-bin": "^0.63.1",
53+
"html-webpack-plugin": "^2.30.1",
54+
"node-sass": "^4.7.2",
55+
"react-fontawesome": "^1.6.1",
56+
"style-loader": "^0.19.0",
57+
"webpack": "^3.9.1",
58+
"webpack-dev-server": "^2.9.5",
59+
"webpack-merge": "^4.1.1"
60+
}
61+
}

src/actions/actionCreators.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// toggle notification
2+
export const showNotify = (notify) => ({
3+
type: 'SHOW_NOTIFICATION',
4+
notify,
5+
});
6+
// toggle usersettings
7+
export const showUserSettings = (userSettings) => ({
8+
type: 'SHOW_USER_SETTINGS',
9+
userSettings,
10+
});
11+
// toggle active burger
12+
export const toggleActive = (burgerActive) => ({
13+
type: 'MAKE_BUTTON_ACTIVE',
14+
burgerActive,
15+
});
16+
// show chat settings
17+
export const showChatSettings = (visibility) => ({
18+
type: 'SHOW_CHAT_SETTINGS',
19+
visibility,
20+
});
21+
// toggle modal
22+
export const toggleModal = (id) => ({
23+
type: 'TOGGLE_MODAL',
24+
id,
25+
});
26+
// show emojis
27+
export const showEmojis = (visibility) => ({
28+
type: 'SHOW_EMOJIS',
29+
visibility,
30+
});
31+
// send message
32+
export const sendMessage = (postId, author, comment) => ({
33+
type: 'SEND_MESSAGE',
34+
postId,
35+
author,
36+
comment,
37+
});

src/app.jsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
// redux
5+
import { connect } from 'react-redux';
6+
import { showUserSettings, toggleActive, showChatSettings } from './actions/actionCreators';
7+
8+
// components
9+
import DialogsPanel from '~/pages/dialogsPanel/dialogsPanel';
10+
import MessagePanelWrap from '~/pages/MessagePanel/MessagePanel';
11+
12+
// styles
13+
import '~/styles/index.js';
14+
15+
const ContentWrap = styled.div`
16+
max-width: 1160px;
17+
margin: 0 auto;
18+
display: flex;
19+
`;
20+
const PageWrap = styled.div`
21+
background-color: #e7ebf0;
22+
height: 100vh;
23+
`;
24+
25+
const mapStateToProps = (state) => ({
26+
userSettings: state.ui.userSettings,
27+
chatSettings: state.ui.chatSettings,
28+
});
29+
30+
class App extends React.Component {
31+
hideSettings = () => {
32+
if (this.props.userSettings) {
33+
this.props.showUserSettings();
34+
this.props.toggleActive();
35+
}
36+
if (this.props.chatSettings) {
37+
this.props.showChatSettings();
38+
}
39+
}
40+
handleFocus = () => {
41+
this.inputElement.focus();
42+
}
43+
render() {
44+
return (
45+
<PageWrap onClick={this.hideSettings}>
46+
<ContentWrap>
47+
<DialogsPanel inputRef={(input) => { this.inputElement = input; }} />
48+
<MessagePanelWrap handleFocus={this.handleFocus} />
49+
</ContentWrap>
50+
</PageWrap>
51+
);
52+
}
53+
}
54+
55+
const MainApp = connect(mapStateToProps, { showUserSettings, toggleActive, showChatSettings })(App);
56+
57+
export default MainApp;

src/data/chatMessage.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const chatMessage = [
2+
{
3+
name: 'Sheldhur Mornor',
4+
message: 'lol',
5+
seen: 'just now',
6+
img: 'https://users-ovtuzvuqxy.now.sh/notdog.jpg',
7+
onlineStatus: 'waiting',
8+
isAdmin: true,
9+
10+
},
11+
{
12+
name: 'aaaaaaaaaaa',
13+
message: 'Am I a shoha, aren\'t I ???',
14+
seen: '5 min',
15+
img: 'https://users-ovtuzvuqxy.now.sh/dog.jpg',
16+
onlineStatus: 'offline',
17+
isAdmin: false,
18+
},
19+
{
20+
name: 'Maks',
21+
message: 'ADMINS, where are you?',
22+
seen: '1 hour',
23+
img: 'https://users-ovtuzvuqxy.now.sh/user2.jpg',
24+
onlineStatus: 'online',
25+
isAdmin: false,
26+
},
27+
];
28+
export default chatMessage;

src/data/chatPanel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const chatPanel =
2+
{
3+
groupImg: 'https://users-ovtuzvuqxy.now.sh/chat.jpg',
4+
groupStatus: 'online',
5+
groupName: 'JS',
6+
groupInfo: 'JSthread, flood and stuff!',
7+
groupMemb: '12',
8+
};
9+
10+
export default chatPanel;

0 commit comments

Comments
 (0)