-
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.
refactor(staggered-fade-and-slide): use Vue native staggered transition
- Loading branch information
1 parent
f915731
commit efc42f5
Showing
9 changed files
with
194 additions
and
736 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
68 changes: 68 additions & 0 deletions
68
packages/_vue3-migration-test/src/components/animations/test-staggered-fade-and-slide.vue
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,68 @@ | ||
<template> | ||
<h1>Dinamic content:</h1> | ||
<button @click="insert">Insert at random index</button> | ||
<button @click="reset">Reset</button> | ||
|
||
<StaggeredFadeAndSlide :stagger="500"> | ||
<li v-for="item in items" :key="item.id"> | ||
{{ item.id }} - {{ item.name }} | ||
<button @click="remove(item)">x</button> | ||
</li> | ||
</StaggeredFadeAndSlide> | ||
|
||
<br /> | ||
<h1>Animation as prop</h1> | ||
<BaseSuggestions :suggestions="suggestions" :animation="StaggeredFadeAndSlide" :stagger="50"> | ||
<template #default="{ suggestion }"> | ||
<span>{{ suggestion.query }}</span> | ||
</template> | ||
</BaseSuggestions> | ||
|
||
<br /> | ||
<h1>Static content:</h1> | ||
<StaggeredFadeAndSlide :stagger="50"> | ||
<li key="1">Element to animate</li> | ||
<li key="2">Element to animate</li> | ||
<li key="3">Element to animate</li> | ||
</StaggeredFadeAndSlide> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import StaggeredFadeAndSlide from '../../../../x-components/src/components/animations/staggered-fade-and-slide.vue'; | ||
import BaseSuggestions from '../../../../x-components/src/components/suggestions/base-suggestions.vue'; | ||
import { | ||
getQuerySuggestionsStub, | ||
createResultStub, | ||
getResultsStub | ||
} from '../../../../x-components/src/__stubs__'; | ||
const suggestions = getQuerySuggestionsStub('chip', 5); | ||
const getInitialItems = () => getResultsStub(5); | ||
const items = ref(getInitialItems()); | ||
let id = items.value.length + 1; | ||
/** | ||
* Insert a new item at a random index. | ||
*/ | ||
function insert() { | ||
const i = Math.round(Math.random() * items.value.length); | ||
items.value.splice(i, 0, createResultStub(`Product ${id++}`)); | ||
} | ||
/** | ||
* Reset the list of items. | ||
*/ | ||
function reset() { | ||
items.value = getInitialItems(); | ||
id = items.value.length + 1; | ||
} | ||
/** | ||
* Remove an item from the list. | ||
* | ||
* @param item - The item to remove. | ||
*/ | ||
function remove(item: any) { | ||
const i = items.value.indexOf(item); | ||
if (i > -1) { | ||
items.value.splice(i, 1); | ||
} | ||
} | ||
</script> |
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
204 changes: 0 additions & 204 deletions
204
...ages/x-components/src/components/animations/__tests__/staggering-transition-group.spec.ts
This file was deleted.
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
Oops, something went wrong.