Skip to content

Commit

Permalink
Fix cascading shadow/ring bug, ensure default ring color
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Nov 17, 2020
1 parent 5e50367 commit e40079a
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1,727 deletions.
439 changes: 10 additions & 429 deletions __tests__/fixtures/tailwind-output-flagged.css

Large diffs are not rendered by default.

445 changes: 13 additions & 432 deletions __tests__/fixtures/tailwind-output-important.css

Large diffs are not rendered by default.

439 changes: 10 additions & 429 deletions __tests__/fixtures/tailwind-output-no-color-opacity.css

Large diffs are not rendered by default.

439 changes: 10 additions & 429 deletions __tests__/fixtures/tailwind-output.css

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions __tests__/plugins/boxShadow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,25 @@ test('box shadow can use DEFAULT keyword and negative prefix syntax', () => {

return getConfigValue(`variants.${path}`, defaultValue)
},
addUtilities(utilities, variants) {
addUtilities(utilities, options) {
addedUtilities.push({
utilities,
variants,
options,
})
},
}

plugin()(pluginApi)

expect(addedUtilities).toEqual([
{
utilities: {
'*': {
'--tw-shadow': '0 0 #0000',
},
},
options: { respectImportant: false },
},
{
utilities: {
'.shadow': {
Expand All @@ -65,7 +73,7 @@ test('box shadow can use DEFAULT keyword and negative prefix syntax', () => {
'var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)',
},
},
variants: ['responsive'],
options: ['responsive'],
},
])
})
9 changes: 9 additions & 0 deletions src/plugins/boxShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import nameClass from '../util/nameClass'

export default function () {
return function ({ addUtilities, theme, variants }) {
addUtilities(
{
'*': {
'--tw-shadow': '0 0 #0000',
},
},
{ respectImportant: false }
)

const utilities = _.fromPairs(
_.map(theme('boxShadow'), (value, modifier) => {
return [
Expand Down
18 changes: 14 additions & 4 deletions src/plugins/ringWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ export default function () {
return `rgba(${r}, ${g}, ${b}, ${theme('ringOpacity.DEFAULT', '0.5')})`
})(safeCall(() => toRgba(theme('ringColor.DEFAULT')), ['147', '197', '253']))

addUtilities(
{
'*': {
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
'--tw-ring-offset-width': '0px',
'--tw-ring-offset-color': '#fff',
'--tw-ring-color': ringColorDefault,
'--tw-ring-offset-shadow': '0 0 #0000',
'--tw-ring-shadow': '0 0 #0000',
},
},
{ respectImportant: false }
)

const utilities = _.fromPairs(
_.map(theme('ringWidth'), (value, modifier) => {
return [
nameClass('ring', modifier),
{
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
'--tw-ring-offset-width': '0px',
'--tw-ring-offset-color': '#fff',
'--tw-ring-color': ringColorDefault,
'--tw-ring-offset-shadow': `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)`,
'--tw-ring-shadow': `var(--tw-ring-inset) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color)`,
'box-shadow': [
Expand Down
2 changes: 1 addition & 1 deletion stubs/defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ module.exports = {
placeholderColor: (theme) => theme('colors'),
placeholderOpacity: (theme) => theme('opacity'),
ringColor: (theme) => ({
DEFAULT: theme('colors.blue.500'),
DEFAULT: theme('colors.blue.500', '#3b82f6'),
...theme('colors'),
}),
ringOffsetColor: (theme) => theme('colors'),
Expand Down

0 comments on commit e40079a

Please sign in to comment.