Skip to content

Commit 8eab46a

Browse files
committed
refactor(textarea): simplify textarea selectors
1 parent 9056b87 commit 8eab46a

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/components/textarea/textarea.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ export default class IgcTextareaComponent extends FormAssociatedRequiredMixin(
456456
part=${partNameMap({
457457
...this.resolvePartNames(),
458458
labelled: this.label,
459+
placeholder: this.placeholder,
459460
})}
460461
>
461462
<div part="start">${this.renderPrefix()}</div>

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ textarea {
3535

3636
[part='label'] {
3737
position: absolute;
38+
transform-origin: top left;
3839
top: calc($input-top-padding - #{rem(2px)});
3940
padding-inline-end: rem(4px);
4041
transition:
4142
transform 150ms cubic-bezier(.4, 0, .2, 1),
4243
color 150ms cubic-bezier(.4, 0, .2, 1),
4344
font-size 150ms cubic-bezier(.4, 0, .2, 1);
44-
will-change: font-size, color, transform;
45+
will-change: transform;
4546
}
4647

4748
%label-filled {
@@ -51,13 +52,12 @@ textarea {
5152
}
5253

5354
%label-outlined-filled {
54-
top: 0;
55+
display: inline-block;
56+
position: relative;
57+
inset-block: 0;
5558
transform: translateY(-50%);
5659
margin-block-end: auto;
5760
padding-inline-end: 0;
58-
display: inline-block;
59-
position: relative;
60-
background: transparent;
6161
font-size: rem(12px);
6262
}
6363

@@ -235,10 +235,6 @@ textarea {
235235
background: var-get($theme, 'border-background');
236236
overflow: initial;
237237

238-
[part~='labelled']:not([part~='filled']):has(textarea:not(:placeholder-shown)):not(:focus-within) {
239-
grid-template-columns: auto 1fr 1fr auto;
240-
}
241-
242238
[part~='container'] {
243239
grid-template-columns: auto auto 1fr auto;
244240
display: grid;
@@ -251,14 +247,16 @@ textarea {
251247
}
252248
}
253249

254-
textarea:placeholder-shown + [part='notch'] [part='label'],
255-
textarea:placeholder-shown ~ [part='notch'] [part='label'],
256-
[part~='filled'] [part='notch'] [part='label'] {
257-
@extend %label-outlined-filled;
250+
[part~='container'][part~='filled'],
251+
[part~='container'][part~='placeholder'] {
252+
[part='notch'] {
253+
border-block-start-color: transparent;
254+
}
258255
}
259256

260-
[part~='labelled']:not([part~='filled']):has(textarea:not(:placeholder-shown)):not(:focus-within) [part='notch'] {
261-
border-block: rem(1px) solid var-get($theme, 'border-color');
257+
[part~='placeholder'] [part='label'],
258+
[part~='filled'] [part='label'] {
259+
@extend %label-outlined-filled;
262260
}
263261

264262
[part='start'] {
@@ -294,8 +292,7 @@ textarea {
294292
}
295293

296294
[part='notch'] {
297-
border-block-start-color: transparent;
298-
border-block-end: rem(1px) solid var-get($theme, 'border-color');
295+
border-block: rem(1px) solid var-get($theme, 'border-color');
299296
padding: 0 rem(4px);
300297

301298
&:empty {
@@ -349,6 +346,7 @@ textarea {
349346
}
350347

351348
[part='notch'] {
349+
border-block-start-color: transparent;
352350
border-block-end-color: var-get($theme, 'focused-border-color');
353351
}
354352

@@ -395,11 +393,13 @@ textarea {
395393
:host([invalid][outlined]:not([disabled]):focus-within) {
396394
[part='start'],
397395
[part='filler'],
398-
[part='notch'],
399-
[part='end'],
400-
[part~='labelled']:not([part~='filled']):has(textarea:not(:placeholder-shown)):not(:focus-within) [part='notch'] {
396+
[part='end'] {
401397
border-color: var-get($theme, 'error-secondary-color');
402398
}
399+
400+
[part='notch'] {
401+
border-block-end-color: var-get($theme, 'error-secondary-color');
402+
}
403403
}
404404

405405
:host(:disabled[outlined]),

stories/textarea.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { sourceCode } from '@igniteui/material-icons-extended';
22
import type { Meta, StoryObj } from '@storybook/web-components';
3-
import { html, render } from 'lit';
3+
import { html, nothing, render } from 'lit';
44

55
import {
66
IgcIconComponent,
@@ -267,7 +267,7 @@ export const Default: Story = {
267267
name=${ifDefined(args.name)}
268268
label=${args.label}
269269
rows=${args.rows}
270-
placeholder=${args.placeholder}
270+
placeholder=${args.placeholder || nothing}
271271
resize=${args.resize}
272272
value=${ifDefined(args.value)}
273273
minlength=${ifDefined(args.minLength)}

0 commit comments

Comments
 (0)