Skip to content

Commit

Permalink
fix: Fix generate / import structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Oct 21, 2023
1 parent 481f8e9 commit 9c52509
Show file tree
Hide file tree
Showing 106 changed files with 4,516 additions and 566 deletions.
31 changes: 23 additions & 8 deletions bin/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readdirSync } from 'fs';
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { dirname, resolve, basename } from 'path';
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { basename, dirname, resolve } from 'node:path';

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

run();

function copyAnimateCss() {
const animateCSS = resolve('node_modules/animate.css/animate.css');
let content = readFileSync(animateCSS, 'utf8');

content = content.replace('--animate-duration: 1s;', '--animate-duration: .5s;')
content = content.replace('--animate-delay: 1s;', '--animate-delay: 0;')

writeFileSync(resolve('src/animates/animate.css'), content);
}

function run() {
const animateDir = resolve('node_modules/animate.css/source');
const dirs = readdirSync(animateDir, { withFileTypes: true });

copyAnimateCss();

rmSync('src/css', { recursive: true, force: true });

let indexContent = `
@import 'animate.css/animate.css';
@import './animate.css';
`;

for (const dir of dirs) {
Expand Down Expand Up @@ -68,7 +79,7 @@ function run() {

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

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

function generateAttentions(dir: string) {
Expand All @@ -87,7 +98,7 @@ function generateAttentions(dir: string) {

attentions.push(animName);

imports.push(`export * from '@src/attentions/${animName}';`);
imports.push(`export * from '@/attentions/${animName}';`);

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

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

function handleAttention(animName: string) {
return `import { type AttentionOptions, doAttention } from '@src/attention';
return `import { type AttentionOptions, doAttention } from '@/attention';
export function ${animName}(
el: HTMLElement, options?: AttentionOptions,
Expand Down Expand Up @@ -168,6 +179,8 @@ function makeTransitionCss(

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

return `.${base}${direction}-${enterLeave}-active {
animation-duration: var(--animate-duration);
animation-delay: var(--animate-delay);
animation-iteration-count: var(--animate-repeat);
animation-fill-mode: both;
animation-name: ${base}${inOut}${direction};
}`;
Expand Down
11 changes: 0 additions & 11 deletions dist/animates/back/backDown.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/back/backLeft.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/back/backRight.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/back/backUp.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/bounce/bounce.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/bounce/bounceDown.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/bounce/bounceLeft.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/bounce/bounceRight.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/bounce/bounceUp.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fade.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeBottomLeft.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeBottomRight.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeDown.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeDownBig.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeLeft.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeLeftBig.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeRight.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeRightBig.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeTopLeft.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeTopRight.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeUp.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/fade/fadeUpBig.css

This file was deleted.

5 changes: 0 additions & 5 deletions dist/animates/flip/flip.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/flip/flipX.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/flip/flipY.css

This file was deleted.

11 changes: 0 additions & 11 deletions dist/animates/lightSpeed/lightSpeedLeft.css

This file was deleted.

Loading

0 comments on commit 9c52509

Please sign in to comment.