This commit is contained in:
Robin Malfait 2021-06-30 19:11:19 +02:00
parent 6dbd28cbb3
commit 4e912e64c6
No known key found for this signature in database
GPG key ID: 92F53D68B9041AFE
2 changed files with 74 additions and 13 deletions

View file

@ -3,20 +3,38 @@ import withAlphaVariable from '../util/withAlphaVariable'
export default function () {
return function ({ config, addBase, matchUtilities, theme, variants, corePlugins }) {
if (!corePlugins('borderOpacity')) {
addBase({
'*, ::before, ::after': {
'border-color': theme('borderColor.DEFAULT', 'currentColor'),
},
})
if (config('mode') === 'jit') {
if (!corePlugins('borderOpacity')) {
addBase({
'*::tailwind': {
'border-color': theme('borderColor.DEFAULT', 'currentColor'),
},
})
} else {
addBase({
'*::tailwind': withAlphaVariable({
color: theme('borderColor.DEFAULT', 'currentColor'),
property: 'border-color',
variable: '--tw-border-opacity',
}),
})
}
} else {
addBase({
'*, ::before, ::after': withAlphaVariable({
color: theme('borderColor.DEFAULT', 'currentColor'),
property: 'border-color',
variable: '--tw-border-opacity',
}),
})
if (!corePlugins('borderOpacity')) {
addBase({
'*, ::before, ::after': {
'border-color': theme('borderColor.DEFAULT', 'currentColor'),
},
})
} else {
addBase({
'*, ::before, ::after': withAlphaVariable({
color: theme('borderColor.DEFAULT', 'currentColor'),
property: 'border-color',
variable: '--tw-border-opacity',
}),
})
}
}
matchUtilities(

View file

@ -443,3 +443,46 @@ test('with apply', async () => {
`)
})
})
test('with borders', async () => {
let config = {
mode: 'jit',
purge: [
{
raw: '<div class="border border-red-500 md:border-2"></div>',
},
],
theme: {},
plugins: [],
corePlugins: ['borderWidth', 'borderColor', 'borderOpacity'],
}
let css = `
@tailwind base;
/* --- */
@tailwind utilities;
`
return run(css, config).then((result) => {
expect(result.css).toMatchFormattedCss(`
.border,
.md\\:border-2 {
--tw-border-opacity: 1;
border-color: rgba(229, 231, 235, var(--tw-border-opacity));
}
/* --- */
.border {
border-width: 1px;
}
.border-red-500 {
--tw-border-opacity: 1;
border-color: rgba(239, 68, 68, var(--tw-border-opacity));
}
@media (min-width: 768px) {
.md\\:border-2 {
border-width: 2px;
}
}
`)
})
})