-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle pre-transformed tagged-template literal by swc
- Loading branch information
Brijesh Bittu
committed
Feb 8, 2025
1 parent
35f443e
commit 155b9ef
Showing
9 changed files
with
361 additions
and
82 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
118 changes: 118 additions & 0 deletions
118
...pigment-css-react-new/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,118 @@ | ||
/** | ||
* 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-new'; | ||
|
||
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; | ||
}, | ||
); |
36 changes: 36 additions & 0 deletions
36
...gment-css-react-new/tests/styled/fixtures/styled-swc-transformed-tagged-string.output.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.