Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit 42f05d9

Browse files
committed
feat: animate function and directive, demo
1 parent 736ca25 commit 42f05d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7450
-405
lines changed

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
singleQuote: true
2+
printWidth: 100
3+
trailingComma: none
4+
arrowParens: avoid

angular.json

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,154 @@
55
"packageManager": "yarn"
66
},
77
"newProjectRoot": "projects",
8-
"projects": {}
8+
"projects": {
9+
"ngx-css-anim": {
10+
"projectType": "library",
11+
"root": "projects/ngx-css-anim",
12+
"sourceRoot": "projects/ngx-css-anim/src",
13+
"prefix": "lib",
14+
"architect": {
15+
"build": {
16+
"builder": "@angular-devkit/build-ng-packagr:build",
17+
"options": {
18+
"tsConfig": "projects/ngx-css-anim/tsconfig.lib.json",
19+
"project": "projects/ngx-css-anim/ng-package.json"
20+
},
21+
"configurations": {
22+
"production": {
23+
"tsConfig": "projects/ngx-css-anim/tsconfig.lib.prod.json"
24+
}
25+
}
26+
},
27+
"test": {
28+
"builder": "@angular-devkit/build-angular:karma",
29+
"options": {
30+
"main": "projects/ngx-css-anim/src/test.ts",
31+
"tsConfig": "projects/ngx-css-anim/tsconfig.spec.json",
32+
"karmaConfig": "projects/ngx-css-anim/karma.conf.js"
33+
}
34+
},
35+
"lint": {
36+
"builder": "@angular-devkit/build-angular:tslint",
37+
"options": {
38+
"tsConfig": [
39+
"projects/ngx-css-anim/tsconfig.lib.json",
40+
"projects/ngx-css-anim/tsconfig.spec.json"
41+
],
42+
"exclude": [
43+
"**/node_modules/**"
44+
]
45+
}
46+
}
47+
}
48+
},
49+
"demo": {
50+
"projectType": "application",
51+
"schematics": {
52+
"@schematics/angular:component": {
53+
"style": "scss"
54+
}
55+
},
56+
"root": "projects/demo",
57+
"sourceRoot": "projects/demo/src",
58+
"prefix": "app",
59+
"architect": {
60+
"build": {
61+
"builder": "@angular-devkit/build-angular:browser",
62+
"options": {
63+
"outputPath": "dist/demo",
64+
"index": "projects/demo/src/index.html",
65+
"main": "projects/demo/src/main.ts",
66+
"polyfills": "projects/demo/src/polyfills.ts",
67+
"tsConfig": "projects/demo/tsconfig.app.json",
68+
"aot": true,
69+
"assets": [
70+
"projects/demo/src/favicon.ico",
71+
"projects/demo/src/assets"
72+
],
73+
"styles": [
74+
"projects/demo/src/styles.scss"
75+
],
76+
"scripts": []
77+
},
78+
"configurations": {
79+
"production": {
80+
"fileReplacements": [
81+
{
82+
"replace": "projects/demo/src/environments/environment.ts",
83+
"with": "projects/demo/src/environments/environment.prod.ts"
84+
}
85+
],
86+
"optimization": true,
87+
"outputHashing": "all",
88+
"sourceMap": false,
89+
"extractCss": true,
90+
"namedChunks": false,
91+
"extractLicenses": true,
92+
"vendorChunk": false,
93+
"buildOptimizer": true,
94+
"budgets": [
95+
{
96+
"type": "initial",
97+
"maximumWarning": "2mb",
98+
"maximumError": "5mb"
99+
},
100+
{
101+
"type": "anyComponentStyle",
102+
"maximumWarning": "6kb",
103+
"maximumError": "10kb"
104+
}
105+
]
106+
}
107+
}
108+
},
109+
"serve": {
110+
"builder": "@angular-devkit/build-angular:dev-server",
111+
"options": {
112+
"browserTarget": "demo:build"
113+
},
114+
"configurations": {
115+
"production": {
116+
"browserTarget": "demo:build:production"
117+
}
118+
}
119+
},
120+
"extract-i18n": {
121+
"builder": "@angular-devkit/build-angular:extract-i18n",
122+
"options": {
123+
"browserTarget": "demo:build"
124+
}
125+
},
126+
"test": {
127+
"builder": "@angular-devkit/build-angular:karma",
128+
"options": {
129+
"main": "projects/demo/src/test.ts",
130+
"polyfills": "projects/demo/src/polyfills.ts",
131+
"tsConfig": "projects/demo/tsconfig.spec.json",
132+
"karmaConfig": "projects/demo/karma.conf.js",
133+
"assets": [
134+
"projects/demo/src/favicon.ico",
135+
"projects/demo/src/assets"
136+
],
137+
"styles": [
138+
"projects/demo/src/styles.scss"
139+
],
140+
"scripts": []
141+
}
142+
},
143+
"lint": {
144+
"builder": "@angular-devkit/build-angular:tslint",
145+
"options": {
146+
"tsConfig": [
147+
"projects/demo/tsconfig.app.json",
148+
"projects/demo/tsconfig.spec.json"
149+
],
150+
"exclude": [
151+
"**/node_modules/**"
152+
]
153+
}
154+
}
155+
}
156+
}},
157+
"defaultProject": "ngx-css-anim"
9158
}

package.json

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,45 @@
77
"build": "ng build",
88
"test": "ng test",
99
"lint": "ng lint",
10-
"e2e": "ng e2e"
10+
"e2e": "ng e2e",
11+
"format": "prettier --write \"projects/**/*.+(ts|js|json|html|scss)\"",
12+
"format:check": "prettier --check \"projects/**/*.+(ts|js|json|html|scss)\""
1113
},
1214
"private": true,
1315
"dependencies": {
14-
"@angular/animations": "~10.0.11",
15-
"@angular/common": "~10.0.11",
16-
"@angular/compiler": "~10.0.11",
17-
"@angular/core": "~10.0.11",
18-
"@angular/forms": "~10.0.11",
19-
"@angular/platform-browser": "~10.0.11",
20-
"@angular/platform-browser-dynamic": "~10.0.11",
21-
"@angular/router": "~10.0.11",
22-
"rxjs": "~6.5.5",
23-
"tslib": "^2.0.0",
24-
"zone.js": "~0.10.3"
16+
"@angular/common": "10.0.11",
17+
"@angular/compiler": "10.0.11",
18+
"@angular/core": "10.0.11",
19+
"@angular/forms": "10.0.11",
20+
"@angular/platform-browser": "10.0.11",
21+
"@angular/platform-browser-dynamic": "10.0.11",
22+
"@angular/router": "10.0.11",
23+
"bootstrap": "4.5.2",
24+
"rxjs": "6.6.2",
25+
"tslib": "2.0.1",
26+
"zone.js": "0.11.1"
2527
},
2628
"devDependencies": {
27-
"@angular/cli": "~10.0.7",
28-
"@angular/compiler-cli": "~10.0.11",
29-
"@types/node": "^12.11.1",
30-
"@types/jasmine": "~3.5.0",
31-
"@types/jasminewd2": "~2.0.3",
32-
"codelyzer": "^6.0.0",
33-
"jasmine-core": "~3.5.0",
34-
"jasmine-spec-reporter": "~5.0.0",
35-
"karma": "~5.0.0",
36-
"karma-chrome-launcher": "~3.1.0",
37-
"karma-coverage-istanbul-reporter": "~3.0.2",
38-
"karma-jasmine": "~3.3.0",
39-
"karma-jasmine-html-reporter": "^1.5.0",
40-
"protractor": "~7.0.0",
41-
"ts-node": "~8.3.0",
42-
"tslint": "~6.1.0",
43-
"typescript": "~3.9.5"
29+
"@angular-devkit/build-angular": "0.1000.7",
30+
"@angular-devkit/build-ng-packagr": "0.1000.7",
31+
"@angular/cli": "10.0.7",
32+
"@angular/compiler-cli": "10.0.11",
33+
"@types/jasmine": "3.5.12",
34+
"@types/jasminewd2": "2.0.8",
35+
"@types/node": "12.12.54",
36+
"codelyzer": "6.0.0",
37+
"jasmine-core": "3.6.0",
38+
"jasmine-spec-reporter": "5.0.2",
39+
"karma": "5.1.1",
40+
"karma-chrome-launcher": "3.1.0",
41+
"karma-coverage-istanbul-reporter": "3.0.3",
42+
"karma-jasmine": "3.3.1",
43+
"karma-jasmine-html-reporter": "1.5.4",
44+
"ng-packagr": "10.0.4",
45+
"ngx-speculoos": "4.1.0",
46+
"prettier": "2.0.5",
47+
"ts-node": "8.10.2",
48+
"tslint": "6.1.3",
49+
"typescript": "3.9.7"
4450
}
4551
}

projects/demo/.browserslistrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
17+
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
18+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

projects/demo/karma.conf.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageIstanbulReporter: {
19+
dir: require('path').join(__dirname, '../../coverage/demo'),
20+
reports: ['html', 'lcovonly', 'text-summary'],
21+
fixWebpackSourcePaths: true
22+
},
23+
reporters: ['progress', 'kjhtml'],
24+
port: 9876,
25+
colors: true,
26+
logLevel: config.LOG_INFO,
27+
autoWatch: true,
28+
browsers: ['ChromeHeadless'],
29+
singleRun: false,
30+
restartOnFileChange: true
31+
});
32+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<div class="container mt-5">
2+
<div class="text-right">
3+
<div class="custom-control custom-switch">
4+
<input
5+
type="checkbox"
6+
class="custom-control-input"
7+
id="toggle-animations"
8+
[(ngModel)]="animationsEnabled"
9+
/>
10+
<label class="custom-control-label" for="toggle-animations">Enable animations</label>
11+
</div>
12+
</div>
13+
14+
<div class="d-flex align-items-center flex-column my-2">
15+
<div class="border rounded mb-4 p-2" [cssAnimate]="slideInAnimation" [animateOnInit]="true">
16+
I'll slide in when the component is initialized
17+
</div>
18+
</div>
19+
20+
<hr />
21+
22+
<div class="d-flex align-items-center flex-column my-2">
23+
<div class="border rounded mb-4 p-2" [cssAnimate]="shakeAnimation" #toShake="cssAnimate">
24+
I'll shake when the button is clicked
25+
</div>
26+
<div>
27+
<button type="button" class="btn btn-primary" (click)="toShake.animate()">Shake it!</button>
28+
</div>
29+
</div>
30+
31+
<hr />
32+
33+
<div class="d-flex align-items-center flex-column my-2">
34+
<ng-container *ngIf="showBump; else resetBump">
35+
<div
36+
class="border rounded mb-4 p-2"
37+
[cssAnimate]="bumpAnimation"
38+
#toBump="cssAnimate"
39+
(animationEnd)="showBump = false"
40+
>
41+
I'll bump and then disappear
42+
</div>
43+
<div>
44+
<button type="button" class="btn btn-primary" (click)="toBump.animate()">Bump it!</button>
45+
</div>
46+
</ng-container>
47+
<ng-template #resetBump>
48+
<div>
49+
<button type="button" class="btn btn-outline-primary" (click)="showBump = true">
50+
Reset
51+
</button>
52+
</div>
53+
</ng-template>
54+
</div>
55+
</div>

0 commit comments

Comments
 (0)