Skip to content

Commit ebd8378

Browse files
susnuxbackportbot[bot]
authored andcommitted
feat: create sharedscss mixin for input border styles
This provides proper styles for input like elements with respect for dark theme and legacy Nextcloud version. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 192292e commit ebd8378

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/assets/input-border.scss

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
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+
}
15+
16+
/**
17+
* Similar as inputBorder but without active styles.
18+
*/
19+
@mixin inputLikeBorder($darkThemeSelector, $legacySelector, $borderColor: var(--color-border-maxcontrast)) {
20+
border: none;
21+
border-radius: var(--border-radius-element);
22+
@include boxShadow($borderColor);
23+
24+
&:hover:not([disabled]) {
25+
box-shadow: 0 0 0 1px $borderColor;
26+
}
27+
28+
@at-root #{$darkThemeSelector} #{&} {
29+
@include boxShadowDark($borderColor);
30+
}
31+
32+
@at-root #{$legacySelector} #{&} {
33+
box-shadow: 0 0 0 1px $borderColor;
34+
35+
&:hover:not([disabled]) {
36+
box-shadow: 0 0 0 2px $borderColor;
37+
}
38+
}
39+
}
40+
41+
/**
42+
* Create a consistent border for an input element.
43+
* With Nextcloud 32+ there is no real border anymore but we use a box-shadow.
44+
*/
45+
@mixin inputBorder($darkThemeSelector, $legacySelector, $borderColor: var(--color-border-maxcontrast)) {
46+
@include inputLikeBorder($darkThemeSelector, $legacySelector, $borderColor);
47+
48+
&:focus-within:not([disabled]),
49+
&:active:not([disabled]) {
50+
box-shadow: 0 0 0 2px $borderColor,
51+
0 0 0 4px var(--color-main-background) !important;
52+
}
53+
}

0 commit comments

Comments
 (0)