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

Add remaining text-decoration utilities #6004

Merged
merged 6 commits into from Nov 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/corePlugins.js
Expand Up @@ -1396,8 +1396,10 @@ export let corePlugins = {

boxDecorationBreak: ({ addUtilities }) => {
addUtilities({
'.decoration-slice': { 'box-decoration-break': 'slice' },
'.decoration-clone': { 'box-decoration-break': 'clone' },
'.decoration-slice': { 'box-decoration-break': 'slice' }, // Deprecated
'.decoration-clone': { 'box-decoration-break': 'clone' }, // Deprecated
'.box-decoration-slice': { 'box-decoration-break': 'slice' },
'.box-decoration-clone': { 'box-decoration-break': 'clone' },
})
},

Expand Down Expand Up @@ -1655,6 +1657,7 @@ export let corePlugins = {
textDecoration: ({ addUtilities }) => {
addUtilities({
'.underline': { 'text-decoration': 'underline' },
'.overline': { 'text-decoration': 'overline' },
'.line-through': { 'text-decoration': 'line-through' },
'.no-underline': { 'text-decoration': 'none' },
})
Expand All @@ -1671,6 +1674,28 @@ export let corePlugins = {
)
},

textDecorationStyle: ({ addUtilities }) => {
addUtilities({
'.decoration-solid': { 'text-decoration-style': 'solid' },
'.decoration-double': { 'text-decoration-style': 'double' },
'.decoration-dotted': { 'text-decoration-style': 'dotted' },
'.decoration-dashed': { 'text-decoration-style': 'dashed' },
'.decoration-wavy': { 'text-decoration-style': 'wavy' },
})
},

textDecorationThickness: createUtilityPlugin(
'textDecorationThickness',
[['decoration', ['text-decoration-thickness']]],
{ type: ['length', 'percentage'] }
),

textUnderlineOffset: createUtilityPlugin(
'textUnderlineOffset',
[['underline-offset', ['text-underline-offset']]],
{ type: ['length', 'percentage'] }
),

fontSmoothing: ({ addUtilities }) => {
addUtilities({
'.antialiased': {
Expand Down
17 changes: 17 additions & 0 deletions stubs/defaultConfig.stub.js
Expand Up @@ -798,6 +798,23 @@ module.exports = {
},
textColor: ({ theme }) => theme('colors'),
textDecorationColor: ({ theme }) => theme('colors'),
textDecorationThickness: {
auto: 'auto',
'from-font': 'from-font',
0: '0px',
1: '1px',
2: '2px',
4: '4px',
8: '8px',
},
textUnderlineOffset: {
auto: 'auto',
0: '0px',
1: '1px',
2: '2px',
4: '4px',
8: '8px',
},
textIndent: ({ theme }) => ({
...theme('spacing'),
}),
Expand Down
6 changes: 6 additions & 0 deletions tests/arbitrary-values.test.css
Expand Up @@ -825,6 +825,12 @@
.decoration-\[var\(--color\)\] {
text-decoration-color: var(--color);
}
.decoration-\[length\:10px\] {
text-decoration-thickness: 10px;
}
.underline-offset-\[10px\] {
text-underline-offset: 10px;
}
.placeholder-\[var\(--placeholder\)\]::placeholder {
color: var(--placeholder);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/arbitrary-values.test.html
Expand Up @@ -305,6 +305,10 @@
<div class="decoration-[color:var(--color)]"></div>
<div class="decoration-[var(--color)]"></div>

<div class="decoration-[length:10px]"></div>

<div class="underline-offset-[10px]"></div>

<div class="placeholder-[var(--placeholder)]"></div>

<div class="placeholder-opacity-[var(--placeholder-opacity)]"></div>
Expand Down
21 changes: 21 additions & 0 deletions tests/basic-usage.test.css
Expand Up @@ -662,6 +662,12 @@
.decoration-clone {
box-decoration-break: clone;
}
.box-decoration-slice {
box-decoration-break: slice;
}
.box-decoration-clone {
box-decoration-break: clone;
}
.bg-cover {
background-size: cover;
}
Expand Down Expand Up @@ -799,6 +805,21 @@
.decoration-red-600 {
text-decoration-color: #dc2626;
}
.decoration-solid {
text-decoration-style: solid;
}
.decoration-1 {
text-decoration-thickness: 1px;
}
.decoration-2 {
text-decoration-thickness: 2px;
}
.underline-offset-1 {
text-underline-offset: 1px;
}
.underline-offset-2 {
text-underline-offset: 2px;
}
.antialiased {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
Expand Down
8 changes: 8 additions & 0 deletions tests/basic-usage.test.html
Expand Up @@ -34,6 +34,7 @@
<div class="shadow shadow-md shadow-lg"></div>
<div class="shadow-black shadow-red-500/25 shadow-blue-100/10"></div>
<div class="decoration-clone decoration-slice"></div>
<div class="box-decoration-clone box-decoration-slice"></div>
<div class="box-border"></div>
<div class="clear-left"></div>
<div class="container"></div>
Expand Down Expand Up @@ -160,7 +161,14 @@
<div class="text-indigo-500"></div>
<div class="text-opacity-10"></div>
<div class="underline"></div>
<div class="decoration-underline"></div>
<div class="decoration-red-600"></div>
<div class="decoration-solid"></div>
<div class="decoration-1"></div>
<div class="decoration-2"></div>
<div class="underline-offset-1"></div>
<div class="underline-offset-2"></div>
<div class="underline-right"></div>
<div class="overflow-ellipsis truncate"></div>
<div class="uppercase"></div>
<div class="transform transform-gpu transform-none"></div>
Expand Down