Skip to content

Commit 91a0e11

Browse files
committed
(feat) add theme colors
1 parent 32a2795 commit 91a0e11

File tree

6 files changed

+65
-16
lines changed

6 files changed

+65
-16
lines changed

demo/src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ body {
109109
110110
.app-container {
111111
font-family: 'Roboto', sans-serif;
112-
color: rgba(0, 0, 0, 0.87);
113112
line-height: 1.5;
114113
padding: 10px 20px 20px;
115114
}

src/ChatWindow/ChatMessage.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export default {
244244
245245
.message-card {
246246
background: #fff;
247+
color: var(--color-dark);
247248
border-radius: 4px;
248249
font-size: 14px;
249250
padding: 8px 8px 3px;

src/ChatWindow/ChatWindow.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="card-window" :style="{ height }">
2+
<div class="card-window" :style="[{ height }, cssVars]">
33
<div class="chat-container">
44
<rooms-list
55
:rooms="rooms"
@@ -35,6 +35,7 @@ import RoomsList from './RoomsList'
3535
import MessagesList from './MessagesList'
3636
const { roomsValid, partcipantsValid } = require('../utils/roomValidation')
3737
import locales from '../locales'
38+
import themes from '../themes'
3839
3940
export default {
4041
name: 'chat-container',
@@ -52,7 +53,9 @@ export default {
5253
menuActions: { type: Array, default: () => [] },
5354
showFiles: { type: Boolean, default: true },
5455
showEmojis: { type: Boolean, default: true },
55-
textMessages: { type: Object, default: null }
56+
textMessages: { type: Object, default: null },
57+
theme: { type: String, default: 'light' },
58+
colors: { type: Object, default: null }
5659
},
5760
5861
data() {
@@ -87,6 +90,23 @@ export default {
8790
...locales,
8891
...this.textMessages
8992
}
93+
},
94+
cssVars() {
95+
const themeColors = {
96+
...themes[this.theme],
97+
...this.colors
98+
}
99+
100+
return {
101+
'--bg-color': themeColors.sidemenuBg,
102+
'--bg-color-hover': themeColors.sidemenuBgHover,
103+
'--bg-color-active': themeColors.sidemenuBgActive,
104+
'--bg-color-content': themeColors.messagesBg,
105+
'--color-dark': themeColors.textColorDark,
106+
'--color': themeColors.textColor,
107+
'--color-active': themeColors.sidemenuColorActive,
108+
'--color-input': themeColors.inputBg
109+
}
90110
}
91111
},
92112
@@ -128,7 +148,8 @@ export default {
128148
border-radius: 4px;
129149
display: block;
130150
max-width: 100%;
131-
background: #fff;
151+
background: var(--bg-color);
152+
color: var(--color);
132153
overflow-wrap: break-word;
133154
position: relative;
134155
white-space: normal;

src/ChatWindow/MessagesList.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</transition>
3434
</div>
3535
</div>
36-
<div class="chat-background container-scroll">
36+
<div class="container-scroll">
3737
<div class="messages-container">
3838
<chat-loader :show="loadingMessages"></chat-loader>
3939
<transition name="fade">
@@ -446,11 +446,8 @@ export default {
446446
margin: 0;
447447
}
448448
449-
.chat-background {
450-
background-color: #f8f9fa !important;
451-
}
452-
453449
.container-scroll {
450+
background: var(--bg-color-content);
454451
height: calc(100% - 120px);
455452
overflow-y: auto;
456453
}
@@ -472,7 +469,7 @@ export default {
472469
position: absolute;
473470
bottom: 0;
474471
width: 100%;
475-
background: #fff;
472+
background: var(--color-input);
476473
border-top: 1px solid #d3dde7;
477474
z-index: 10;
478475
}
@@ -487,6 +484,8 @@ export default {
487484
}
488485
489486
textarea {
487+
background: var(--color-input);
488+
color: var(--color);
490489
margin: 2px;
491490
padding: 15px 15px 5px 10px;
492491
overflow: hidden;

src/ChatWindow/RoomsList.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ export default {
136136
display: flex;
137137
}
138138
139+
input {
140+
background: var(--color-input);
141+
border-radius: 4px;
142+
margin: 0 10px;
143+
}
144+
139145
.rooms-empty {
140146
font-size: 14px;
141147
color: #9ca6af;
@@ -154,7 +160,7 @@ export default {
154160
flex: 0 1 auto;
155161
position: relative;
156162
max-width: 100%;
157-
background: #fff;
163+
background: var(--text-color);
158164
cursor: pointer;
159165
160166
:not(:hover) {
@@ -163,19 +169,18 @@ export default {
163169
}
164170
165171
:hover {
166-
background: #f6f6f6;
172+
background: var(--bg-color-hover);
167173
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
168174
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
169175
}
170176
}
171177
172178
.room-selected {
173-
color: #1976d2 !important;
174-
background: #e5effa !important;
179+
color: var(--color-active) !important;
180+
background: var(--bg-color-active) !important;
175181
176182
:hover {
177-
color: #1976d2;
178-
background: #e5effa;
183+
background: var(--bg-color-active);
179184
}
180185
}
181186

src/themes/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export default {
2+
light: {
3+
headerBg: '#fff',
4+
sidemenuBg: '#fff',
5+
sidemenuBgHover: '#f6f6f6',
6+
sidemenuBgActive: '#e5effa',
7+
sidemenuColorActive: '#1976d2',
8+
messagesBg: '#f8f9fa',
9+
textColorDark: '#0a0a0a',
10+
textColor: '#0a0a0a',
11+
inputBg: '#fff'
12+
},
13+
dark: {
14+
headerBg: '#26272e',
15+
sidemenuBg: '#26272e',
16+
sidemenuBgHover: '#202024',
17+
sidemenuBgActive: '#1C1D21',
18+
sidemenuColorActive: '#fff',
19+
messagesBg: '#1C1D21',
20+
textColorDark: '#0a0a0a',
21+
textColor: '#fff',
22+
inputBg: '#34343b'
23+
}
24+
}

0 commit comments

Comments
 (0)