Skip to content

Commit 12e4206

Browse files
susnuxbackportbot[bot]
authored andcommitted
refactor: use native CSS selectors for dark theme of input borders
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> [skip ci]
1 parent 0cc7a65 commit 12e4206

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

src/assets/input-border.scss

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,35 @@
22
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
6-
@mixin boxShadow($borderColor) {
7-
box-shadow: 0 -1px $borderColor,
8-
0 0 0 1px color-mix(in srgb, $borderColor, 65% transparent);
9-
}
10-
11-
@mixin boxShadowDark($borderColor) {
12-
box-shadow: 0 1px $borderColor,
13-
0 0 0 1px color-mix(in srgb, $borderColor, 65% transparent);
14-
}
155

166
/**
177
* Similar as inputBorder but without active styles.
188
*/
19-
@mixin inputLikeBorder($darkThemeSelector, $legacySelector, $borderColor: var(--color-border-maxcontrast)) {
9+
@mixin inputLikeBorder($legacySelector, $borderColor: var(--color-border-maxcontrast)) {
10+
--input-border-box-shadow-light: 0 -1px #{$borderColor},
11+
0 0 0 1px color-mix(in srgb, #{$borderColor}, 65% transparent);
12+
--input-border-box-shadow-dark: 0 1px #{$borderColor},
13+
0 0 0 1px color-mix(in srgb, #{$borderColor}, 65% transparent);
14+
--input-border-box-shadow: var(--input-border-box-shadow-light);
2015
border: none;
2116
border-radius: var(--border-radius-element);
22-
@include boxShadow($borderColor);
17+
box-shadow: var(--input-border-box-shadow);
2318

2419
&:hover:not([disabled]) {
2520
box-shadow: 0 0 0 1px $borderColor;
2621
}
2722

28-
@at-root #{$darkThemeSelector} #{&} {
29-
@include boxShadowDark($borderColor);
23+
// override with system theme
24+
@media (prefers-color-scheme: dark) {
25+
--input-border-box-shadow: var(--input-border-box-shadow-dark);
26+
}
27+
28+
// override with nextcloud theme
29+
@at-root [data-theme-dark] #{&} {
30+
--input-border-box-shadow: var(--input-border-box-shadow-dark);
31+
}
32+
@at-root [data-theme-light] #{&} {
33+
--input-border-box-shadow: var(--input-border-box-shadow-light);
3034
}
3135

3236
@at-root #{$legacySelector} #{&} {
@@ -42,8 +46,8 @@
4246
* Create a consistent border for an input element.
4347
* With Nextcloud 32+ there is no real border anymore but we use a box-shadow.
4448
*/
45-
@mixin inputBorder($darkThemeSelector, $legacySelector, $borderColor: var(--color-border-maxcontrast)) {
46-
@include inputLikeBorder($darkThemeSelector, $legacySelector, $borderColor);
49+
@mixin inputBorder($legacySelector, $borderColor: var(--color-border-maxcontrast)) {
50+
@include inputLikeBorder($legacySelector, $borderColor);
4751

4852
&:focus-within:not([disabled]),
4953
&:active:not([disabled]) {

src/components/NcInputField/NcInputField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export default {
412412
}
413413
414414
&__input {
415-
@include border.inputBorder('.input-field--dark', '.input-field--legacy', var(--input-border-color));
415+
@include border.inputBorder('.input-field--legacy', var(--input-border-color));
416416
background-color: var(--color-main-background);
417417
color: var(--color-main-text);
418418
border-radius: var(--input-border-radius);

src/components/NcSelect/NcSelect.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ export default {
325325
<VueSelect
326326
class="select"
327327
:class="{
328-
'select--dark': isDark,
329328
'select--legacy': isLegacy,
330329
'select--no-wrap': noWrap,
331330
'user-select': userSelect,
@@ -1228,7 +1227,7 @@ body {
12281227
}
12291228
12301229
.vs__dropdown-toggle {
1231-
@include border.inputLikeBorder('.select--dark', '.select--legacy', var(--vs-border-color));
1230+
@include border.inputLikeBorder('.select--legacy', var(--vs-border-color));
12321231
}
12331232
12341233
.vs__dropdown-menu {

0 commit comments

Comments
 (0)