Skip to content

Commit

Permalink
feat: 适配深色模式(svg还未适配)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saltro committed Apr 16, 2023
1 parent 67f4aab commit 21506a0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ import './assets/default.less';
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-bg);
}
:deep(*) {
color: var(--color-text);
}
</style>
4 changes: 4 additions & 0 deletions assets/default.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
padding: 0;
font-family: -apple-system, 'PingFang SC', 'Microsoft Yahei', Arial, Helvetica, sans-serif, system-ui;
}

:root {
color-scheme: light dark;
}
15 changes: 15 additions & 0 deletions assets/var.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
:root {
--color-primary: #01579B;
--color-bg: #FFFFFF;
--color-text: #000000;
--color-input-bg: rgba(0, 123, 221, 0.05);
--border-radius-m: 10px;
--border-radius-l: 20px;
Expand All @@ -9,3 +11,16 @@
--color-disabled: rgba(0, 0, 0, 0.25);
--color-disabled-bg: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
:root {
--color-bg: #0D0D0D;
--color-text: #FFFFFF;
--color-primary: #0167B4;
--color-input-bg: #222222;
--color-secondary: #888888;
--color-button-secondary-bg: #262626;
--color-disabled: rgba(255, 255, 255, 0.82);
--color-disabled-bg: #000000;
}
}
6 changes: 6 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
border-radius: var(--border-radius-m);
font-size: 15px;
background-color: var(--color-input-bg);
&::placeholder,
&::-webkit-input-placeholder,
&:-moz-placeholder {
color: var(--color-secondary);
}
}
:deep(label) {
Expand Down

0 comments on commit 21506a0

Please sign in to comment.