Skip to content

Commit 6a81631

Browse files
committed
feat(textarea-skeleton): new hide-label attribute
1 parent 4ddc1a8 commit 6a81631

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

packages/web-components/src/components/textarea/__tests__/textarea-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ describe('cds-textarea', () => {
124124
expect(skeleton).to.exist;
125125
});
126126

127+
it('should support hide-label on skeleton variant', async () => {
128+
const el = await fixture(html`
129+
<cds-textarea-skeleton></cds-textarea-skeleton>
130+
`);
131+
132+
await el.updateComplete;
133+
134+
const label = el.shadowRoot?.querySelector(`.cds--label.cds--skeleton`);
135+
expect(label).to.exist;
136+
137+
const elHiddenLabel = await fixture(html`
138+
<cds-textarea-skeleton hide-label></cds-textarea-skeleton>
139+
`);
140+
141+
await elHiddenLabel.updateComplete;
142+
143+
// label should not render when hide-label is true
144+
const hiddenLabel = elHiddenLabel.shadowRoot?.querySelector(
145+
`.cds--label.cds--skeleton`
146+
);
147+
expect(hiddenLabel).to.not.exist;
148+
});
149+
127150
it('should be accessible', async () => {
128151
const el = await fixture(html`
129152
<cds-textarea

packages/web-components/src/components/textarea/textarea-skeleton.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
2-
* Copyright IBM Corp. 2019, 2023
2+
* Copyright IBM Corp. 2019, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
77

88
import { LitElement, html } from 'lit';
9+
import { property } from 'lit/decorators.js';
910
import { prefix } from '../../globals/settings';
1011
import styles from './textarea.scss?lit';
1112
import { carbonElement as customElement } from '../../globals/decorators/carbon-element';
@@ -17,9 +18,18 @@ import { carbonElement as customElement } from '../../globals/decorators/carbon-
1718
*/
1819
@customElement(`${prefix}-textarea-skeleton`)
1920
class CDSTextareaSkeleton extends LitElement {
21+
/**
22+
* Specify whether the label should be hidden, or not
23+
*/
24+
@property({ type: Boolean, reflect: true, attribute: 'hide-label' })
25+
hideLabel = false;
26+
2027
render() {
28+
const { hideLabel } = this;
2129
return html`
22-
<span class="${prefix}--label ${prefix}--skeleton"></span>
30+
${hideLabel
31+
? ''
32+
: html`<span class="${prefix}--label ${prefix}--skeleton"></span>`}
2333
<div class="${prefix}--skeleton ${prefix}--text-area"></div>
2434
`;
2535
}

packages/web-components/src/components/textarea/textarea.stories.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,19 @@ export const Default = {
191191
};
192192

193193
export const Skeleton = {
194+
args,
195+
argTypes,
194196
parameters: {
195197
percy: {
196198
skip: true,
197199
},
200+
controls: {
201+
include: ['hideLabel'],
202+
},
198203
},
199-
render: () => html` <cds-textarea-skeleton></cds-textarea-skeleton> `,
204+
render: ({ hideLabel }) => html`
205+
<cds-textarea-skeleton ?hide-label=${hideLabel}></cds-textarea-skeleton>
206+
`,
200207
};
201208

202209
export const WithAILabel = {

0 commit comments

Comments
 (0)