Skip to content

Commit 475268b

Browse files
committed
add error property to select + stories for disabled and error
1 parent 8c32fc2 commit 475268b

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ export class UUISelectElement extends LabelMixin('label', LitElement) {
8888
span.label {
8989
display: inline-block;
9090
}
91+
92+
:host([error]) #native {
93+
border: 1px solid var(--uui-look-danger-border);
94+
}
95+
96+
:host([error]) #native[disabled] {
97+
border: 1px solid var(--uui-look-danger-border);
98+
}
9199
`,
92100
];
93101

@@ -120,6 +128,15 @@ export class UUISelectElement extends LabelMixin('label', LitElement) {
120128
@property({ type: Boolean, reflect: true })
121129
disabled = false;
122130

131+
/**
132+
* Set to true if the component should have an error state.Property is reflected to the corresponding attribute.
133+
* @type {boolean}
134+
* @attr
135+
* @default false
136+
*/
137+
@property({ type: Boolean, reflect: true })
138+
error = false;
139+
123140
/**
124141
* This is the name property of the uui-checkbox or the uui-toggle component. It reflects the behaviour of the native input type="checkbox" element and its name attribute.
125142
* @type {string}

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
label: 'Favorite green',
3030
placeholder: 'Select an option',
3131
disabled: false,
32+
error: false,
3233
name: 'Favorite Green',
3334
value: '',
3435
},
@@ -59,7 +60,8 @@ export const AAAOverview: Story = props =>
5960
.options=${options}
6061
.placeholder=${props.placeholder}
6162
.disabled=${props.disabled}
62-
.label=${props.label}></uui-select>`;
63+
.label=${props.label}
64+
?error=${props.error}></uui-select>`;
6365
AAAOverview.storyName = 'Overview';
6466

6567
export const Preselected: Story = () =>
@@ -133,7 +135,7 @@ DisabledGroups.parameters = {
133135

134136
export const Disabled: Story = props =>
135137
html`<uui-select
136-
.options=${groupedOptions}
138+
.options=${options}
137139
label="Label"
138140
.placeholder=${props.placeholder}
139141
.disabled=${props.disabled}></uui-select> `;
@@ -151,3 +153,24 @@ Disabled.parameters = {
151153
},
152154
},
153155
};
156+
157+
export const Error: Story = props =>
158+
html`<uui-select
159+
.options=${options}
160+
label="Label"
161+
.placeholder=${props.placeholder}
162+
?error=${props.error}></uui-select>`;
163+
164+
Error.args = {
165+
error: true,
166+
};
167+
168+
Error.parameters = {
169+
controls: { include: ['error'] },
170+
docs: {
171+
source: {
172+
code: `
173+
<uui-select error></uui-select>`,
174+
},
175+
},
176+
};

0 commit comments

Comments
 (0)