Skip to content

Commit 58f5d39

Browse files
committed
Icons in uu-base & reset state timeout
1 parent 3a9970a commit 58f5d39

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { svg } from 'lit';
2+
3+
export default svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
4+
<path d="M461.884 68.14c-132.601 81.297-228.817 183.87-272.048 235.345l-105.874-82.95-46.751 37.691 182.941 186.049c31.485-80.646 131.198-238.264 252.956-350.252L461.884 68.14z"/>
5+
</svg>`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { svg } from 'lit';
2+
3+
export default svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
4+
<path d="M422.952 371.305L307.064 255.418l115.884-115.887-51.722-51.723L255.34 203.693 139.457 87.812l-51.726 51.719 115.885 115.885L87.731 371.305l51.726 51.721L255.344 307.14l115.884 115.882z"/>
5+
</svg>`;

packages/uui-button/lib/button-icons.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
InterfaceLookType,
1010
InterfaceLookDefaultValue,
1111
} from '@umbraco-ui/uui-base/lib/types';
12-
import { iconCheck, iconWrong } from './button-icons';
12+
import IconCheck from '@umbraco-ui/uui-base/lib/svgs/icon-check';
13+
import IconWrong from '@umbraco-ui/uui-base/lib/svgs/icon-wrong';
1314

1415
export type UUIButtonState = null | 'waiting' | 'success' | 'failed';
1516

@@ -433,12 +434,17 @@ export class UUIButtonElement extends LabelMixin('', LitElement) {
433434
}
434435
}
435436

437+
private _resetStateTimeout?: number;
438+
436439
// Reset the state after 2sec if it is 'success' or 'failed'.
437440
updated(changedProperties: any) {
438441
if (changedProperties.has('state')) {
439-
this.disabled = !!this.state;
442+
clearTimeout(this._resetStateTimeout);
440443
if (this.state === 'success' || this.state === 'failed') {
441-
setTimeout(() => (this.state = null), 2000);
444+
this._resetStateTimeout = setTimeout(
445+
() => (this.state = null),
446+
2000
447+
) as any;
442448
}
443449
}
444450
}
@@ -450,10 +456,10 @@ export class UUIButtonElement extends LabelMixin('', LitElement) {
450456
element = html`<uui-loader-circle id="loader"></uui-loader-circle>`;
451457
break;
452458
case 'success':
453-
element = html`<div id="icon-check" style="">${iconCheck}</div>`;
459+
element = html`<div id="icon-check" style="">${IconCheck}</div>`;
454460
break;
455461
case 'failed':
456-
element = html`<div id="icon-wrong" style="">${iconWrong}</div>`;
462+
element = html`<div id="icon-wrong" style="">${IconWrong}</div>`;
457463
break;
458464
default:
459465
return '';

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,21 @@ export const Sizing: Story = props => {
141141
<uui-button
142142
style="font-size:9px; font-weight:bold;"
143143
look=${props.look}
144+
state=${props.state}
144145
?disabled=${props.disabled}
145146
?compact=${props.compact}
146147
label=${props.label}></uui-button>
147148
<uui-button
148149
style="font-size:12px"
149150
look=${props.look}
151+
state=${props.state}
150152
?disabled=${props.disabled}
151153
?compact=${props.compact}
152154
label=${props.label}></uui-button>
153155
<uui-button
154156
style="font-size:15px"
155157
look=${props.look}
158+
state=${props.state}
156159
?disabled=${props.disabled}
157160
?compact=${props.compact}
158161
label=${props.label}></uui-button>
@@ -187,7 +190,12 @@ export const Looks: Story = props => html`
187190
<h5>Looks</h5>
188191
${InterfaceLookNames.map(
189192
(lookName: InterfaceLookType) =>
190-
html`<uui-button .look=${lookName} style="margin-right:12px;">
193+
html`<uui-button
194+
.look=${lookName}
195+
state=${props.state}
196+
?disabled=${props.disabled}
197+
?compact=${props.compact}
198+
style="margin-right:12px;">
191199
${uppercaseFirstLetter(lookName)} look
192200
</uui-button>`
193201
)}

0 commit comments

Comments
 (0)