Skip to content
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

Compose styles with arrays in sx prop #704

Closed
wants to merge 4 commits into from

Conversation

jonavila
Copy link

This PR attempts to revive the work done @phelma (https://github.com/phelma) in #174. I took his work and put in the core package and update the SxStyleProp type.

Sorry about the noise added by Prettier in the test file.

@@ -16,9 +16,10 @@ export * from './types'
const getCSS = props => {
if (!props.sx && !props.css) return undefined
return theme => {
const styles = css(props.sx)(theme)
const sx = Array.isArray(props.sx) ? props.sx : [props.sx]
const styles = sx.map(s => css(s)(theme))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jxnblk Do you have a preferred method for recursively flattening arrays? I realized after I opened the PR that Emotion recursively flattens arrays of styles and this doesn't account for that scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are merge utilities in this file (see line 66)—is that what you’re looking for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachlanjc Thanks for the suggestion. Looks like the merge utility didn't have what i was looking for. I update a PR to do the flattening though.

@dburles dburles mentioned this pull request May 11, 2020
7 tasks
@lachlanjc lachlanjc added the enhancement New feature or request label Dec 3, 2020
@hasparus hasparus closed this Dec 14, 2020
@hasparus hasparus deleted the branch system-ui:develop December 14, 2020 08:53
@hasparus hasparus reopened this Dec 14, 2020
@vercel
Copy link

vercel bot commented Dec 14, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/systemui/theme-ui/gvd2e4iv4
✅ Preview: https://theme-ui-git-sx-composition.systemui.vercel.app

@hasparus hasparus changed the base branch from master to develop December 14, 2020 09:13
@hasparus hasparus self-requested a review as a code owner December 14, 2020 09:13
@jonavila jonavila closed this Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants