Skip to content

Commit 77dfac2

Browse files
JIT: Add caret-color utilities (#4499)
Co-Authored-By: Jesse Katsumata <[email protected]> Co-authored-by: Jesse Katsumata <[email protected]>
1 parent e6ea821 commit 77dfac2

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

src/corePlugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as plugins from './plugins/index.js'
22
import configurePlugins from './util/configurePlugins'
33

4-
const jitOnlyPlugins = ['content']
4+
const jitOnlyPlugins = ['caretColor', 'content']
55

66
export default function ({ corePlugins: corePluginConfig }) {
77
corePluginConfig = corePluginConfig.filter((pluginName) => !jitOnlyPlugins.includes(pluginName))

src/plugins/caretColor.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import flattenColorPalette from '../util/flattenColorPalette'
2+
import toColorValue from '../util/toColorValue'
3+
4+
export default function () {
5+
return function ({ matchUtilities, theme, variants }) {
6+
matchUtilities(
7+
{
8+
caret: (value) => {
9+
return { 'caret-color': toColorValue(value) }
10+
},
11+
},
12+
{
13+
values: flattenColorPalette(theme('caretColor')),
14+
variants: variants('caretColor'),
15+
type: ['color', 'any'],
16+
}
17+
)
18+
}
19+
}

src/plugins/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export { default as textDecoration } from './textDecoration'
123123
export { default as fontSmoothing } from './fontSmoothing'
124124
export { default as placeholderColor } from './placeholderColor'
125125
export { default as placeholderOpacity } from './placeholderOpacity'
126+
export { default as caretColor } from './caretColor'
126127

127128
export { default as opacity } from './opacity'
128129
export { default as backgroundBlendMode } from './backgroundBlendMode'

stubs/defaultConfig.stub.js

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ module.exports = {
165165
inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
166166
none: 'none',
167167
},
168+
caretColor: (theme) => theme('colors'),
168169
contrast: {
169170
0: '0',
170171
50: '.5',

tests/jit/basic-usage.test.css

+3
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@
604604
.placeholder-opacity-60::placeholder {
605605
--tw-placeholder-opacity: 0.6;
606606
}
607+
.caret-red-600 {
608+
caret-color: #dc2626;
609+
}
607610
.opacity-90 {
608611
opacity: 0.9;
609612
}

tests/jit/basic-usage.test.html

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
<div class="place-content-start"></div>
101101
<div class="placeholder-green-300"></div>
102102
<div class="placeholder-opacity-60"></div>
103+
<div class="caret-red-600"></div>
103104
<div class="place-items-end"></div>
104105
<div class="place-self-center"></div>
105106
<div class="pointer-events-none"></div>

0 commit comments

Comments
 (0)