Skip to content

Commit 8141eb7

Browse files
authored
fix: add background color in uui-textarea (#410)
* add css variable and use correct background variable * adds JSDocs and updates story
1 parent 02f17b9 commit 8141eb7

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

packages/uui-textarea/lib/uui-textarea.element.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins';
1111
* @fires KeyboardEvent#keyup on keyup
1212
* @cssprop --uui-textarea-min-height - Sets the minimum height of the textarea
1313
* @cssprop --uui-textarea-max-height - Sets the maximum height of the textarea
14+
* @cssprop {color} --uui-textarea-background-color - Sets the background color of the textarea
1415
*/
1516
@defineElement('uui-textarea')
1617
export class UUITextareaElement extends FormControlMixin(LitElement) {
@@ -77,6 +78,10 @@ export class UUITextareaElement extends FormControlMixin(LitElement) {
7778
outline: none;
7879
min-height: var(--uui-textarea-min-height);
7980
max-height: var(--uui-textarea-max-height);
81+
background-color: var(
82+
--uui-textarea-background-color,
83+
var(--uui-color-surface)
84+
);
8085
}
8186
:host(:hover)
8287
textarea:not([readonly]):not([disabled])

packages/uui-textarea/lib/uui-textarea.story.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@ export default {
1616
},
1717
};
1818

19-
export const AAAOverview: Story = props =>
20-
html`<uui-textarea
21-
style="--uui-textarea-min-height: ${props[
22-
'--uui-textarea-min-height'
23-
]}; --uui-textarea-max-height: ${props['--uui-textarea-max-height']}"
19+
export const AAAOverview: Story = props => {
20+
const minHeight = props['--uui-textarea-min-height'];
21+
const maxHeight = props['--uui-textarea-max-height'];
22+
const backgroundColor = props['--uui-textarea-background-color'];
23+
24+
const styles = `
25+
${minHeight ? `--uui-textarea-min-height: ${minHeight};` : ''}
26+
${maxHeight ? `--uui-textarea-max-height: ${maxHeight};` : ''}
27+
${
28+
backgroundColor
29+
? `--uui-textarea-background-color: ${backgroundColor};`
30+
: ''
31+
}
32+
`;
33+
return html`<uui-textarea
34+
style=${styles}
2435
.label=${props.label}
2536
?auto-height=${props.autoHeight}
2637
.minlength=${props.minlength}
@@ -31,18 +42,21 @@ export const AAAOverview: Story = props =>
3142
.name=${props.name}
3243
.error=${props.error}
3344
.value=${props.value}></uui-textarea>`;
45+
};
3446

3547
AAAOverview.storyName = 'Overview';
3648

3749
AAAOverview.args = {
3850
label: 'Label',
3951
'--uui-textarea-min-height': '',
4052
'--uui-textarea-max-height': '',
53+
'--uui-textarea-background-color': '',
4154
};
4255

4356
AAAOverview.argTypes = {
4457
'--uui-textarea-min-height': { control: { type: 'text' } },
4558
'--uui-textarea-max-height': { control: { type: 'text' } },
59+
'--uui-textarea-background-color': { control: { type: 'color' } },
4660
};
4761

4862
AAAOverview.parameters = {

0 commit comments

Comments
 (0)