{"id":21240248,"url":"https://github.com/retyui/postcss-animations","last_synced_at":"2025-04-09T15:04:21.496Z","repository":{"id":18782319,"uuid":"85298423","full_name":"retyui/postcss-animations","owner":"retyui","description":"PostCSS plugin that adds `@keyframes` from animate.css, tuesday.css, magic.css, mimic.css","archived":false,"fork":false,"pushed_at":"2024-11-20T10:34:02.000Z","size":171,"stargazers_count":40,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T15:03:26.403Z","etag":null,"topics":["css-animations","postcss-animations","postcss-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/retyui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-17T10:13:54.000Z","updated_at":"2021-10-04T15:07:43.000Z","dependencies_parsed_at":"2023-01-13T20:00:37.767Z","dependency_job_id":null,"html_url":"https://github.com/retyui/postcss-animations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-animations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-animations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-animations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/retyui%2Fpostcss-animations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/retyui","download_url":"https://codeload.github.com/retyui/postcss-animations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055276,"owners_count":21040156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css-animations","postcss-animations","postcss-plugin"],"created_at":"2024-11-21T00:50:09.477Z","updated_at":"2025-04-09T15:04:21.475Z","avatar_url":"https://github.com/retyui.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postcss-animations\n\n[![npm](https://img.shields.io/npm/v/postcss-animations.svg)](https://www.npmjs.com/package/postcss-animations)\n[![CI](https://github.com/retyui/postcss-animations/actions/workflows/nodejs.yml/badge.svg)](https://github.com/retyui/postcss-animations/actions/workflows/nodejs.yml)\n\nPostCSS plugin that adds `@keyframes` from:\n\n- [![npm postcss-animation.css-data](https://img.shields.io/npm/dm/postcss-animation.css-data.svg)](https://www.npmjs.com/package/postcss-animation.css-data) [postcss-animation.css-data](https://github.com/retyui/postcss-animation.css-data)\n- [![npm postcss-magic.css-data](https://img.shields.io/npm/dm/postcss-magic.css-data.svg)](https://www.npmjs.com/package/postcss-magic.css-data) [postcss-magic.css-data](https://github.com/retyui/postcss-magic.css-data)\n- [![npm postcss-mimic.css-data](https://img.shields.io/npm/dm/postcss-mimic.css-data.svg)](https://www.npmjs.com/package/postcss-mimic.css-data) [postcss-mimic.css-data](https://github.com/retyui/postcss-mimic.css-data)\n- [![npm postcss-tuesday.css-data](https://img.shields.io/npm/dm/postcss-tuesday.css-data.svg)](https://www.npmjs.com/package/postcss-tuesday.css-data) [postcss-tuesday.css-data](https://github.com/retyui/postcss-tuesday.css-data)\n\n### Install\n\n```bash\nyarn add -D postcss-animations\n\n# and the animation data set you need\nyarn add -D postcss-animation.css-data postcss-magic.css-data postcss-mimic.css-data postcss-tuesday.css-data\n```\n\n**Input:**\n\n```css\n:root {\n  --fade-in-animation-name: tdFadeOut; /* add css variables support (Disabled default) */\n}\n\n.tdFadeIn {\n  animation-name: tdFadeIn;\n}\n\n.tdFadeOut {\n  animation-name: var(--fade-in-animation-name); /* or css variables */\n}\n```\n\n**Output:**\n\n```css\n:root {\n  --fade-in-animation-name: tdFadeOut;\n}\n\n.tdFadeIn {\n  animation-name: tdFadeIn;\n}\n\n.tdFadeOut {\n  animation-name: var(--fade-in-animation-name);\n}\n\n@keyframes tdFadeIn {\n  /* ... */\n}\n@keyframes tdFadeOut {\n  /* will be added if 'disableCheckCssVariables: false' */\n  /* ... */\n}\n```\n\n### Usage\n\n```js\nconst fs = require(\"fs\");\nconst postcss = require(\"postcss\");\nconst postcssAnimations = require(\"postcss-animations\");\n\nconst [from, to] = [\"./src/style.css\", \"./dist/style.css\"];\nconst CSS = fs.readFileSync(from);\nconst PLUGINS = [\n  postcssAnimations({\n    data: [\n      require(\"postcss-animation.css-data\"),\n      require(\"postcss-magic.css-data\"),\n      require(\"postcss-mimic.css-data\"),\n      require(\"postcss-tuesday.css-data\"),\n    ],\n    checkDuplications: true,\n    disableCheckCssVariables: true,\n  }),\n];\n\n(async () =\u003e {\n  try {\n    const { css, messages } = await postcss(PLUGINS).process(CSS, { from, to });\n    messages\n      .filter(({ type }) =\u003e type === \"warning\")\n      .map((msg) =\u003e console.log(msg.toString()));\n    console.log(css);\n    fs.writeFileSync(to, css);\n  } catch (e) {\n    console.error(e);\n  }\n})();\n```\n\n### Options\n\n#### `data: Array\u003c{[animationName: string]: string}\u003e | {[animationName: string]: string}`\n\n`data` is a simple object where:\n\n- `key`: animation name\n- `value`: css code of animation\n\n```js\n// Plain object\nconst data = {\n  myAnimationName: `@keyframes myAnimationName { 0%{opacity:1;} 100%{opacity:0;} }`,\n};\n\n// or Array\nconst data = [\n  {\n    myAnimationName: `@keyframes myAnimationName { 0%{opacity:1;} 100%{opacity:0;} }`,\n  },\n  require(\"postcss-animation.css-data\"),\n];\n```\n\n#### `disableCheckCssVariables: boolean`\n\nDisable checking and search variables css `var(--name)` (default: `true`)\n\n#### `checkDuplications: boolean`\n\nDisplay a warning if find duplicate name of the animation (default: `true`)\n\n---\n\n### [Animista](http://animista.net) support example:\n\n```js\nconst {\n  css: parseFromCss,\n  files: parseFromFile,\n} = require(\"css-parse-keyframes\");\n\npostcss([\n  require(\"postcss-animations\")({\n    data: [\n      // your Generated code\n      parseFromCss(\n        \"@keyframes scale-up-center {0% { transform: scale(0.5); } 100% { transform: scale(1); }}\"\n      ),\n      // or saved\n      parseFromFile(\"./animista-demo.css\"),\n      parseFromFile([\"./animista-text.css\", \"./animista-base.css\"]),\n    ],\n  }),\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretyui%2Fpostcss-animations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretyui%2Fpostcss-animations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretyui%2Fpostcss-animations/lists"}