Skip to content

Commit

Permalink
fix: partial animate.css refactor (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Oct 3, 2021
1 parent 94fb858 commit 75d3217
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 325 deletions.
24 changes: 24 additions & 0 deletions .todo
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,27 @@ Add tests
advanced -- unit tests to ensure that the package actually works
Improve npm package ratings
Write medium article
Fix issues with Animate.css


---

const plugin = require('tailwindcss/plugin');
const withAnimations = require('animated-tailwindcss');

module.exports = withAnimations({
variants: { animation: ['motion-reduce'] },
plugins: [
plugin(({ addUtilities }) => {
addUtilities({
'.animate-animated': {
'@media print, (prefers-reduced-motion: reduce)': {
'--animate-duration': '1ms',
'--animate-repeat': '1',
},
},
'.animate-foo': { '@media print, (prefers-reduced-motion: reduce)': { opacity: '0' } },
});
}),
],
});
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import createPlugin from 'tailwindcss/plugin';
import keyframes from '@/keyframes';
import utilities from '@/utilities';

// overrides tailwind animations

const withAnimations: Main = (config = {}, { experimental = false } = {}) => {
// keyframes
const configKeyframes: typeof keyframes = get(config, 'theme.extend.keyframes', {});
set(config, 'theme.extend.keyframes', { ...keyframes, ...configKeyframes });
set(config, 'theme.keyframes', { ...keyframes, ...configKeyframes });

// animation
const animation = Object.fromEntries(Object.keys(keyframes).map((k) => [k, k]));
const configAnimations: typeof animation = get(config, 'theme.extend.animation', {});

set(config, 'theme.extend.animation', { ...animation, ...configAnimations });
set(config, 'theme.animation', { ...animation, ...configAnimations });

// utilities
const prefixed = Object.fromEntries(
Expand Down

0 comments on commit 75d3217

Please sign in to comment.