-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add animation to popover components (#974)
* feat(popover): add animation control to Popover Canvas and Popover Menu stories * feat(popover): add animation prop to Popover components for open/close effects * feat(utils): add generateClassList function for dynamic class name generation * feat(popover): add fade animations for popover visibility transitions * feat(popover): add animation property to control opening/closing animations * feat(popover): change animation control from select to radio for Popover Canvas and Menu stories * refactor(popover): clean up fade animation styles in SCSS
- Loading branch information
Showing
11 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,9 @@ export class TdsPopoverCanvas { | |
/** Sets the offset skidding */ | ||
@Prop() offsetSkidding: number = 0; | ||
|
||
/** Whether the popover should animate when being opened/closed or not */ | ||
@Prop() animation: 'none' | 'fade' | string = 'none'; | ||
|
||
/** Sets the offset distance */ | ||
@Prop() offsetDistance: number = 8; | ||
|
||
|
@@ -76,6 +79,7 @@ export class TdsPopoverCanvas { | |
this.childRef = el; | ||
}} | ||
defaultShow={this.defaultShow} | ||
animation={this.animation} | ||
> | ||
<div> | ||
{/* (@stencil/[email protected]): This div is somehow needed to keep the slotted children in a predictable order */} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/core/src/components/popover-core/tds-popover-core.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@import '../../global/global'; | ||
|
||
:host { | ||
pointer-events: none; | ||
display: block; | ||
} | ||
|
||
:host(.tds-animation-enter-fade) { | ||
animation: tds-fade-in var(--tds-motion-duration-moderate-01) var(--tds-motion-easing-enter) | ||
forwards; | ||
} | ||
|
||
:host(.tds-animation-exit-fade) { | ||
animation: tds-fade-out var(--tds-motion-duration-moderate-01) var(--tds-motion-easing-exit) | ||
forwards; | ||
} | ||
|
||
:host(.is-shown) { | ||
opacity: 1; | ||
pointer-events: auto; | ||
visibility: visible; | ||
} | ||
|
||
:host(.is-hidden) { | ||
opacity: 0; | ||
pointer-events: none; | ||
visibility: hidden; | ||
} | ||
|
||
:host(.initially-hidden) { | ||
opacity: 0; | ||
pointer-events: none; | ||
visibility: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Generates a string of class names by filtering out keys from the `classes` object | ||
* whose values evaluate to `false`. The keys that remain will be joined with a space. | ||
* | ||
* @param classes - An object where keys represent class names and values are boolean | ||
* flags indicating whether to include the class name. | ||
* @returns A string of class names separated by spaces. | ||
* | ||
* @example | ||
* const classes = { | ||
* 'active': true, | ||
* 'disabled': false, | ||
* 'highlighted': true, | ||
* }; | ||
* const classList = generateClassList(classes); | ||
* console.log(classList); // Output: "active highlighted" | ||
*/ | ||
export const generateClassList = (classes: Record<string, boolean>): string => { | ||
return Object.keys(classes) | ||
.filter((key) => classes[key]) | ||
.join(' '); | ||
}; |