Skip to content

Commit 9c52509

Browse files
committed
fix: Fix generate / import structures.
1 parent 481f8e9 commit 9c52509

File tree

106 files changed

+4516
-566
lines changed

Some content is hidden

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

106 files changed

+4516
-566
lines changed

bin/generate.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { readdirSync } from 'fs';
2-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3-
import { dirname, resolve, basename } from 'path';
1+
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2+
import { basename, dirname, resolve } from 'node:path';
43

54
type AnimationItem = {
65
file: string;
@@ -13,14 +12,26 @@ const animations: { [action: string]: AnimationItem } = {};
1312

1413
run();
1514

15+
function copyAnimateCss() {
16+
const animateCSS = resolve('node_modules/animate.css/animate.css');
17+
let content = readFileSync(animateCSS, 'utf8');
18+
19+
content = content.replace('--animate-duration: 1s;', '--animate-duration: .5s;')
20+
content = content.replace('--animate-delay: 1s;', '--animate-delay: 0;')
21+
22+
writeFileSync(resolve('src/animates/animate.css'), content);
23+
}
24+
1625
function run() {
1726
const animateDir = resolve('node_modules/animate.css/source');
1827
const dirs = readdirSync(animateDir, { withFileTypes: true });
1928

29+
copyAnimateCss();
30+
2031
rmSync('src/css', { recursive: true, force: true });
2132

2233
let indexContent = `
23-
@import 'animate.css/animate.css';
34+
@import './animate.css';
2435
`;
2536

2637
for (const dir of dirs) {
@@ -68,7 +79,7 @@ function run() {
6879

6980
writeFileSync(resolve('src/animates/main.css'), indexContent);
7081

71-
writeFileSync(resolve('src/animations.json'), JSON.stringify(animJson, null, 2));
82+
writeFileSync(resolve('src/animations-list.json'), JSON.stringify(animJson, null, 2));
7283
}
7384

7485
function generateAttentions(dir: string) {
@@ -87,7 +98,7 @@ function generateAttentions(dir: string) {
8798

8899
attentions.push(animName);
89100

90-
imports.push(`export * from '@src/attentions/${animName}';`);
101+
imports.push(`export * from '@/attentions/${animName}';`);
91102

92103
const dest = resolve('src/attentions', animName + '.ts');
93104
const code = handleAttention(animName);
@@ -100,11 +111,11 @@ function generateAttentions(dir: string) {
100111
}
101112

102113
writeFileSync(resolve('src/attentions/index.ts'), imports.join("\n"));
103-
writeFileSync(resolve('src/attentions.json'), JSON.stringify(attentions));
114+
writeFileSync(resolve('src/attentions-list.json'), JSON.stringify(attentions));
104115
}
105116

106117
function handleAttention(animName: string) {
107-
return `import { type AttentionOptions, doAttention } from '@src/attention';
118+
return `import { type AttentionOptions, doAttention } from '@/attention';
108119
109120
export function ${animName}(
110121
el: HTMLElement, options?: AttentionOptions,
@@ -168,6 +179,8 @@ function makeTransitionCss(
168179

169180
return `.${base}${direction}-${enterLeave}-active {
170181
animation-duration: var(--animate-duration);
182+
animation-delay: var(--animate-delay);
183+
animation-iteration-count: var(--animate-repeat);
171184
animation-fill-mode: both;
172185
animation-name: ${base}${inOut}${direction};
173186
}`;
@@ -182,6 +195,8 @@ function makeTransitionTs(
182195

183196
return `.${base}${direction}-${enterLeave}-active {
184197
animation-duration: var(--animate-duration);
198+
animation-delay: var(--animate-delay);
199+
animation-iteration-count: var(--animate-repeat);
185200
animation-fill-mode: both;
186201
animation-name: ${base}${inOut}${direction};
187202
}`;

dist/animates/back/backDown.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/back/backLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/back/backRight.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/back/backUp.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/bounce/bounce.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/bounce/bounceDown.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/bounce/bounceLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/bounce/bounceRight.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/bounce/bounceUp.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fade.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeBottomLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeBottomRight.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeDown.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeDownBig.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeLeftBig.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeRight.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeRightBig.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeTopLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeTopRight.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeUp.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/fade/fadeUpBig.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/flip/flip.css

Lines changed: 0 additions & 5 deletions
This file was deleted.

dist/animates/flip/flipX.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/flip/flipY.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/animates/lightSpeed/lightSpeedLeft.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)