Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit 6b598c6

Browse files
committed
Add test and readme note about referencing theme colors
1 parent 0e79a7a commit 6b598c6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ npm install tailwindcss-gradients
3838
],
3939
}
4040
```
41+
or you can reference your existing theme colors:
42+
```js
43+
{
44+
theme: {
45+
colors: {
46+
'red': '#f00',
47+
'blue': '#00f',
48+
},
49+
gradients: theme => ({
50+
// directions: { ... },
51+
colors: theme('colors'),
52+
}),
53+
},
54+
plugins: [
55+
require('tailwindcss-gradients')(),
56+
],
57+
}
58+
```
4159

4260
This plugin generates the following utilities:
4361

test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,35 @@ test('multiple directions and multiple gradients can be used together', () => {
217217
});
218218
});
219219

220+
test('colors can be referenced from the theme with a closure', () => {
221+
return generatePluginCss({
222+
theme: {
223+
colors: {
224+
'red': '#f00',
225+
'blue': '#00f',
226+
},
227+
gradients: theme => ({
228+
directions: {
229+
'b': 'to bottom',
230+
},
231+
colors: theme('colors'),
232+
}),
233+
},
234+
variants: {
235+
gradients: [],
236+
},
237+
}).then(css => {
238+
expect(css).toMatchCss(`
239+
.bg-gradient-b-red {
240+
background-image: linear-gradient(to bottom, rgba(255, 0, 0, 0), #f00);
241+
}
242+
.bg-gradient-b-blue {
243+
background-image: linear-gradient(to bottom, rgba(0, 0, 255, 0), #00f);
244+
}
245+
`);
246+
});
247+
});
248+
220249
test('responsive utilities are generated by default', () => {
221250
return generatePluginCss({
222251
theme: {

0 commit comments

Comments
 (0)