ben-rogerson / twin.macro

🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, solid-styled-components, stitches and goober) at build time.
MIT License
7.89k stars 184 forks source link

Allow grabbing theme values with a decimal #815

Closed ben-rogerson closed 1 year ago

ben-rogerson commented 1 year ago

This PR contains a fix for spacing theme values containing a decimal, like this:

tw`pl-[calc(20px + theme(spacing.2.5))]`

// ↓ ↓ ↓ ↓ ↓ ↓

({
  "paddingLeft": "calc(20px + 0.625rem)"
});

Previously values like this would return an incorrect value. This made square brackets required to select these type of values:

tw`pl-[calc(20px + theme(spacing[2.5]))]`

Related https://github.com/ben-rogerson/twin.macro/discussions/814