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

Allow negative theme lookup of space objects #865

Merged
merged 1 commit into from
May 5, 2020

Conversation

kenny-f
Copy link
Contributor

@kenny-f kenny-f commented Apr 23, 2020

Currently, if you set your space to be an object in theme instead of an array then using for example -xl does not work.

Example:

// theme.js
const theme = { space : { s: '8px', m: '16px' } } 
// some-component.js
<div
  sx={{
    margin: '-m'
  }}
/>

The -m does not get replaced with -16px.

What we currently have to do is:

// some-component.js
<div
  sx={{
    margin: (theme) => `-${theme.space.m}`
  }}
/>

which is not as nice.

This pr will see if the value starts with a - and return the theme lookup value and add a -.

@jxnblk
Copy link
Member

jxnblk commented May 5, 2020

Thanks! This seems like a helpful addition to the API :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants