Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit b76943f

Browse files
authored
Merge pull request #127 from tailwindlabs/fix-gradient-extensions
Fix extending gradient colors directly
2 parents 1529bf1 + 6381787 commit b76943f

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/corePlugins/gradientColorStops.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const transformThemeValue = require('tailwindcss/lib/util/transformThemeValue').default
21
const flattenColorPalette = require('tailwindcss/lib/util/flattenColorPalette').default
32
const toColorValue = require('tailwindcss/lib/util/toColorValue').default
43
const toRgba = require('tailwindcss/lib/util/withAlphaVariable').toRgba
@@ -17,11 +16,11 @@ function transparentTo(value) {
1716
}
1817
}
1918

20-
module.exports = function ({ matchUtilities, jit: { theme } }) {
21-
let colorPalette = flattenColorPalette(theme.backgroundColor)
19+
module.exports = function ({ matchUtilities, theme }) {
20+
let colorPalette = flattenColorPalette(theme('gradientColorStops'))
2221

2322
matchUtilities({
24-
from: (modifier, { theme }) => {
23+
from: (modifier) => {
2524
let value = asColor(modifier, colorPalette)
2625

2726
if (value === undefined) {
@@ -39,7 +38,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
3938
},
4039
})
4140
matchUtilities({
42-
via: (modifier, { theme }) => {
41+
via: (modifier) => {
4342
let value = asColor(modifier, colorPalette)
4443

4544
if (value === undefined) {
@@ -59,7 +58,7 @@ module.exports = function ({ matchUtilities, jit: { theme } }) {
5958
},
6059
})
6160
matchUtilities({
62-
to: (modifier, { theme }) => {
61+
to: (modifier) => {
6362
let value = asColor(modifier, colorPalette)
6463

6564
if (value === undefined) {

tests/00-kitchen-sink.test.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ div {
288288
.bg-opacity-50 {
289289
--tw-bg-opacity: 0.5;
290290
}
291+
.bg-gradient-to-r {
292+
background-image: linear-gradient(to right, var(--tw-gradient-stops));
293+
}
294+
.from-foo {
295+
--tw-gradient-from: #bada55;
296+
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(186, 218, 85, 0));
297+
}
291298
.text-center {
292299
text-align: center;
293300
}

tests/00-kitchen-sink.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<div class="filter-none filter-grayscale"></div>
3131
<div class="focus:font-normal"></div>
3232
<div class="font-medium"></div>
33+
<div class="bg-gradient-to-r from-foo"></div>
3334
<div class="custom-component custom-util"></div>
3435
<div class="bg-opacity-50"></div>
3536
<div class="focus:ring-2 focus:ring-blue-500"></div>

tests/00-kitchen-sink.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ test('it works', () => {
1919
range: { min: '1280px', max: '1535px' },
2020
multi: [{ min: '640px', max: '767px' }, { max: '868px' }],
2121
},
22+
gradientColorStops: {
23+
foo: '#bada55',
24+
},
2225
},
2326
},
2427
plugins: [

0 commit comments

Comments
 (0)