Skip to content

Commit f5be94a

Browse files
committed
fix(input-group): replace fluent border with box-shadow
1 parent c01572b commit f5be94a

File tree

4 files changed

+122
-94
lines changed

4 files changed

+122
-94
lines changed

src/components/combo/themes/shared/combo.fluent.scss

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ $dropdown-theme: dropdown-theme.$fluent;
2727

2828
igc-input::part(container) {
2929
background: transparent;
30-
border-inline-start: 0;
31-
border-inline-end-color: transparent;
32-
border-block-start: 0;
3330
border-radius: 0;
31+
32+
&::before {
33+
// The color value of the shadow is set by the color prop set by the input-group::before
34+
// Here we only change the shadow to look like border bottom
35+
box-shadow: inset 0 rem(-1px) 0 0;
36+
border-radius: 0;
37+
}
38+
}
39+
40+
igc-input:focus-within::part(container) {
41+
&::before {
42+
// The color value of the shadow is set by the color prop set by the input-group::before
43+
// Here we only change the shadow to look like border bottom
44+
box-shadow: inset 0 rem(-2px) 0 0;
45+
}
3446
}
3547

3648
igc-input::part(start) {
@@ -87,13 +99,7 @@ $dropdown-theme: dropdown-theme.$fluent;
8799

88100
igc-input::part(suffix) {
89101
height: var(--size);
90-
margin-inline-end: rem(-1px);
91-
margin-block-start: rem(-2px);
92-
}
93102

94-
igc-input::part(prefix) {
95-
margin-inline-start: rem(-1px);
96-
margin-block-start: rem(-2px);
97103
}
98104
}
99105

src/components/input/themes/shared/input.fluent.scss

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
@use '../light/themes' as *;
33

44
$theme: $fluent;
5-
$resting-border-width: rem(1px);
6-
$focused-border-width: rem(2px);
7-
$resting-height: calc(var-get($theme, 'size') - #{($resting-border-width * 2)});
8-
$focused-height: calc(var-get($theme, 'size') - #{($focused-border-width * 2)});
5+
$border-size: rem(1px);
96

107
:host {
118
--component-size: var(--ig-size, #{var-get($theme, 'default-size')});
@@ -16,6 +13,7 @@ $focused-height: calc(var-get($theme, 'size') - #{($focused-border-width * 2)});
1613
[part='suffix'] {
1714
font-size: rem(14px);
1815
cursor: default;
16+
z-index: 0;
1917

2018
::slotted(*) {
2119
color: inherit;
@@ -59,17 +57,34 @@ $focused-height: calc(var-get($theme, 'size') - #{($focused-border-width * 2)});
5957

6058
[part^='container'] {
6159
height: var-get($theme, 'size');
62-
border-radius: var-get($theme, 'border-border-radius');
63-
border: #{$resting-border-width} solid var-get($theme, 'border-color');
60+
background: var-get($theme, 'border-background');
6461
transition: none;
6562
cursor: text;
6663
grid-template-columns: auto 1fr auto;
6764
overflow: hidden;
65+
66+
&::before {
67+
content: '';
68+
position: absolute;
69+
inset: 0;
70+
width: 100%;
71+
height: 100%;
72+
73+
// The color: here is the actual box-shadow color. If we don't provide color-value to the shadow it
74+
// defaults to the css color: prop the same way as border-color: do.
75+
// We do this in order to have the shadow working correctly inside the Combo search
76+
// We can't change the var-get($theme, 'border-color') in the combo search, but we can change the shadow
77+
color: var-get($theme, 'border-color');
78+
box-shadow: inset 0 0 0 $border-size;
79+
border-radius: var-get($theme, 'border-border-radius');
80+
user-select: none;
81+
pointer-events: none;
82+
z-index: 1;
83+
}
6884
}
6985

7086
[part~='input'] {
7187
color: var-get($theme, 'idle-text-color');
72-
height: $resting-height;
7388
background: initial;
7489
font-size: rem(14px);
7590
padding-inline: rem(8px);
@@ -100,26 +115,27 @@ $focused-height: calc(var-get($theme, 'size') - #{($focused-border-width * 2)});
100115

101116
:host(:hover) {
102117
[part^='container'] {
103-
border-color: var-get($theme, 'hover-border-color');
118+
&::before {
119+
// The color: here is the actual box-shadow color. If we don't provide color-value to the shadow it
120+
// defaults to the css color: prop the same way as border-color: do.
121+
// We do this in order to have the shadow working correctly inside the Combo search
122+
// We can't change the var-get($theme, 'hover-border-color') in the combo search, but we can change the shadow
123+
color: var-get($theme, 'hover-border-color');
124+
box-shadow: inset 0 0 0 $border-size;
125+
}
104126
}
105127
}
106128

107129
:host(:focus-within) {
108130
[part^='container'] {
109-
border-color: var-get($theme, 'focused-border-color');
110-
border-width: #{$focused-border-width};
111-
}
112-
113-
[part~='input'] {
114-
height: $focused-height;
115-
}
116-
117-
[part='prefix'] {
118-
margin-inline-start: rem(-1px);
119-
}
120-
121-
[part='suffix'] {
122-
margin-inline-end: rem(-1px);
131+
&::before {
132+
// The color: here is the actual box-shadow color. If we don't provide color-value to the shadow it
133+
// defaults to the css color: prop the same way as border-color: do.
134+
// We do this in order to have the shadow working correctly inside the Combo search
135+
// We can't change the var-get($theme, 'focused-border-color') in the combo search, but we can change the shadow
136+
color: var-get($theme, 'focused-border-color');
137+
box-shadow: inset 0 0 0 calc($border-size + #{rem(1px)}),
138+
}
123139
}
124140

125141
[name='prefix']::slotted(*),
@@ -166,15 +182,23 @@ $focused-height: calc(var-get($theme, 'size') - #{($focused-border-width * 2)});
166182
:host([invalid]:hover),
167183
:host([readonly][invalid]:hover),
168184
:host([readonly][invalid]:focus-within) {
169-
[part^='container'] {
170-
border-color: var-get($theme, 'error-secondary-color');
185+
::part(helper-text) {
186+
color: var-get($theme, 'error-secondary-color');
187+
}
188+
189+
[part~='container'] {
190+
&::before {
191+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'error-secondary-color')
192+
}
171193
}
172194
}
173195

174196
:host(:disabled),
175197
:host([disabled]) {
176-
[part^='container'] {
177-
border-color: var-get($theme, 'disabled-border-color');
198+
[part~='container'] {
199+
&::before {
200+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'disabled-border-color');
201+
}
178202
}
179203

180204
[part^='container'],

src/components/select/themes/shared/select.fluent.scss

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
$theme: $fluent;
77
$dropdown-theme: dropdown-theme.$fluent;
88
$input-theme: input-theme.$fluent;
9-
$focused-border-width: rem(2px);
109

1110
:host {
1211
--component-size: var(--ig-size, #{var-get($theme, 'default-size')});
@@ -39,25 +38,6 @@ $focused-border-width: rem(2px);
3938
[part~='toggle-icon'] {
4039
background: var-get($theme, 'toggle-button-background-focus');
4140
}
42-
43-
igc-input[readonly]:not([disabled])::part(container) {
44-
border-width: #{$focused-border-width};
45-
}
46-
}
47-
48-
:host(:not([invalid]):focus-within) {
49-
igc-input[readonly]:not([disabled])::part(container) {
50-
border-color: var-get($input-theme, 'focused-border-color');
51-
border-width: #{$focused-border-width};
52-
}
53-
54-
igc-input[readonly]:not([disabled])::part(prefix) {
55-
margin-inline-start: rem(-1px);
56-
}
57-
58-
igc-input[readonly]:not([disabled])::part(suffix) {
59-
margin-inline-end: rem(-1px);
60-
}
6141
}
6242

6343
:host([invalid]:not([disabled])),

src/components/textarea/themes/shared/textarea.fluent.scss

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use '../light/themes' as *;
33

44
$theme: $fluent;
5+
$border-size: rem(1px);
56

67
:host {
78
@include type-style('body-2');
@@ -17,60 +18,62 @@ $theme: $fluent;
1718
}
1819
}
1920

20-
:host(:hover) {
21-
[part~='container'] {
22-
border-color: var-get($theme, 'hover-border-color');
23-
}
24-
}
25-
26-
:host(:focus-within) {
27-
[part~='container'] {
28-
border-color: var-get($theme, 'focused-border-color');
29-
border-width: rem(2px);
30-
}
21+
[part~='label'] {
22+
@include type-style('subtitle-2') {
23+
--ig-subtitle-2-line-height: #{rem(16px)};
3124

32-
[part~='prefix']:not([hidden]) {
33-
margin-inline-start: rem(-1px);
34-
}
25+
margin-block: 0 rem(5px);
26+
};
3527

36-
[part~='suffix']:not([hidden]) {
37-
margin-inline-end: rem(-1px);
38-
}
28+
display: block;
29+
position: static;
30+
transform: translateY(0);
31+
transform-origin: top left;
32+
height: auto;
3933

40-
textarea {
41-
margin-block: rem(-1px);
42-
margin-inline-start: rem(-1px);
43-
}
4434

45-
[part~='prefix']:not([hidden]) ~ textarea {
46-
margin-inline: initial;
47-
}
4835
}
4936

5037
[part~='container'] {
51-
border: rem(1px) solid var-get($theme, 'border-color');
38+
position: relative;
5239
background: var-get($theme, 'border-background');
5340
align-items: stretch;
5441
overflow: hidden;
5542
border-radius: var-get($theme, 'border-border-radius');
56-
}
57-
58-
[part~='label'] {
59-
@include type-style('subtitle-2') {
60-
--ig-subtitle-2-line-height: #{rem(16px)};
6143

62-
margin-block: 0 rem(5px);
63-
};
44+
&::before {
45+
content: '';
46+
position: absolute;
47+
inset: 0;
48+
width: 100%;
49+
height: 100%;
50+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'border-color');
51+
border-radius: var-get($theme, 'border-border-radius');
52+
user-select: none;
53+
pointer-events: none;
54+
z-index: 1;
55+
}
56+
}
6457

65-
display: block;
66-
position: static;
67-
transform: translateY(0);
68-
transform-origin: top left;
69-
height: auto;
7058

59+
:host(:hover) {
60+
[part~='container'] {
61+
&::before {
62+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'hover-border-color');
63+
}
64+
}
65+
}
7166

67+
:host(:focus-within) {
68+
[part~='container'] {
69+
&::before {
70+
box-shadow: 0 0 0 $border-size var-get($theme, 'focused-border-color'),
71+
inset 0 0 0 calc($border-size + #{rem(1px)}) var-get($theme, 'focused-border-color');
72+
}
73+
}
7274
}
7375

76+
7477
:host([invalid]) {
7578
[part~='label'] {
7679
color: var-get($theme, 'idle-text-color');
@@ -99,14 +102,29 @@ textarea {
99102
}
100103

101104
[part~='container'] {
102-
border-color: var-get($theme, 'error-secondary-color');
105+
&::before {
106+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'error-secondary-color')
107+
}
108+
}
109+
}
110+
111+
:host(:not(:disabled)[invalid]:focus-within),
112+
:host(:not([disabled])[invalid]:focus-within) {
113+
[part^='container'] {
114+
&::before {
115+
box-shadow: 0 0 0 $border-size var-get($theme, 'error-secondary-color'),
116+
inset 0 0 0 calc($border-size + #{rem(1px)}) var-get($theme, 'error-secondary-color');
117+
}
103118
}
104119
}
105120

106121
:host(:disabled),
107122
:host([disabled]) {
108123
[part~='container'] {
109-
border-color: var-get($theme, 'disabled-border-color');
110124
background: var-get($theme, 'border-disabled-background');
125+
126+
&::before {
127+
box-shadow: inset 0 0 0 $border-size var-get($theme, 'disabled-border-color');
128+
}
111129
}
112130
}

0 commit comments

Comments
 (0)