Skip to content

Commit 1e01dcb

Browse files
WingSMCGergely Dremakjustin-schroeder
authored
Angular 17.1+ support (#206)
* Angular >v17.1 support * angular example rewrite * Angular docs change * Update package.json * angular pnpm-lock & usage import fix * ' -> " typo fix --------- Co-authored-by: Gergely Dremak <[email protected]> Co-authored-by: Justin Schroeder <[email protected]>
1 parent 61455c8 commit 1e01dcb

File tree

5 files changed

+52
-4694
lines changed

5 files changed

+52
-4694
lines changed

docs/src/examples/angular/index.ts

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
11
const angularDirectiveMain = {
2-
angular: {
3-
ext: "angular",
4-
language: "jsx",
5-
example: `import { NgModule } from '@angular/core';
6-
import { AutoAnimateModule } from '@formkit/auto-animate/angular'
7-
8-
@NgModule({
9-
declarations: [AppComponent],
10-
imports: [BrowserModule, AutoAnimateModule],
11-
bootstrap: [AppComponent],
12-
})
13-
export class AppModule {}
14-
`,
15-
},
16-
}
17-
18-
const angularDirectiveApp = {
192
angular: {
203
ext: "angular",
214
language: "jsx",
225
example: `import { Component } from '@angular/core';
6+
import { AutoAnimateDirective } from '@formkit/auto-animate/angular';
237
248
@Component({
259
selector: 'app-root',
10+
standalone: true,
11+
imports: [AutoAnimateDirective],
2612
template: \`
27-
<div *ngFor="let story of stories">
28-
<div class="story-card" auto-animate>
29-
<h2>{{ story.title }}</h2>
30-
<div *ngIf="story.showStory">{{ story.story }}</div>
31-
<button (click)="story.showStory = !story.showStory">Toggle story</button>
13+
@for (story of stories; track story.title) {
14+
<div>
15+
<div class="story-card" auto-animate>
16+
<h2>{{ story.title }}</h2>
17+
@if (story.showStory) {
18+
<div>{{ story.story }}</div>
19+
}
20+
<button (click)="story.showStory = !story.showStory">Toggle story</button>
21+
</div>
3222
</div>
33-
</div>
34-
\`
23+
}
24+
\`,
3525
})
3626
export class AppComponent {
37-
stories = [
27+
readonly stories = [
3828
{title: 'The Ant and The Grasshopper', showStory: false, story: "The ant and the grasshopper were good friends..."},
3929
{title: 'The Boy Who Cried Wolf', showStory: false, story: "There was once a shepherd boy who liked to play tricks..."},
4030
];
41-
}`,
31+
}
32+
`,
4233
},
4334
}
44-
export { angularDirectiveMain, angularDirectiveApp }
35+
export { angularDirectiveMain }

docs/src/sections/SectionUsage.vue

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
vueDirectiveApp,
99
vueComposable,
1010
} from "../examples/vue"
11-
import { angularDirectiveMain, angularDirectiveApp } from "../examples/angular"
11+
import { angularDirectiveMain } from "../examples/angular"
1212
import { solidPrimitive, solidDirective } from "../examples/solid"
1313
import reactHook from "../examples/react"
1414
import preactHook from "../examples/preact"
@@ -160,14 +160,16 @@ import IconQwik from "../components/IconQwik.vue"
160160
<h2 id="usage-vue">Vue directive</h2>
161161
<p>
162162
Vue users can globally register the
163-
<code>v-auto-animate</code> directive or install the Nuxt module. This makes adding transitions and
164-
animations as easy as applying an attribute. Import the Vue plugin from
165-
<code>@formkit/auto-animate/vue</code> and register it with your Vue app:
163+
<code>v-auto-animate</code> directive or install the Nuxt module. This
164+
makes adding transitions and animations as easy as applying an attribute.
165+
Import the Vue plugin from <code>@formkit/auto-animate/vue</code> and
166+
register it with your Vue app:
166167
</p>
167168
<CodeExample :examples="vueDirectiveMain" title="main" />
168169
<AsideTip>
169170
If you prefer to not register the Vue directive globally, you can import
170-
it directly into the component where you want to use it <code>import { vAutoAnimate } from '@formkit/auto-animate'</code>.
171+
it directly into the component where you want to use it
172+
<code>import { vAutoAnimate } from '@formkit/auto-animate'</code>.
171173
</AsideTip>
172174
<p>
173175
Once you’ve registered the plugin, it can be applied anywhere in your
@@ -194,8 +196,8 @@ import IconQwik from "../components/IconQwik.vue"
194196
</p>
195197
<p>
196198
Import the composable from <code>@formkit/auto-animate/vue</code> (the
197-
Nuxt module will automatically import <code>useAutoAnimate</code> for you), and
198-
call it in <code>script setup</code> to create a
199+
Nuxt module will automatically import <code>useAutoAnimate</code> for
200+
you), and call it in <code>script setup</code> to create a
199201
<a
200202
href="https://vuejs.org/guide/essentials/template-refs.html#template-refs"
201203
target="_blank"
@@ -256,24 +258,24 @@ import IconQwik from "../components/IconQwik.vue"
256258

257259
<h2 id="usage-angular">Angular directive</h2>
258260
<p>
259-
Angular users can globally register the
260-
<code>auto-animate</code> directive. This makes adding transitions and
261-
animations as easy as applying an attribute. Import the AutoAnimateModule
262-
from <code>@formkit/auto-animate/angular</code> and register it with your
263-
Angular app:
261+
Import <code>AutoAnimateDirective</code> from
262+
<code>@formkit/auto-animate/angular</code> into a module or a standalone
263+
component to easily add transitions and animations by applying the
264+
<code>auto-animate</code> attribute to the parent element in your
265+
template:
264266
</p>
265267
<CodeExample :examples="angularDirectiveMain" title="App" />
266-
<p>
267-
Once you’ve registered the plugin, it can be applied anywhere in your
268-
application by adding the <code>auto-animate</code> directive to the
269-
parent element:
270-
</p>
271-
<CodeExample :examples="angularDirectiveApp" title="App" />
272268
<ActualAngularApp />
273269
<AsideTip>
274270
Angular users can pass options by directly setting the options input
275271
<code>&lt;ul auto-animate [options]="{ duration: 100 }"&gt;</code>
276272
</AsideTip>
273+
<AsideTip>
274+
In Angular versions &lt;16 you can only import
275+
<code>AutoAnimateModule</code> in <code>NgModule</code>s. And you have to
276+
use auto-animate v0.8.2 or earlier. Angular v16 isn't directly supported,
277+
but you can easily write a wrapper.
278+
</AsideTip>
277279

278280
<!-- <h2 id="usage-qwik">Qwik hook</h2>
279281
<p>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
}
7373
},
7474
"devDependencies": {
75-
"@angular/core": "^13.4.0",
75+
"@angular/core": "^17.1.0",
7676
"@formkit/vue": "^1.6.5",
7777
"@nuxt/kit": "^3.12.4",
7878
"@nuxt/module-builder": "^0.8.3",

0 commit comments

Comments
 (0)