-
Notifications
You must be signed in to change notification settings - Fork 12
Styled Components: Fix interpolated className #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Styled Components: Fix interpolated className #277
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/itsjonq/g2/9w5rDTVhEGpVEQkdyCXnxCYP5UQa |
Going to try an alpha |
* @returns {string} The interpolated className. | ||
*/ | ||
export function getInterpolatedClassName(displayName) { | ||
return typeof displayName === 'string' ? `ic-${hash(displayName)}` : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise a development-env warning that the displayName was undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. But maybe not here. Perhaps in contextConnect()
or useContext()
?
What you think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that makes sense to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed that update :). Lemme know if that works
This update consolidates how the interpolated className is created, in an attempt to resolve WordPress/gutenberg#29084 (comment)
Changes:
getInterpolatedClassName
util is created and exported from@wp-g2/create-styles
getInterpolatedClassName
ensures the@emotion/hash
function is only called if the argument is valid@wp-g2/context
adds@wp-g2/create-styles
as a dependency (was previously missing)@emotion/hash
go through the newgetInterpolatedClassName
util