denshobato_chat_panel 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -9
- data/lib/denshobato_chat_panel.rb +6 -0
- data/lib/denshobato_chat_panel/chat_panel_helper.rb +44 -0
- data/lib/denshobato_chat_panel/core.rb +15 -0
- data/lib/denshobato_chat_panel/version.rb +1 -1
- data/lib/generators/denshobato_chat_panel/assets/javascripts/denshobato.js +698 -818
- data/lib/generators/denshobato_chat_panel/assets/stylesheets/denshobato.scss +69 -34
- data/lib/generators/denshobato_chat_panel/install_generator.rb +11 -5
- data/lib/react/components/Message.jsx +5 -3
- data/lib/react/components/MessageForm.jsx +4 -11
- data/webpack.config.js +1 -1
- metadata +4 -2
@@ -117,10 +117,8 @@ $color-blue: #8ac0d9;
|
|
117
117
|
// - - - Chat
|
118
118
|
|
119
119
|
.chat-wrapper {
|
120
|
-
min-width: 400px;
|
121
|
-
width: 100%;
|
122
|
-
height: 500px;
|
123
120
|
border: 1px solid rgba(0, 0, 0, 0.08);
|
121
|
+
height: 500px;
|
124
122
|
padding: 20px;
|
125
123
|
position: relative;
|
126
124
|
border-radius: 0px 0px 10px 10px;
|
@@ -188,27 +186,29 @@ $color-blue: #8ac0d9;
|
|
188
186
|
}
|
189
187
|
}
|
190
188
|
&.chat-message-recipient {
|
191
|
-
.
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
position: absolute;
|
202
|
-
top: 76px;
|
203
|
-
left: 17px;
|
189
|
+
.user-info {
|
190
|
+
display: inline-block;
|
191
|
+
float: left;
|
192
|
+
width: 60px;
|
193
|
+
height: auto;
|
194
|
+
.message-author {
|
195
|
+
font-size: small;
|
196
|
+
display: block;
|
197
|
+
text-align: center;
|
198
|
+
}
|
204
199
|
}
|
205
200
|
.chat-message-wrapper,
|
206
201
|
.chat-message-content {
|
207
202
|
float: left;
|
208
203
|
}
|
209
204
|
.chat-message-wrapper {
|
205
|
+
.message-time {
|
206
|
+
font-size: xx-small;
|
207
|
+
display: block;
|
208
|
+
}
|
210
209
|
&:before {
|
211
|
-
left:
|
210
|
+
left: -20px;
|
211
|
+
top: 30px;
|
212
212
|
border-right-color: $color-green;
|
213
213
|
}
|
214
214
|
}
|
@@ -218,27 +218,31 @@ $color-blue: #8ac0d9;
|
|
218
218
|
}
|
219
219
|
}
|
220
220
|
&.chat-message-sender {
|
221
|
-
.
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
top: 77px;
|
233
|
-
right: 10px;
|
221
|
+
.user-info {
|
222
|
+
display: inline-block;
|
223
|
+
float: right;
|
224
|
+
width: 60px;
|
225
|
+
height: auto;
|
226
|
+
.message-author {
|
227
|
+
font-size: small;
|
228
|
+
display: block;
|
229
|
+
text-align: center;
|
230
|
+
margin: 0px 0px 0px 0px;
|
231
|
+
}
|
234
232
|
}
|
235
233
|
.chat-message-wrapper,
|
236
234
|
.chat-message-content {
|
237
235
|
float: right;
|
238
236
|
}
|
239
237
|
.chat-message-wrapper {
|
238
|
+
.message-time {
|
239
|
+
font-size: xx-small;
|
240
|
+
display: block;
|
241
|
+
text-align: right;
|
242
|
+
}
|
240
243
|
&:before {
|
241
244
|
right: -$spacing;
|
245
|
+
top: 30px;
|
242
246
|
border-left-color: $color-blue;
|
243
247
|
}
|
244
248
|
}
|
@@ -293,7 +297,7 @@ $color-blue: #8ac0d9;
|
|
293
297
|
z-index: 9;
|
294
298
|
bottom: 23px;
|
295
299
|
.message_input_wrapper {
|
296
|
-
display:
|
300
|
+
display: block;
|
297
301
|
height: 38px;
|
298
302
|
border-radius: 20px;
|
299
303
|
border: 1px solid #bcbdc0;
|
@@ -311,9 +315,8 @@ $color-blue: #8ac0d9;
|
|
311
315
|
}
|
312
316
|
}
|
313
317
|
.send_message {
|
314
|
-
width:
|
315
|
-
|
316
|
-
display: inline-block;
|
318
|
+
width: 20%;
|
319
|
+
display: block;
|
317
320
|
border-radius: 50px;
|
318
321
|
background-color: #a3d063;
|
319
322
|
border: 2px solid #a3d063;
|
@@ -439,3 +442,35 @@ $color-blue: #8ac0d9;
|
|
439
442
|
color: white;
|
440
443
|
}
|
441
444
|
}
|
445
|
+
|
446
|
+
.denshobato-send-message {
|
447
|
+
width: 70%;
|
448
|
+
position: fixed;
|
449
|
+
bottom: 0px;
|
450
|
+
outline: none;
|
451
|
+
margin-bottom: 30px;
|
452
|
+
z-index: 999;
|
453
|
+
input {
|
454
|
+
width: 70%;
|
455
|
+
border-radius: 20px;
|
456
|
+
border: 1px solid #BBBBBB;
|
457
|
+
padding: 5px 0px 5px 10px;
|
458
|
+
}
|
459
|
+
|
460
|
+
button {
|
461
|
+
width: 15%;
|
462
|
+
display: inline-block;
|
463
|
+
padding: 5px;
|
464
|
+
border-radius: 50px;
|
465
|
+
background-color: #a3d063;
|
466
|
+
border: 2px solid #a3d063;
|
467
|
+
color: white;
|
468
|
+
cursor: pointer;
|
469
|
+
transition: all 0.2s linear;
|
470
|
+
text-align: center;
|
471
|
+
&:hover {
|
472
|
+
color: #a3d063;
|
473
|
+
background-color: white;
|
474
|
+
}
|
475
|
+
}
|
476
|
+
}
|
@@ -13,12 +13,18 @@ module DenshobatoChatPanel
|
|
13
13
|
|
14
14
|
def done
|
15
15
|
puts " =====================================================
|
16
|
-
1.
|
16
|
+
1. Add 'denshobato_chat_panel' method to your model
|
17
|
+
class User < ActiveRecord::Base
|
18
|
+
denshobato_for :user
|
19
|
+
denshobato_chat_panel
|
20
|
+
end
|
21
|
+
|
22
|
+
2. Copy this line to your config/initializers/assets.rb
|
17
23
|
Rails.application.config.assets.precompile += %w( denshobato.js )
|
18
24
|
|
19
|
-
|
25
|
+
3. Add '@import 'denshobato'; to your application.scss'
|
20
26
|
|
21
|
-
|
27
|
+
4. In layouts/application.erb include javascript file to the bottom
|
22
28
|
Like this:
|
23
29
|
|
24
30
|
<body>
|
@@ -30,10 +36,10 @@ module DenshobatoChatPanel
|
|
30
36
|
<%= javascript_include_tag 'denshobato' %>
|
31
37
|
</body>
|
32
38
|
|
33
|
-
|
39
|
+
5. Mount API route in your routes.rb
|
34
40
|
mount Denshobato::DenshobatoApi => '/'
|
35
41
|
|
36
|
-
|
42
|
+
6. Add this helper with arguments to the page with your conversation
|
37
43
|
e.g # => conversation/32
|
38
44
|
|
39
45
|
= render_denshobato_messages(@conversation, current_user)
|
@@ -30,10 +30,12 @@ export default class Message extends Component {
|
|
30
30
|
|
31
31
|
return (
|
32
32
|
<div className={`chat-message chat-message-${cssClass}`}>
|
33
|
-
<
|
34
|
-
|
35
|
-
|
33
|
+
<div className='user-info'>
|
34
|
+
<img className='chat-image chat-image-default' src={message.avatar} />
|
35
|
+
<span className='message-author'>{message.full_name}</span>
|
36
|
+
</div>
|
36
37
|
<div className='chat-message-wrapper'>
|
38
|
+
<span className='message-time'>{message.time}</span>
|
37
39
|
<div className='chat-message-content'>
|
38
40
|
<p>{message.body}</p>
|
39
41
|
</div>
|
@@ -14,18 +14,11 @@ export default class MessageForm extends Component {
|
|
14
14
|
render() {
|
15
15
|
const { fields: { body, senderClass }, handleSubmit } = this.props;
|
16
16
|
return (
|
17
|
-
<div>
|
17
|
+
<div className='denshobato-send-message'>
|
18
18
|
<form onSubmit={handleSubmit}>
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
</div>
|
23
|
-
<div className="send_message">
|
24
|
-
<div className="icon"></div>
|
25
|
-
<button onclick={handleSubmit} className="text">Send</button>
|
26
|
-
</div>
|
27
|
-
</div>
|
28
|
-
</form>
|
19
|
+
<input className="message_input" placeholder="Type your message here..." {...body}/>
|
20
|
+
<button onclick={handleSubmit} className="text">Send</button>
|
21
|
+
</form>
|
29
22
|
</div>
|
30
23
|
);
|
31
24
|
}
|
data/webpack.config.js
CHANGED
@@ -3,7 +3,7 @@ var webpack = require('webpack');
|
|
3
3
|
|
4
4
|
module.exports = {
|
5
5
|
entry: './lib/react/denshobato.js',
|
6
|
-
output: { path:
|
6
|
+
output: { path: './lib/generators/denshobato_chat_panel/assets/javascripts/', filename: 'denshobato.js' },
|
7
7
|
resolve: { extensions: ['', '.js', '.jsx'] },
|
8
8
|
module: {
|
9
9
|
loaders: [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: denshobato_chat_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ID25
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -114,6 +114,8 @@ files:
|
|
114
114
|
- lib/api/denshobato_api.rb
|
115
115
|
- lib/api/message_api.rb
|
116
116
|
- lib/denshobato_chat_panel.rb
|
117
|
+
- lib/denshobato_chat_panel/chat_panel_helper.rb
|
118
|
+
- lib/denshobato_chat_panel/core.rb
|
117
119
|
- lib/denshobato_chat_panel/engine.rb
|
118
120
|
- lib/denshobato_chat_panel/react_helper.rb
|
119
121
|
- lib/denshobato_chat_panel/version.rb
|