-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): created abstract factory for animations
BREAKING CHANGE: Removed `CollapseFromTop` Animation. Use `animateScale()` instead. BREAKING CHANGE: Removed `TranslateFromLeft` and `TranslateFromRight` components. Use `animateTranslate('left')` and `animateTranslate('right')` instead. EX-5355
- Loading branch information
1 parent
6a28bcc
commit a6120c1
Showing
22 changed files
with
2,022 additions
and
1,671 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
...mponents/src/components/animations/__tests__/create-directional-animation-factory.spec.ts
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,47 @@ | ||
import { mount, Wrapper } from '@vue/test-utils'; | ||
import Vue from 'vue'; | ||
import { getDataTestSelector } from '../../../__tests__/utils'; | ||
import { createDirectionalAnimationFactory } from '../create-directional-animation-factory'; | ||
|
||
describe('testing animation abstract factory', () => { | ||
function renderAnimatedComponent(animationName: string): RenderApi { | ||
const wrapper = mount( | ||
{ | ||
template: ` | ||
<animationComponent data-test="animation-component"> | ||
<div v-if="open" data-test="animation-content"></div> | ||
</animationComponent> | ||
`, | ||
components: { | ||
animationComponent: createDirectionalAnimationFactory(animationName)() | ||
}, | ||
props: { | ||
open: { default: false } | ||
} | ||
}, | ||
{} | ||
); | ||
|
||
return { | ||
open(): void | Promise<void> { | ||
return wrapper.setProps({ open: true }); | ||
}, | ||
getContentWrapper(): Wrapper<Vue> { | ||
return wrapper.find(getDataTestSelector('animation-content')); | ||
} | ||
}; | ||
} | ||
|
||
it('renders the slots content.', async () => { | ||
const { open, getContentWrapper } = renderAnimatedComponent('my-animation'); | ||
|
||
expect(getContentWrapper().exists()).toBe(false); | ||
await open(); | ||
expect(getContentWrapper().exists()).toBe(true); | ||
}); | ||
}); | ||
|
||
interface RenderApi { | ||
open: () => void | Promise<void>; | ||
getContentWrapper: () => Wrapper<Vue>; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ges/x-components/src/components/animations/animate-clip-path/animate-clip-path.factory.ts
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,15 @@ | ||
import './animate-clip-path.style.scss'; | ||
import { createDirectionalAnimationFactory } from '../create-directional-animation-factory'; | ||
|
||
/** | ||
* Returns a transition component to wrap an element passed in the default slot and animating its | ||
* clip-path using inset and with the origin passed as parameter. | ||
* | ||
* @param animationOrigin - The origin of the animation. This means where the animation starts and | ||
* ends. For example 'left' makes the element to animate from the left. If not provided the default | ||
* value is 'top'. | ||
* @returns A Transition Component. | ||
* | ||
* @public | ||
*/ | ||
export const animateClipPath = createDirectionalAnimationFactory('animate-clip-path'); |
23 changes: 23 additions & 0 deletions
23
...ges/x-components/src/components/animations/animate-clip-path/animate-clip-path.style.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,23 @@ | ||
.x-animate-clip-path { | ||
&--enter-active, | ||
&--leave-active { | ||
transition: clip-path var(--x-duration-animation, 0.3s) ease-out; | ||
clip-path: inset(0 0 0 0 round var(--x-size-border-radius-animation-clip-path, 0)); | ||
} | ||
$p: &; | ||
&--enter, | ||
&--leave-to { | ||
&#{$p}--top { | ||
clip-path: inset(0 0 100% 0 round var(--x-size-border-radius-animation-clip-path, 0)); | ||
} | ||
&#{$p}--bottom { | ||
clip-path: inset(100% 0 0 0 round var(--x-size-border-radius-animation-clip-path, 0)); | ||
} | ||
&#{$p}--left { | ||
clip-path: inset(0 100% 0 0 round var(--x-size-border-radius-animation-clip-path, 0)); | ||
} | ||
&#{$p}--right { | ||
clip-path: inset(0 0 0 100% round var(--x-size-border-radius-animation-clip-path, 0)); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/x-components/src/components/animations/animate-scale/animate-scale.factory.ts
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,15 @@ | ||
import './animate-scale.style.scss'; | ||
import { createDirectionalAnimationFactory } from '../create-directional-animation-factory'; | ||
|
||
/** | ||
* Returns a transition component to wrap an element passed in the default slot and animating its | ||
* scale using transform and with the transform origin passed as parameter. | ||
* | ||
* @param animationOrigin - The origin of the transform animation. This means where the animation | ||
* starts and ends. For example 'left' makes the element to animate from the left. If not provided | ||
* the default value is 'top'. | ||
* @returns A Transition Component. | ||
* | ||
* @public | ||
*/ | ||
export const animateScale = createDirectionalAnimationFactory('animate-scale'); |
102 changes: 102 additions & 0 deletions
102
packages/x-components/src/components/animations/animate-scale/animate-scale.style.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,102 @@ | ||
@use "sass:math" as *; | ||
|
||
.x-animate-scale { | ||
$p: &; | ||
|
||
&--enter-active, | ||
&--leave-active, | ||
&--enter-active *, | ||
&--leave-active * { | ||
animation-duration: var(--x-duration-animation, 0.3s); | ||
animation-timing-function: linear; | ||
} | ||
|
||
&--enter-active, | ||
&--leave-active { | ||
&#{$p}--top, | ||
&#{$p}--bottom { | ||
animation-name: containerAnimationY; | ||
} | ||
&#{$p}--left, | ||
&#{$p}--right { | ||
animation-name: containerAnimationX; | ||
} | ||
overflow: hidden; | ||
} | ||
|
||
&--enter-active, | ||
&--leave-active { | ||
&#{$p}--top > *, | ||
&#{$p}--bottom > * { | ||
animation-name: contentAnimationY; | ||
} | ||
&#{$p}--left > *, | ||
&#{$p}--right > * { | ||
animation-name: contentAnimationX; | ||
} | ||
} | ||
|
||
&--leave-active, | ||
&--leave-active > * { | ||
animation-direction: reverse; | ||
} | ||
|
||
$origins: top, bottom, left, right; | ||
@each $origin in $origins { | ||
&--#{$origin} { | ||
&#{$p}--enter-active, | ||
&#{$p}--leave-active, | ||
&#{$p}--enter-active > *, | ||
&#{$p}--leave-active > * { | ||
transform-origin: $origin center; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@function easeInOut($x) { | ||
@if $x < 0.5 { | ||
@return 8 * $x * $x * $x * $x; | ||
} @else { | ||
$x: $x - 1; | ||
@return 1 - (8 * $x * $x * $x * $x); | ||
} | ||
} | ||
$steps: 18; | ||
@keyframes containerAnimationY { | ||
@for $step from 0 through $steps { | ||
$scale: easeInOut(div($step, $steps)); | ||
#{$step * div(100, $steps)}% { | ||
transform: scaleY(#{$scale}); | ||
} | ||
} | ||
} | ||
|
||
@keyframes contentAnimationY { | ||
@for $step from 0 through $steps { | ||
$scale: easeInOut(div($step, $steps)); | ||
$invScale: if($scale > 0, div(1, $scale), 99999999); | ||
#{$step * div(100, $steps)}% { | ||
transform: scaleY(#{$invScale}); | ||
} | ||
} | ||
} | ||
|
||
@keyframes containerAnimationX { | ||
@for $step from 0 through $steps { | ||
$scale: easeInOut(div($step, $steps)); | ||
#{$step * div(100, $steps)}% { | ||
transform: scaleX(#{$scale}); | ||
} | ||
} | ||
} | ||
|
||
@keyframes contentAnimationX { | ||
@for $step from 0 through $steps { | ||
$scale: easeInOut(div($step, $steps)); | ||
$invScale: if($scale > 0, div(1, $scale), 99999999); | ||
#{$step * div(100, $steps)}% { | ||
transform: scaleX(#{$invScale}); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ges/x-components/src/components/animations/animate-translate/animate-translate.factory.ts
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,15 @@ | ||
import './animate-translate.style.scss'; | ||
import { createDirectionalAnimationFactory } from '../create-directional-animation-factory'; | ||
|
||
/** | ||
* Returns a transition component to wrap an element passed in the default slot and animating its | ||
* translate using transform and with the transform origin passed as parameter. | ||
* | ||
* @param animationOrigin - The origin of the transform animation. This means where the animation | ||
* starts and ends. For example 'left' makes the element to animate from the left. If not provided | ||
* the default value is 'top'. | ||
* @returns A Transition Component. | ||
* | ||
* @public | ||
*/ | ||
export const animateTranslate = createDirectionalAnimationFactory('animate-translate'); |
24 changes: 24 additions & 0 deletions
24
...ges/x-components/src/components/animations/animate-translate/animate-translate.style.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,24 @@ | ||
.x-animate-translate { | ||
$p: &; | ||
|
||
&--enter-active, | ||
&--leave-active { | ||
transition: transform var(--x-duration-animation, 0.3s) ease-out; | ||
} | ||
|
||
&--enter, | ||
&--leave-to { | ||
&#{$p}--top { | ||
transform: translateY(-100%); | ||
} | ||
&#{$p}--bottom { | ||
transform: translateY(100%); | ||
} | ||
&#{$p}--left { | ||
transform: translateX(-100%); | ||
} | ||
&#{$p}--right { | ||
transform: translateX(100%); | ||
} | ||
} | ||
} |
93 changes: 0 additions & 93 deletions
93
packages/x-components/src/components/animations/collapse-from-top.vue
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.