Skip to content

Commit afff0cd

Browse files
committed
Dark mode for dashboard
1 parent 47ca6b2 commit afff0cd

File tree

9 files changed

+53
-10
lines changed

9 files changed

+53
-10
lines changed

src/_locales/de/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,8 @@
322322
"clearYoutube": {
323323
"message": "Clear YouTube",
324324
"description": "Chrome-Erweiterung, die YouTube-Shorts, empfohlene Videos, Kommentare, Feeds, Homepage-Empfehlungen und andere Ablenkungen ausblenden kann. Sieh dir YouTube ohne Ablenkungen an."
325+
},
326+
"darkTheme": {
327+
"message": "Dunkles Thema"
325328
}
326329
}

src/_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,8 @@
322322
"clearYoutube": {
323323
"message": "Clear YouTube",
324324
"description": "Chrome extension that can hide YouTube shorts, recomended videos, comments, feed, homepage recommendations and other distractions. Watch YouTube free of distractions."
325+
},
326+
"darkTheme": {
327+
"message": "Dark theme"
325328
}
326329
}

src/_locales/ru/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,5 +323,8 @@
323323
"clearYoutube": {
324324
"message": "Clear YouTube",
325325
"description": "Расширение для Chrome, которое может скрывать шортс YouTube, рекомендуемые видео, комментарии, ленту новостей, рекомендации по домашней странице и другие отвлекающие факторы. Смотрите YouTube без отвлекающих факторов."
326+
},
327+
"darkTheme": {
328+
"message": "Темная тема"
326329
}
327330
}

src/_locales/zh_CN/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,8 @@
322322
"clearYoutube": {
323323
"message": "Clear YouTube",
324324
"description": "Chrome扩展程序,可以隐藏YouTube短片,推荐视频,评论,feed,主页推荐和其他分心。 观看YouTube免费分心。"
325+
},
326+
"darkTheme": {
327+
"message": "黑暗主题"
325328
}
326329
}

src/assets/css/dark.css

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
color: white;
44
}
55
.dark .headerBlock .header {
6-
color: #ffffff;
6+
color: #ffffff !important;
77
}
88
.dark .headerBlock .icons-block a:hover{
99
filter: invert(40%) sepia(94%) saturate(3371%) hue-rotate(227deg) brightness(99%) contrast(92%);
@@ -24,7 +24,7 @@
2424
filter: invert(100%) sepia(17%) saturate(0%) hue-rotate(24deg) brightness(103%) contrast(102%);
2525
}
2626
.dark .stats-block .block p{
27-
color: #b9b9b9;
27+
color: #b9b9b9 !important;
2828
}
2929
.dark .stats-block .block .header {
3030
background-color: #595959;
@@ -35,11 +35,32 @@
3535
color: rgb(255 255 255);
3636
}
3737
.dark .stats-block.block p{
38-
color: #b9b9b9;
38+
color: #b9b9b9 !important;
3939
}
4040
.dark .expander-body{
41-
background-color: #595959;
41+
background-color: #595959 !important;
42+
}
43+
.dark .expander .header span{
44+
color: #b9b9b9 !important;
4245
}
4346
.dark .header span{
4447
color: rgb(255 255 255);
48+
}
49+
.dark .settings-tab label[name="tabName"] img{
50+
filter: invert(100%) sepia(17%) saturate(0%) hue-rotate(24deg) brightness(103%) contrast(102%);
51+
}
52+
.dark .settings-tab label[name="tabName"]{
53+
background-color: #303030 !important;
54+
}
55+
.dark .settings-content{
56+
background-color: #303030 !important;
57+
}
58+
.dark .app-block .title{
59+
color: black;
60+
}
61+
.dark .settings-tab label[name="tabName"]:hover, .dark [type='radio']:checked ~ label{
62+
background-color: #979797 !important;
63+
}
64+
.dark .container p.value{
65+
color: black;
4566
}

src/assets/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ label {
283283
}
284284
.settings-tab label[name='tabName']:hover {
285285
background-color: #cccccc !important;
286-
border-radius: 10px;
286+
border-radius: 10px;
287287
}
288288
.settings-tab [type='radio'] {
289289
display: none;

src/components/GeneralSettings.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</p>
3030
</label>
3131
</div>
32-
<!-- <div class="settings-item">
32+
<div class="settings-item">
3333
<label class="setting-header">
3434
<input
3535
type="checkbox"
@@ -38,10 +38,9 @@
3838
v-model="darkMode"
3939
@change="onChange(StorageParams.DARK_MODE, $event.target)"
4040
/>
41-
<span>Dark mode</span>
42-
<p class="description">Dark theme</p>
41+
<span>{{ t('darkTheme.message') }}</span>
4342
</label>
44-
</div> -->
43+
</div>
4544
<div class="settings-item">
4645
<label class="setting-header d-inline-block">{{ t('intervalInactivity.message') }} </label>
4746
<div class="d-inline-block ml-10">
@@ -156,6 +155,7 @@ import { FileType, useFile } from '../functions/useFile';
156155
import { useRemoveAllData } from '../functions/useRemoveAllData';
157156
import { injectTabsRepository } from '../repository/inject-tabs-repository';
158157
import { useRestoreData } from '../functions/useRestoreData';
158+
import { applyDarkMode } from '../utils/dark-mode';
159159
160160
const { t } = useI18n();
161161
@@ -202,6 +202,8 @@ async function onChange(storageParam: StorageParams, target: any) {
202202
storageParam,
203203
storageParam == StorageParams.INTERVAL_INACTIVITY ? Number(target.value) : target.checked,
204204
);
205+
206+
if (storageParam == StorageParams.DARK_MODE) applyDarkMode(target.checked);
205207
}
206208
207209
async function save(storageParam: StorageParams, value: any) {

src/dashboard.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<script type="module" src="./dashboard.ts"></script>
1212
</body>
1313

14+
<link rel="stylesheet" href="assets/css/dark.css" />
1415
<link rel="stylesheet" href="assets/css/dashboard.css" />
1516
<link rel="stylesheet" href="assets/css/general.css" />
1617
</html>

src/pages/Dashboard.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,26 @@ import { SettingsTab } from '../utils/enums';
146146
import DashboadContainer from '../components/DashboadContainer.vue';
147147
import { useExtensionPage } from '../compositions/useExtensionPage';
148148
import { getEnumValueTab } from '../utils/extension-tabs';
149+
import { applyDarkMode } from '../utils/dark-mode';
150+
import { injecStorage } from '../storage/inject-storage';
151+
import { StorageParams, DARK_MODE_DEFAULT } from '../storage/storage-params';
149152
150153
const { t } = useI18n();
151154
const extensionPage = useExtensionPage();
155+
const settingsStorage = injecStorage();
152156
153157
const selectedTab = ref<SettingsTab>();
154158
const currentUrl = ref(new URL(location.href));
155159
const selectedWebsite = ref<string>();
160+
const darkMode = ref<boolean>();
156161
157162
watch(currentUrl, () => {
158163
getCurrentTab();
159164
});
160165
161-
onMounted(() => {
166+
onMounted(async () => {
167+
darkMode.value = await settingsStorage.getValue(StorageParams.DARK_MODE, DARK_MODE_DEFAULT);
168+
applyDarkMode(darkMode.value!);
162169
getCurrentTab();
163170
});
164171

0 commit comments

Comments
 (0)