Skip to content

Commit 50478de

Browse files
SisIvanovadesig9steinsimeonoff
authored
feat(textarea): readonly styles (#1768)
* feat(textarea): readonly styles * fix(textarea): stories * fix(textarea): bootstrap focused styles --------- Co-authored-by: Marin Popov <[email protected]> Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent ca6fc20 commit 50478de

File tree

7 files changed

+106
-14
lines changed

7 files changed

+106
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ $transition-duration: .25s;
167167
}
168168
}
169169

170-
:host(:not([aria-haspopup='dialog'],[role='combobox'])[readonly]) {
170+
:host(:not([aria-haspopup='dialog'],[role='combobox'],[disabled])[readonly]) {
171171
[part^='container'] {
172172
border-color: var-get($theme, 'disabled-text-color');
173173
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ textarea {
117117
}
118118
}
119119

120+
:host([readonly]) {
121+
[part~='prefix'],
122+
[part~='suffix'],
123+
textarea {
124+
background: var-get($theme, 'border-disabled-background');
125+
}
126+
127+
[part~='prefix'],
128+
[part~='suffix'] {
129+
color: var-get($theme, 'disabled-text-color');
130+
}
131+
}
132+
120133
:host([invalid]:not(:disabled)),
121134
:host([invalid]:not([disabled])) {
122135
textarea {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ textarea {
4646
}
4747
}
4848

49-
:host(:hover),
49+
:host([readonly]) {
50+
[part='prefix'],
51+
[part='suffix'] {
52+
color: var-get($theme, 'disabled-text-color');
53+
}
54+
}
55+
56+
:host(:not([readonly]):hover),
5057
:host(:focus) {
5158
textarea {
5259
&::placeholder {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ $border-size: rem(1px);
7171
}
7272
}
7373

74+
:host([readonly]) {
75+
[part='prefix'],
76+
[part='suffix'] {
77+
background: transparent;
78+
}
79+
}
80+
7481
:host([invalid]) {
7582
[part~='label'] {
7683
color: var-get($theme, 'idle-text-color');

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $theme: $indigo;
2424

2525
}
2626

27-
:host(:hover) {
27+
:host(:not([readonly], :focus-within):hover) {
2828
[part~='container'] {
2929
background: var-get($theme, 'box-background-hover');
3030

@@ -38,7 +38,8 @@ $theme: $indigo;
3838
}
3939
}
4040

41-
:host(:focus-within) {
41+
:host(:focus-within),
42+
:host([readonly]:focus-within) {
4243
[part~='label'] {
4344
color: var-get($theme, 'focused-secondary-color');
4445
}
@@ -135,6 +136,12 @@ textarea {
135136
height: calc(100% - #{rem(1px)});
136137
}
137138

139+
:host([readonly]) {
140+
[part~='container']::after {
141+
border-block-end-color: var-get($theme, 'disabled-text-color');
142+
}
143+
}
144+
138145
:host([invalid]:not(:disabled)),
139146
:host([invalid]:not([disabled])) {
140147
::part(validation-icon) {

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

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ textarea {
9595
}
9696
}
9797

98-
:host(:not([outlined]):hover) {
98+
:host(:not([outlined], [readonly]):hover) {
9999
[part~='container'] {
100100
background: var-get($theme, 'box-background-hover');
101101

@@ -138,10 +138,14 @@ textarea {
138138
}
139139
}
140140

141-
:host(:focus-within) {
141+
:host(:not([readonly]):focus-within) {
142142
[part~='label'] {
143143
@extend %label-filled;
144+
}
145+
}
144146

147+
:host(:focus-within) {
148+
[part~='label'] {
145149
color: var-get($theme, 'focused-secondary-color');
146150
}
147151
}
@@ -160,7 +164,9 @@ textarea {
160164
);
161165
}
162166
}
167+
}
163168

169+
:host(:not([outlined], [readonly]):focus-within) {
164170
[part~='prefix'] {
165171
color: var-get($theme, 'input-prefix-color--focused');
166172
background: var-get($theme, 'input-prefix-background--focused');
@@ -172,6 +178,12 @@ textarea {
172178
}
173179
}
174180

181+
:host(:not([outlined], [disabled])[readonly]) {
182+
[part~='container'] {
183+
background: var-get($theme, 'box-background-focus');
184+
}
185+
}
186+
175187
:host([invalid]:not([outlined]):focus-within) {
176188
[part~='container'] {
177189
&::after {
@@ -335,7 +347,7 @@ textarea {
335347
}
336348
}
337349

338-
:host([outlined]:hover) {
350+
:host(:not([readonly], :focus-within)[outlined]:hover) {
339351
[part='notch'],
340352
[part='start'],
341353
[part='end'],
@@ -351,22 +363,64 @@ textarea {
351363
}
352364
}
353365

354-
:host([outlined]:focus-within) {
355-
[part='filler'],
366+
:host(:not([readonly])[outlined]:focus-within) {
367+
[part='label'] {
368+
@extend %label-outlined-filled;
369+
}
370+
356371
[part='notch'] {
357-
border-block-width: rem(2px);
372+
border-block-start-color: transparent;
358373
}
374+
}
359375

376+
:host([readonly][outlined]) {
377+
[part~='container'][part~='filled'],
378+
[part~='container'][part~='placeholder'] {
379+
[part='label'] {
380+
@extend %label-outlined-filled;
381+
}
382+
383+
[part='notch'] {
384+
border-block-start-color: transparent;
385+
}
386+
}
387+
}
388+
389+
:host([readonly][outlined]:focus-within) {
360390
[part='label'] {
361-
@extend %label-outlined-filled;
391+
inset-block-start: calc($input-top-padding - #{rem(3px)});
392+
}
393+
394+
[part='notch'] {
395+
border-block-start-color: var-get($theme, 'focused-border-color');
396+
}
397+
}
398+
399+
:host(:not(:disabled)[readonly][outlined][invalid]:focus-within),
400+
:host(:not([disabled])[readonly][outlined][invalid]:focus-within) {
401+
[part='notch'] {
402+
border-block-start-color: var-get($theme, 'error-secondary-color');
403+
}
404+
405+
[part~='container'][part~='filled'],
406+
[part~='container'][part~='placeholder'] {
407+
[part='notch'] {
408+
border-block-start-color: transparent;
409+
}
410+
}
411+
}
412+
413+
:host([outlined]:focus-within) {
414+
[part='filler'],
415+
[part='notch'] {
416+
border-block-width: rem(2px);
362417
}
363418

364419
[part='filler'] {
365420
border-block-color: var-get($theme, 'focused-border-color');
366421
}
367422

368423
[part='notch'] {
369-
border-block-start-color: transparent;
370424
border-block-end-color: var-get($theme, 'focused-border-color');
371425
}
372426

stories/textarea.stories.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,16 @@ export const Default: Story = {
261261
?invalid=${args.invalid}
262262
?validate-only=${args.validateOnly}
263263
?spellcheck=${args.spellcheck}
264-
></igc-textarea>
264+
>
265+
<igc-icon name="source-code" aria-hidden="true" slot="prefix"></igc-icon>
266+
<igc-icon name="source-code" aria-hidden="true" slot="suffix"></igc-icon>
267+
</igc-textarea>
265268
`,
266269
};
267270

268271
export const ProjectContent: Story = {
269272
render: (
270-
{ rows, resize, required, disabled, outlined },
273+
{ rows, resize, required, disabled, outlined, readOnly },
271274
{ globals: { direction } }
272275
) => {
273276
return html`
@@ -276,6 +279,7 @@ export const ProjectContent: Story = {
276279
dir=${direction}
277280
spellcheck="false"
278281
.outlined=${outlined}
282+
?readonly=${readOnly}
279283
autofocus
280284
label="Leave your comment"
281285
.rows=${rows}

0 commit comments

Comments
 (0)