Skip to content

Commit c371aa8

Browse files
committed
Add a prop & story for the timeout delay for the animation/state of the button
1 parent c72d0b7 commit c371aa8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ export class UUICopyElement extends LabelMixin('', LitElement) {
7474
@property({ type: Boolean })
7575
compact = false;
7676

77+
/**
78+
* The delay in milliseconds before the button returns to its default state after a successful copy
79+
* @type {number}
80+
* @attr
81+
* @default 250
82+
*/
83+
@property({ type: Number, attribute: 'animation-state-delay' })
84+
animationStateDelay = 250;
85+
7786
constructor() {
7887
super();
7988
demandCustomElement(this, 'uui-button');
@@ -130,7 +139,7 @@ export class UUICopyElement extends LabelMixin('', LitElement) {
130139
);
131140
setTimeout(() => {
132141
button.state = 'success';
133-
}, 2000);
142+
}, this.animationStateDelay);
134143
})
135144
.catch(err => {
136145
button.state = 'failed';

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

+15
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,18 @@ export const CopyFromInput: Story = {
204204
},
205205
},
206206
};
207+
208+
export const AnimationDelay: Story = {
209+
name: 'Animation Delay',
210+
args: {
211+
value: 'A long 3 second delay',
212+
animationStateDelay: 3000,
213+
},
214+
parameters: {
215+
docs: {
216+
source: {
217+
code: `<uui-copy value="A long 3 second delay" animation-state-delay="3000"></uui-copy>`,
218+
},
219+
},
220+
},
221+
};

0 commit comments

Comments
 (0)