Skip to content

Commit 51f71af

Browse files
authored
Add accent-color utilities (#5387)
* Add accent-color utilities * Address comments
1 parent 9371cce commit 51f71af

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

src/plugins/accentColor.js

Lines changed: 19 additions & 0 deletions
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+
accent: (value) => {
9+
return { 'accent-color': toColorValue(value) }
10+
},
11+
},
12+
{
13+
values: flattenColorPalette(theme('accentColor')),
14+
variants: variants('accentColor'),
15+
type: 'color',
16+
}
17+
)
18+
}
19+
}

src/plugins/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export { default as fontSmoothing } from './fontSmoothing'
125125
export { default as placeholderColor } from './placeholderColor'
126126
export { default as placeholderOpacity } from './placeholderOpacity'
127127
export { default as caretColor } from './caretColor'
128+
export { default as accentColor } from './accentColor'
128129

129130
export { default as opacity } from './opacity'
130131
export { default as backgroundBlendMode } from './backgroundBlendMode'

stubs/defaultConfig.stub.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ module.exports = {
183183
none: 'none',
184184
},
185185
caretColor: (theme) => theme('colors'),
186+
accentColor: (theme) => ({
187+
...theme('colors'),
188+
auto: 'auto',
189+
}),
186190
contrast: {
187191
0: '0',
188192
50: '.5',

tests/basic-usage.test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@
649649
.caret-red-600 {
650650
caret-color: #dc2626;
651651
}
652+
.accent-red-600 {
653+
accent-color: #dc2626;
654+
}
652655
.opacity-90 {
653656
opacity: 0.9;
654657
}

tests/basic-usage.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<div class="placeholder-green-300"></div>
102102
<div class="placeholder-opacity-60"></div>
103103
<div class="caret-red-600"></div>
104+
<div class="accent-red-600"></div>
104105
<div class="place-items-end"></div>
105106
<div class="place-self-center"></div>
106107
<div class="pointer-events-none"></div>

0 commit comments

Comments
 (0)