Skip to content

Commit 8122634

Browse files
committed
feat: toggling AnimationForm on 'Customize this animation' anchor click
1 parent 7dcac09 commit 8122634

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

docs/.vitepress/components/AnimationForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</script>
8484
8585
<template>
86-
<Container class="form--container">
86+
<Container class="form--container js-anim--collapsed">
8787
<div class="column">
8888
<div class="row">
8989
<FormField

docs/.vitepress/components/Container.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
border-radius: 0.5rem;
1111
padding: 1rem;
1212
margin: 1.5rem auto 3rem auto;
13+
min-width: 350px;
1314
}
1415
</style>

docs/.vitepress/components/Example.vue

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Button from './Button.vue';
44
import Content from './Content.vue';
55
import AnimationForm from './AnimationForm.vue';
6+
import jsCssAnimations from '../../../js-css-animations/js-css-animations';
67
78
defineEmits(['resetAnimation']);
89
</script>
@@ -11,6 +12,7 @@
1112
export default {
1213
props: {
1314
animationFn: Function,
15+
animationName: String,
1416
title: String,
1517
btnList: Array,
1618
contentList: Array,
@@ -19,6 +21,10 @@
1921
},
2022
mounted() {
2123
this.animationFn();
24+
jsCssAnimations.init.fade({
25+
trigger: `.customize--anchor__${this.animationName}`,
26+
targetSelector: `.customize--form__${this.animationName}`,
27+
});
2228
},
2329
methods: {
2430
titleId() {
@@ -34,12 +40,20 @@
3440
<template>
3541
<Container>
3642
<h3 :id="titleId()" class="title">{{ title }}</h3>
37-
<a href="#">Customize the animation</a>
38-
<AnimationForm
39-
:initial="animOpts"
40-
:fields-list="$props.fieldsList"
41-
@resetAnimation="opts => $emit('resetAnimation', opts)"
42-
/>
43+
<a
44+
href="#"
45+
class="customize--anchor"
46+
:class="`customize--anchor__${animationName}`"
47+
>Customize this animation</a
48+
>
49+
<div>
50+
<AnimationForm
51+
:class="`customize--form__${animationName}`"
52+
:initial="animOpts"
53+
:fields-list="$props.fieldsList"
54+
@resetAnimation="opts => $emit('resetAnimation', opts)"
55+
/>
56+
</div>
4357
<div class="buttons">
4458
<Button v-for="btn in btnList" v-bind="btn" />
4559
</div>
@@ -67,6 +81,11 @@
6781
6882
.title {
6983
margin-top: 0;
70-
margin-bottom: 1.5rem;
84+
margin-bottom: 1rem;
85+
}
86+
87+
.customize--anchor {
88+
display: flex;
89+
justify-content: right;
7190
}
7291
</style>

docs/.vitepress/components/FormField.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@
105105
}
106106
107107
input:focus,
108-
select:focus {
108+
select:focus,
109+
input:hover,
110+
select:hover {
109111
border: 1px solid var(--vp-c-green-lighter);
110112
}
111113

docs/examples/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ aside: false
119119

120120
<Example
121121
:animation-fn="slideAnimations"
122+
:animation-name="'slide'"
122123
:title="'Slide Animations'"
123124
:btn-list="examples.slide.btnList"
124125
:content-list="examples.slide.contentList"
@@ -150,6 +151,7 @@ jsCssAnimations.init.slideRight({
150151

151152
<Example
152153
:animation-fn="fadeAnimation"
154+
:animation-name="'fade'"
153155
:title="'Fade In / Out'"
154156
:btn-list="examples.fade.btnList"
155157
:content-list="examples.fade.contentList"
@@ -176,6 +178,7 @@ jsCssAnimations.init.fade({
176178

177179
<Example
178180
:animation-fn="collapseAnimation"
181+
:animation-name="'collapse'"
179182
:title="'Collapse/Expand'"
180183
:btn-list="examples.collapse.btnList"
181184
:content-list="examples.collapse.contentList"

0 commit comments

Comments
 (0)