Skip to content

Commit da9151a

Browse files
authored
feat(uui-button): add transition property (#771)
* cleanup * add transition and focus visible styles * feat: ✨ add transition custom property to uui-button
1 parent def0263 commit da9151a

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

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

+15-19
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type UUIButtonType = 'submit' | 'button' | 'reset';
4747
* @cssprop --uui-button-contrast-hover - overwrite the text color for hover state
4848
* @cssprop --uui-button-contrast-disabled - overwrite the text color for disabled state
4949
* @cssprop --uui-button-content-align - Overwrite justify-content alignment. Possible values: 'left', 'right', 'center'.
50+
* @cssprop --uui-button-transition - Add transition to the button. Default is none.
5051
*/
5152
@defineElement('uui-button')
5253
export class UUIButtonElement extends UUIFormControlMixin(
@@ -335,7 +336,14 @@ export class UUIButtonElement extends UUIFormControlMixin(
335336
calc(var(--uui-size-2) * var(--uui-button-padding-left-factor));
336337
337338
box-shadow: none;
339+
340+
transition: var(--uui-button-transition, none);
341+
}
342+
343+
#button:focus-visible {
344+
outline: 2px solid var(--color-emphasis);
338345
}
346+
339347
button[disabled]:active,
340348
a:not([href]):active {
341349
animation: ${UUIHorizontalShakeAnimationValue};
@@ -354,25 +362,6 @@ export class UUIButtonElement extends UUIFormControlMixin(
354362
color: inherit;
355363
}
356364
357-
/* ANIMATIONS */
358-
@keyframes fadeIn {
359-
0% {
360-
opacity: 0;
361-
}
362-
100% {
363-
opacity: 1;
364-
}
365-
}
366-
367-
@keyframes fadeOut {
368-
0% {
369-
opacity: 1;
370-
}
371-
100% {
372-
opacity: 0;
373-
}
374-
}
375-
376365
/* edge case for default color */
377366
:host(:not([color]):not([look='primary'])),
378367
:host([color='']:not([look='primary'])),
@@ -452,6 +441,7 @@ export class UUIButtonElement extends UUIFormControlMixin(
452441
/* special for primary: */
453442
font-weight: var(--uui-button-font-weight, 700);
454443
}
444+
455445
:host([look='primary']:hover) #button {
456446
background-color: var(
457447
--uui-button-background-color-hover,
@@ -460,6 +450,12 @@ export class UUIButtonElement extends UUIFormControlMixin(
460450
color: var(--uui-button-contrast-hover, var(--color-contrast));
461451
border-color: var(--uui-button-border-color-hover, transparent);
462452
}
453+
454+
/* special outline offset tof primary style so you can see the outline */
455+
:host([look='primary']) #button:focus-visible {
456+
outline-offset: 2px;
457+
}
458+
463459
:host([look='primary'][disabled]) #button {
464460
background-color: var(
465461
--uui-button-background-color-disabled,

0 commit comments

Comments
 (0)