-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[react] Fix css extraction for transformed styled tagged-template call (
#234)
- Loading branch information
1 parent
fd79e6b
commit d7c13d1
Showing
6 changed files
with
334 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...ges/pigment-css-react/tests/styled/fixtures/styled-swc-transformed-tagged-string.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* This is a pre-transformed file for testing. | ||
*/ | ||
import { _ as _tagged_template_literal } from "@swc/helpers/_/_tagged_template_literal"; | ||
import { styled, keyframes } from '@pigment-css/react'; | ||
|
||
function _templateObject() { | ||
const data = _tagged_template_literal(["\n 0% {\n transform: scale(0);\n opacity: 0.1;\n }\n\n 100% {\n transform: scale(1);\n opacity: 0.3;\n }\n"]); | ||
_templateObject = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject1() { | ||
const data = _tagged_template_literal(["\n 0% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0;\n }\n"]); | ||
_templateObject1 = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject2() { | ||
const data = _tagged_template_literal(["\n 0% {\n transform: scale(1);\n }\n\n 50% {\n transform: scale(0.92);\n }\n\n 100% {\n transform: scale(1);\n }\n"]); | ||
_templateObject2 = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _templateObject3() { | ||
const data = _tagged_template_literal(["\n opacity: 0;\n position: absolute;\n\n &.", " {\n opacity: 0.3;\n transform: scale(1);\n animation-name: ", ";\n animation-duration: ", "ms;\n animation-timing-function: ", ";\n }\n\n &.", " {\n animation-duration: ", "ms;\n }\n\n & .", " {\n opacity: 1;\n display: block;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n background-color: currentColor;\n }\n\n & .", " {\n opacity: 0;\n animation-name: ", ";\n animation-duration: ", "ms;\n animation-timing-function: ", ";\n }\n\n & .", " {\n position: absolute;\n /* @noflip */\n left: 0px;\n top: 0;\n animation-name: ", ";\n animation-duration: 2500ms;\n animation-timing-function: ", ";\n animation-iteration-count: infinite;\n animation-delay: 200ms;\n }\n"]); | ||
_templateObject3 = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
|
||
const touchRippleClasses = { | ||
rippleVisible: 'MuiTouchRipple.rippleVisible', | ||
ripplePulsate: 'MuiTouchRipple.ripplePulsate', | ||
child: 'MuiTouchRipple.child', | ||
childLeaving: 'MuiTouchRipple.childLeaving', | ||
childPulsate: 'MuiTouchRipple.childPulsate', | ||
}; | ||
|
||
const enterKeyframe = keyframes(_templateObject()); | ||
const exitKeyframe = keyframes(_templateObject1()); | ||
const pulsateKeyframe = keyframes(_templateObject2()); | ||
|
||
export const TouchRippleRoot = styled('span', { | ||
name: 'MuiTouchRipple', | ||
slot: 'Root' | ||
})({ | ||
overflow: 'hidden', | ||
pointerEvents: 'none', | ||
position: 'absolute', | ||
zIndex: 0, | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
borderRadius: 'inherit' | ||
}); | ||
|
||
// This `styled()` function invokes keyframes. `styled-components` only supports keyframes | ||
// in string templates. Do not convert these styles in JS object as it will break. | ||
export const TouchRippleRipple = styled(Ripple, { | ||
name: 'MuiTouchRipple', | ||
slot: 'Ripple' | ||
})(_templateObject3(), touchRippleClasses.rippleVisible, enterKeyframe, DURATION, param => { | ||
let { | ||
theme | ||
} = param; | ||
return theme.transitions.easing.easeInOut; | ||
}, touchRippleClasses.ripplePulsate, param => { | ||
let { | ||
theme | ||
} = param; | ||
return theme.transitions.duration.shorter; | ||
}, touchRippleClasses.child, touchRippleClasses.childLeaving, exitKeyframe, DURATION, param => { | ||
let { | ||
theme | ||
} = param; | ||
return theme.transitions.easing.easeInOut; | ||
}, touchRippleClasses.childPulsate, pulsateKeyframe, param => { | ||
let { | ||
theme | ||
} = param; | ||
return theme.transitions.easing.easeInOut; | ||
}); |
78 changes: 78 additions & 0 deletions
78
...s/pigment-css-react/tests/styled/fixtures/styled-swc-transformed-tagged-string.output.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@keyframes e19ejdhp { | ||
0% { | ||
transform: scale(0); | ||
opacity: 0.1; | ||
} | ||
100% { | ||
transform: scale(1); | ||
opacity: 0.3; | ||
} | ||
} | ||
@keyframes e1rvu9kp { | ||
0% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
@keyframes p1yhz964 { | ||
0% { | ||
transform: scale(1); | ||
} | ||
50% { | ||
transform: scale(0.92); | ||
} | ||
100% { | ||
transform: scale(1); | ||
} | ||
} | ||
.ttz155n { | ||
overflow: hidden; | ||
pointer-events: none; | ||
position: absolute; | ||
z-index: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
border-radius: inherit; | ||
} | ||
.tm7990f { | ||
opacity: 0; | ||
position: absolute; | ||
} | ||
.tm7990f.MuiTouchRipple.rippleVisible { | ||
opacity: 0.3; | ||
transform: scale(1); | ||
animation-name: e19ejdhp; | ||
animation-duration: ms; | ||
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
} | ||
.tm7990f.MuiTouchRipple.ripplePulsate { | ||
animation-duration: 200ms; | ||
} | ||
.tm7990f .MuiTouchRipple.child { | ||
opacity: 1; | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 50%; | ||
background-color: currentColor; | ||
} | ||
.tm7990f .MuiTouchRipple.childLeaving { | ||
opacity: 0; | ||
animation-name: e1rvu9kp; | ||
animation-duration: ms; | ||
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
} | ||
.tm7990f .MuiTouchRipple.childPulsate { | ||
position: absolute; | ||
left: 0px; | ||
top: 0; | ||
animation-name: p1yhz964; | ||
animation-duration: 2500ms; | ||
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
animation-iteration-count: infinite; | ||
animation-delay: 200ms; | ||
} |
21 changes: 21 additions & 0 deletions
21
...es/pigment-css-react/tests/styled/fixtures/styled-swc-transformed-tagged-string.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { styled as _styled, styled as _styled2 } from '@pigment-css/react'; | ||
import _theme from '@pigment-css/react/theme'; | ||
/** | ||
* This is a pre-transformed file for testing. | ||
*/ | ||
export const TouchRippleRoot = /*#__PURE__*/ _styled('span', { | ||
name: 'MuiTouchRipple', | ||
slot: 'Root', | ||
})({ | ||
classes: ['ttz155n'], | ||
}); | ||
|
||
// This `styled()` function invokes keyframes. `styled-components` only supports keyframes | ||
// in string templates. Do not convert these styles in JS object as it will break. | ||
const _exp6 = /*#__PURE__*/ () => Ripple; | ||
export const TouchRippleRipple = /*#__PURE__*/ _styled2(_exp6(), { | ||
name: 'MuiTouchRipple', | ||
slot: 'Ripple', | ||
})({ | ||
classes: ['tm7990f'], | ||
}); |
Oops, something went wrong.