Fix issue where using theme with default line-heights did not resolve correctly
This commit is contained in:
parent
a2c6dccc74
commit
15ae28a37e
4 changed files with 96 additions and 1 deletions
|
|
@ -2050,3 +2050,65 @@ test('keyframes are not escaped', () => {
|
|||
}
|
||||
`)
|
||||
})
|
||||
|
||||
test('font sizes are retrieved without default line-heights or letter-spacing using theme function', () => {
|
||||
const { components } = processPlugins(
|
||||
[
|
||||
function({ addComponents, theme }) {
|
||||
addComponents({
|
||||
'.foo': {
|
||||
fontSize: theme('fontSize.sm'),
|
||||
},
|
||||
})
|
||||
},
|
||||
],
|
||||
makeConfig({
|
||||
theme: {
|
||||
fontSize: {
|
||||
sm: ['14px', '20px'],
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
expect(css(components)).toMatchCss(`
|
||||
@layer components {
|
||||
@variants {
|
||||
.foo {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
test('outlines are retrieved without outline-offset using theme function', () => {
|
||||
const { components } = processPlugins(
|
||||
[
|
||||
function({ addComponents, theme }) {
|
||||
addComponents({
|
||||
'.foo': {
|
||||
outline: theme('outline.black'),
|
||||
},
|
||||
})
|
||||
},
|
||||
],
|
||||
makeConfig({
|
||||
theme: {
|
||||
outline: {
|
||||
black: ['2px dotted black', '4px'],
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
expect(css(components)).toMatchCss(`
|
||||
@layer components {
|
||||
@variants {
|
||||
.foo {
|
||||
outline: 2px dotted black;
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -154,3 +154,24 @@ test('font sizes are retrieved without default line-heights or letter-spacing',
|
|||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('outlines are retrieved without default outline-offset', () => {
|
||||
const input = `
|
||||
.element { outline: theme('outline.black'); }
|
||||
`
|
||||
|
||||
const output = `
|
||||
.element { outline: 2px dotted black; }
|
||||
`
|
||||
|
||||
return run(input, {
|
||||
theme: {
|
||||
outline: {
|
||||
black: ['2px dotted black', '4px'],
|
||||
},
|
||||
},
|
||||
}).then(result => {
|
||||
expect(result.css).toMatchCss(output)
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ const themeTransforms = {
|
|||
fontSize(value) {
|
||||
return Array.isArray(value) ? value[0] : value
|
||||
},
|
||||
outline(value) {
|
||||
return Array.isArray(value) ? value[0] : value
|
||||
},
|
||||
}
|
||||
|
||||
function defaultTransform(value) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,16 @@ export default function(plugins, config) {
|
|||
handler({
|
||||
postcss,
|
||||
config: getConfigValue,
|
||||
theme: (path, defaultValue) => getConfigValue(`theme.${path}`, defaultValue),
|
||||
theme: (path, defaultValue) => {
|
||||
const value = getConfigValue(`theme.${path}`, defaultValue)
|
||||
const [rootPath] = _.toPath(path)
|
||||
|
||||
if (['fontSize', 'outline'].includes(rootPath)) {
|
||||
return Array.isArray(value) ? value[0] : value
|
||||
}
|
||||
|
||||
return value
|
||||
},
|
||||
corePlugins: path => {
|
||||
if (Array.isArray(config.corePlugins)) {
|
||||
return config.corePlugins.includes(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue