Skip to content

Commit

Permalink
Make boxShadow respect ring shadows
Browse files Browse the repository at this point in the history
This is to prevent box-shadows from overriding rings that are added manually by plugins like the custom forms plugin.
  • Loading branch information
adamwathan committed Nov 10, 2020
1 parent 229af3b commit c3dd3b6
Show file tree
Hide file tree
Showing 7 changed files with 1,649 additions and 1,641 deletions.
816 changes: 408 additions & 408 deletions __tests__/fixtures/tailwind-output-flagged.css

Large diffs are not rendered by default.

816 changes: 408 additions & 408 deletions __tests__/fixtures/tailwind-output-important.css

Large diffs are not rendered by default.

816 changes: 408 additions & 408 deletions __tests__/fixtures/tailwind-output-no-color-opacity.css

Large diffs are not rendered by default.

816 changes: 408 additions & 408 deletions __tests__/fixtures/tailwind-output.css

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions __tests__/plugins/boxShadow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,23 @@ test('box shadow can use DEFAULT keyword and negative prefix syntax', () => {
utilities: {
'.shadow': {
'--box-shadow': '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
'box-shadow': 'var(--box-shadow)',
'box-shadow':
'var(--ring-offset-shadow, 0 0 #0000), var(--ring-shadow, 0 0 #0000), var(--box-shadow)',
},
'.shadow-md': {
'--box-shadow': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
'box-shadow': 'var(--box-shadow)',
'box-shadow':
'var(--ring-offset-shadow, 0 0 #0000), var(--ring-shadow, 0 0 #0000), var(--box-shadow)',
},
'.-shadow': {
'--box-shadow': 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
'box-shadow': 'var(--box-shadow)',
'box-shadow':
'var(--ring-offset-shadow, 0 0 #0000), var(--ring-shadow, 0 0 #0000), var(--box-shadow)',
},
'.-shadow-md': {
'--box-shadow': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
'box-shadow': 'var(--box-shadow)',
'box-shadow':
'var(--ring-offset-shadow, 0 0 #0000), var(--ring-shadow, 0 0 #0000), var(--box-shadow)',
},
},
variants: ['responsive'],
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/boxShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export default function () {
nameClass('shadow', modifier),
{
'--box-shadow': value === 'none' ? '0 0 #0000' : value,
'box-shadow': 'var(--box-shadow)',
'box-shadow': [
`var(--ring-offset-shadow, 0 0 #0000)`,
`var(--ring-shadow, 0 0 #0000)`,
`var(--box-shadow)`,
].join(', '),
},
]
})
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ringWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export default function () {
return [
nameClass('ring', modifier),
{
'--ring-width': value,
'--ring-color-default': ringColorDefault,
'--ring-offset-shadow': `0 0 0 var(--ring-offset-width, 0) var(--ring-offset-color, #fff)`,
'--ring-shadow': `0 0 0 calc(${value} + var(--ring-offset-width, 0px)) var(--ring-color, ${ringColorDefault})`,
'box-shadow': [
`0 0 0 var(--ring-offset-width, 0) var(--ring-offset-color, #fff)`,
`0 0 0 calc(var(--ring-width) + var(--ring-offset-width, 0px)) var(--ring-color, var(--ring-color-default))`,
`var(--ring-offset-shadow)`,
`var(--ring-shadow)`,
`var(--box-shadow, 0 0 #0000)`,
].join(', '),
},
Expand Down

0 comments on commit c3dd3b6

Please sign in to comment.