Skip to content

Commit 6b0f985

Browse files
committed
(refactor) theme colors
1 parent 91a0e11 commit 6b0f985

File tree

5 files changed

+42
-27
lines changed

5 files changed

+42
-27
lines changed

src/ChatWindow/ChatMessage.vue

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

src/ChatWindow/ChatWindow.vue

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +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'
38+
import { defaultThemeColors, cssThemeVars } from '../themes'
3939
4040
export default {
4141
name: 'chat-container',
@@ -54,7 +54,7 @@ export default {
5454
showFiles: { type: Boolean, default: true },
5555
showEmojis: { type: Boolean, default: true },
5656
textMessages: { type: Object, default: null },
57-
theme: { type: String, default: 'light' },
57+
theme: { type: String, default: 'dark' },
5858
colors: { type: Object, default: null }
5959
},
6060
@@ -93,20 +93,11 @@ export default {
9393
},
9494
cssVars() {
9595
const themeColors = {
96-
...themes[this.theme],
96+
...defaultThemeColors[this.theme],
9797
...this.colors
9898
}
9999
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-
}
100+
return cssThemeVars(themeColors)
110101
}
111102
},
112103
@@ -148,8 +139,8 @@ export default {
148139
border-radius: 4px;
149140
display: block;
150141
max-width: 100%;
151-
background: var(--bg-color);
152-
color: var(--color);
142+
background: var(--chat-bg-color);
143+
color: var(--chat-color);
153144
overflow-wrap: break-word;
154145
position: relative;
155146
white-space: normal;

src/ChatWindow/MessagesList.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ export default {
447447
}
448448
449449
.container-scroll {
450-
background: var(--bg-color-content);
450+
background: var(--chat-bg-color-content);
451451
height: calc(100% - 120px);
452452
overflow-y: auto;
453453
}
@@ -469,7 +469,7 @@ export default {
469469
position: absolute;
470470
bottom: 0;
471471
width: 100%;
472-
background: var(--color-input);
472+
background: var(--chat-color-input);
473473
border-top: 1px solid #d3dde7;
474474
z-index: 10;
475475
}
@@ -484,8 +484,8 @@ export default {
484484
}
485485
486486
textarea {
487-
background: var(--color-input);
488-
color: var(--color);
487+
background: var(--chat-color-input);
488+
color: var(--chat-color);
489489
margin: 2px;
490490
padding: 15px 15px 5px 10px;
491491
overflow: hidden;

src/ChatWindow/RoomsList.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export default {
137137
}
138138
139139
input {
140-
background: var(--color-input);
140+
background: var(--chat-color-input);
141141
border-radius: 4px;
142142
margin: 0 10px;
143143
}
@@ -160,7 +160,7 @@ input {
160160
flex: 0 1 auto;
161161
position: relative;
162162
max-width: 100%;
163-
background: var(--text-color);
163+
background: var(--chat-text-color);
164164
cursor: pointer;
165165
166166
:not(:hover) {
@@ -169,18 +169,18 @@ input {
169169
}
170170
171171
:hover {
172-
background: var(--bg-color-hover);
172+
background: var(--chat-bg-color-hover);
173173
-webkit-transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
174174
transition: background-color 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
175175
}
176176
}
177177
178178
.room-selected {
179-
color: var(--color-active) !important;
180-
background: var(--bg-color-active) !important;
179+
color: var(--chat-color-active) !important;
180+
background: var(--chat-bg-color-active) !important;
181181
182182
:hover {
183-
background: var(--bg-color-active);
183+
background: var(--chat-bg-color-active);
184184
}
185185
}
186186

src/themes/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
export const defaultThemeColors = {
22
light: {
33
headerBg: '#fff',
44
sidemenuBg: '#fff',
@@ -22,3 +22,27 @@ export default {
2222
inputBg: '#34343b'
2323
}
2424
}
25+
26+
export const cssThemeVars = ({
27+
headerBg,
28+
sidemenuBg,
29+
sidemenuBgHover,
30+
sidemenuBgActive,
31+
sidemenuColorActive,
32+
messagesBg,
33+
textColorDark,
34+
textColor,
35+
inputBg
36+
}) => {
37+
return {
38+
'--chat-header-bg-color': headerBg,
39+
'--chat-bg-color': sidemenuBg,
40+
'--chat-bg-color-hover': sidemenuBgHover,
41+
'--chat-bg-color-active': sidemenuBgActive,
42+
'--chat-bg-color-content': messagesBg,
43+
'--chat-color-dark': textColorDark,
44+
'--chat-color': textColor,
45+
'--chat-color-active': sidemenuColorActive,
46+
'--chat-color-input': inputBg
47+
}
48+
}

0 commit comments

Comments
 (0)