Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(CSS): outline doesn't handle some keyword values #299

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/css/src/config/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ const rules = {
variables: ['spacing']
} as Rule['options'],
outlineStyle: {
match: ['outline', ['dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']],
match: ['outline', ['none', 'auto', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset']],
layer: CoreLayer.Native
} as Rule['options'],
outlineWidth: {
Expand All @@ -1668,9 +1668,15 @@ const rules = {
layer: CoreLayer.NativeShorthand,
colored: true,
transform(value) {
if (!/hidden|dotted|dashed|solid|double|groove|ridge|inset|outset/i.test(value)) {
const outlineGlobalValuesRegex =
/^(?:inherit|initial|revert|revert-layer|unset)$/i
Comment on lines +1671 to +1672
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are applicable for all CSS properties but decided to keep it here while it's used only in this place.

const outlineStyleRegex = /none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset/i
const outlineAutoRegex = /auto/i

if (!outlineGlobalValuesRegex.test(value) && !outlineStyleRegex.test(value) && !outlineAutoRegex.test(value)) {
value += ' solid'
}

return value
},
variables: [
Expand Down
12 changes: 12 additions & 0 deletions packages/css/tests/outline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@ test('outline', () => {
testProp('outline:2|black', 'outline:0.125rem #000000 solid')
testProp('outline-offset:1', 'outline-offset:0.0625rem')
testProp('outline:1', 'outline-width:0.0625rem')
testProp('outline:dashed|black', 'outline:dashed #000000')
testProp('outline:solid', 'outline-style:solid')
testProp('outline:1rem|solid', 'outline:1rem solid')
testProp('outline:thick|double|black', 'outline:thick double #000000')
testProp('outline:none', 'outline-style:none')
testProp('outline:unset', 'outline:unset')
testProp('outline:inherit', 'outline:inherit')
testProp('outline:initial', 'outline:initial')
testProp('outline:revert', 'outline:revert')
testProp('outline:revert-layer', 'outline:revert-layer')
testProp('outline:auto', 'outline-style:auto')
testProp('outline:auto|1', 'outline:auto 0.0625rem')
})
Loading