Skip to content

Commit

Permalink
Add skew plugin + change order of transform functions (apply translat…
Browse files Browse the repository at this point in the history
…e last)
  • Loading branch information
benface committed Jan 2, 2020
1 parent 63b5cc2 commit 12cd6e6
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 34 deletions.
40 changes: 25 additions & 15 deletions __tests__/fixtures/tailwind-output-important.css
Original file line number Diff line number Diff line change
Expand Up @@ -8443,12 +8443,14 @@ video {
}

.transform {
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
--transform-scale-x: 1 !important;
--transform-scale-y: 1 !important;
--transform-rotate: 0 !important;
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) !important;
--transform-skew-x: 0 !important;
--transform-skew-y: 0 !important;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) !important;
}

.transform-none {
Expand Down Expand Up @@ -17793,12 +17795,14 @@ video {
}

.sm\:transform {
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
--transform-scale-x: 1 !important;
--transform-scale-y: 1 !important;
--transform-rotate: 0 !important;
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) !important;
--transform-skew-x: 0 !important;
--transform-skew-y: 0 !important;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) !important;
}

.sm\:transform-none {
Expand Down Expand Up @@ -27144,12 +27148,14 @@ video {
}

.md\:transform {
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
--transform-scale-x: 1 !important;
--transform-scale-y: 1 !important;
--transform-rotate: 0 !important;
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) !important;
--transform-skew-x: 0 !important;
--transform-skew-y: 0 !important;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) !important;
}

.md\:transform-none {
Expand Down Expand Up @@ -36495,12 +36501,14 @@ video {
}

.lg\:transform {
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
--transform-scale-x: 1 !important;
--transform-scale-y: 1 !important;
--transform-rotate: 0 !important;
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) !important;
--transform-skew-x: 0 !important;
--transform-skew-y: 0 !important;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) !important;
}

.lg\:transform-none {
Expand Down Expand Up @@ -45846,12 +45854,14 @@ video {
}

.xl\:transform {
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
--transform-scale-x: 1 !important;
--transform-scale-y: 1 !important;
--transform-rotate: 0 !important;
--transform-translate-x: 0 !important;
--transform-translate-y: 0 !important;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) !important;
--transform-skew-x: 0 !important;
--transform-skew-y: 0 !important;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y)) !important;
}

.xl\:transform-none {
Expand Down
40 changes: 25 additions & 15 deletions __tests__/fixtures/tailwind-output.css
Original file line number Diff line number Diff line change
Expand Up @@ -8443,12 +8443,14 @@ video {
}

.transform {
--transform-translate-x: 0;
--transform-translate-y: 0;
--transform-scale-x: 1;
--transform-scale-y: 1;
--transform-rotate: 0;
--transform-translate-x: 0;
--transform-translate-y: 0;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y));
--transform-skew-x: 0;
--transform-skew-y: 0;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y));
}

.transform-none {
Expand Down Expand Up @@ -17793,12 +17795,14 @@ video {
}

.sm\:transform {
--transform-translate-x: 0;
--transform-translate-y: 0;
--transform-scale-x: 1;
--transform-scale-y: 1;
--transform-rotate: 0;
--transform-translate-x: 0;
--transform-translate-y: 0;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y));
--transform-skew-x: 0;
--transform-skew-y: 0;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y));
}

.sm\:transform-none {
Expand Down Expand Up @@ -27144,12 +27148,14 @@ video {
}

.md\:transform {
--transform-translate-x: 0;
--transform-translate-y: 0;
--transform-scale-x: 1;
--transform-scale-y: 1;
--transform-rotate: 0;
--transform-translate-x: 0;
--transform-translate-y: 0;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y));
--transform-skew-x: 0;
--transform-skew-y: 0;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y));
}

.md\:transform-none {
Expand Down Expand Up @@ -36495,12 +36501,14 @@ video {
}

.lg\:transform {
--transform-translate-x: 0;
--transform-translate-y: 0;
--transform-scale-x: 1;
--transform-scale-y: 1;
--transform-rotate: 0;
--transform-translate-x: 0;
--transform-translate-y: 0;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y));
--transform-skew-x: 0;
--transform-skew-y: 0;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y));
}

.lg\:transform-none {
Expand Down Expand Up @@ -45846,12 +45854,14 @@ video {
}

.xl\:transform {
--transform-translate-x: 0;
--transform-translate-y: 0;
--transform-scale-x: 1;
--transform-scale-y: 1;
--transform-rotate: 0;
--transform-translate-x: 0;
--transform-translate-y: 0;
transform: scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y));
--transform-skew-x: 0;
--transform-skew-y: 0;
transform: translateX(var(--transform-translate-x)) translateY(var(--transform-translate-y)) scaleX(var(--transform-scale-x)) scaleY(var(--transform-scale-y)) rotate(var(--transform-rotate)) skewX(var(--transform-skew-x)) skewY(var(--transform-skew-y));
}

.xl\:transform-none {
Expand Down
2 changes: 2 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import transformOrigin from './plugins/transformOrigin'
import scale from './plugins/scale'
import rotate from './plugins/rotate'
import translate from './plugins/translate'
import skew from './plugins/skew'

import configurePlugins from './util/configurePlugins'

Expand Down Expand Up @@ -153,5 +154,6 @@ export default function({ corePlugins: corePluginConfig }) {
scale,
rotate,
translate,
skew,
})
}
8 changes: 8 additions & 0 deletions src/plugins/skew.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import createUtilityPlugin from '../util/createUtilityPlugin'

export default function() {
return createUtilityPlugin('skew', [
['skew-x', ['--transform-skew-x']],
['skew-y', ['--transform-skew-y']],
])
}
12 changes: 8 additions & 4 deletions src/plugins/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ export default function() {
addUtilities(
{
'.transform': {
'--transform-translate-x': '0',
'--transform-translate-y': '0',
'--transform-scale-x': '1',
'--transform-scale-y': '1',
'--transform-rotate': '0',
'--transform-translate-x': '0',
'--transform-translate-y': '0',
'--transform-skew-x': '0',
'--transform-skew-y': '0',
transform: [
'translateX(var(--transform-translate-x))',
'translateY(var(--transform-translate-y))',
'scaleX(var(--transform-scale-x))',
'scaleY(var(--transform-scale-y))',
'rotate(var(--transform-rotate))',
'translateX(var(--transform-translate-x))',
'translateY(var(--transform-translate-y))',
'skewX(var(--transform-skew-x))',
'skewY(var(--transform-skew-y))',
].join(' '),
},
'.transform-none': { transform: 'none' },
Expand Down
2 changes: 2 additions & 0 deletions stubs/defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ module.exports = {
'1/2': '50%',
full: '100%',
}),
skew: {},
},
variants: {
accessibility: ['responsive', 'focus'],
Expand Down Expand Up @@ -525,6 +526,7 @@ module.exports = {
scale: ['responsive', 'hover', 'focus'],
rotate: ['responsive', 'hover', 'focus'],
translate: ['responsive', 'hover', 'focus'],
skew: ['responsive', 'hover', 'focus'],
},
corePlugins: {},
plugins: [],
Expand Down

0 comments on commit 12cd6e6

Please sign in to comment.