Skip to content

Commit

Permalink
Parse shadows without a leading zero
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Feb 1, 2022
1 parent dab8b04 commit b84d01e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/parseBoxShadowValue.js
@@ -1,7 +1,7 @@
let KEYWORDS = new Set(['inset', 'inherit', 'initial', 'revert', 'unset'])
let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
let LENGTH = /^-?(\d+)(.*?)$/g
let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g

export function parseBoxShadowValue(input) {
let shadows = input.split(COMMA)
Expand Down
33 changes: 33 additions & 0 deletions tests/basic-usage.test.js
Expand Up @@ -137,3 +137,36 @@ it('fasly config values still work', () => {
`)
})
})

it('shadows support values without a leading zero', () => {
let config = {
content: [{ raw: html`<div class="shadow-one shadow-two"></div>` }],
theme: {
boxShadow: {
one: '0.5rem 0.5rem 0.5rem #0005',
two: '.5rem .5rem .5rem #0005',
},
},
plugins: [],
corePlugins: { preflight: false },
}

let input = css`
@tailwind utilities;
`

return run(input, config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
.shadow-one {
--tw-shadow: 0.5rem 0.5rem 0.5rem #0005;
--tw-shadow-colored: 0.5rem 0.5rem 0.5rem var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.shadow-two {
--tw-shadow: 0.5rem 0.5rem 0.5rem #0005;
--tw-shadow-colored: 0.5rem 0.5rem 0.5rem var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
`)
})
})

0 comments on commit b84d01e

Please sign in to comment.