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

Don't inherit gradient "to" from parent #8489

Merged
merged 2 commits into from
Jun 1, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
- Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
- Don't inherit `to` value from parent gradients ([#8489](https://github.com/tailwindlabs/tailwindcss/pull/8489))

### Changed

Expand Down
6 changes: 4 additions & 2 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ export let corePlugins = {

return {
'--tw-gradient-from': toColorValue(value, 'from'),
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to, ${transparentToValue})`,
'--tw-gradient-to': transparentToValue,
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to)`,
}
},
},
Expand All @@ -1449,10 +1450,11 @@ export let corePlugins = {
let transparentToValue = transparentTo(value)

return {
'--tw-gradient-to': transparentToValue,
'--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
value,
'via'
)}, var(--tw-gradient-to, ${transparentToValue})`,
)}, var(--tw-gradient-to)`,
}
},
},
Expand Down
12 changes: 8 additions & 4 deletions tests/arbitrary-values.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,18 +651,22 @@
}
.from-\[\#da5b66\] {
--tw-gradient-from: #da5b66;
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(218 91 102 / 0));
--tw-gradient-to: rgb(218 91 102 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-\[var\(--color\)\] {
--tw-gradient-from: var(--color);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(255 255 255 / 0));
--tw-gradient-to: rgb(255 255 255 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-\[\#da5b66\] {
--tw-gradient-stops: var(--tw-gradient-from), #da5b66, var(--tw-gradient-to, rgb(218 91 102 / 0));
--tw-gradient-to: rgb(218 91 102 / 0);
--tw-gradient-stops: var(--tw-gradient-from), #da5b66, var(--tw-gradient-to);
}
.via-\[var\(--color\)\] {
--tw-gradient-to: rgb(255 255 255 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--color),
var(--tw-gradient-to, rgb(255 255 255 / 0));
var(--tw-gradient-to);
}
.to-\[\#da5b66\] {
--tw-gradient-to: #da5b66;
Expand Down
6 changes: 4 additions & 2 deletions tests/basic-usage.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,12 @@
}
.from-red-300 {
--tw-gradient-from: #fca5a5;
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(252 165 165 / 0));
--tw-gradient-to: rgb(252 165 165 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-purple-200 {
--tw-gradient-stops: var(--tw-gradient-from), #e9d5ff, var(--tw-gradient-to, rgb(233 213 255 / 0));
--tw-gradient-to: rgb(233 213 255 / 0);
--tw-gradient-stops: var(--tw-gradient-from), #e9d5ff, var(--tw-gradient-to);
}
.to-blue-400 {
--tw-gradient-to: #60a5fa;
Expand Down
3 changes: 2 additions & 1 deletion tests/color-opacity-modifiers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ test('utilities that support any type are supported', async () => {
expect(result.css).toMatchFormattedCss(css`
.from-red-500\/50 {
--tw-gradient-from: rgb(239 68 68 / 0.5);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(239 68 68 / 0));
--tw-gradient-to: rgb(239 68 68 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.fill-red-500\/25 {
fill: rgb(239 68 68 / 0.25);
Expand Down
3 changes: 2 additions & 1 deletion tests/kitchen-sink.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ div {
}
.from-foo {
--tw-gradient-from: #bada55;
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(186 218 85 / 0));
--tw-gradient-to: rgb(186 218 85 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.text-center {
text-align: center;
Expand Down
14 changes: 8 additions & 6 deletions tests/plugins/gradientColorStops.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ test('opacity variables are given to colors defined as closures', () => {
expect(result.css).toMatchFormattedCss(css`
.from-primary {
--tw-gradient-from: rgb(31, 31, 31);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(31, 31, 31, 0));
--tw-gradient-to: rgba(31, 31, 31, 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.from-secondary {
--tw-gradient-from: hsl(10, 50%, 50%);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, hsl(10 50% 50% / 0));
--tw-gradient-to: hsl(10 50% 50% / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-primary {
--tw-gradient-stops: var(--tw-gradient-from), rgb(31, 31, 31),
var(--tw-gradient-to, rgba(31, 31, 31, 0));
--tw-gradient-to: rgba(31, 31, 31, 0);
--tw-gradient-stops: var(--tw-gradient-from), rgb(31, 31, 31), var(--tw-gradient-to);
}
.via-secondary {
--tw-gradient-stops: var(--tw-gradient-from), hsl(10, 50%, 50%),
var(--tw-gradient-to, hsl(10 50% 50% / 0));
--tw-gradient-to: hsl(10 50% 50% / 0);
--tw-gradient-stops: var(--tw-gradient-from), hsl(10, 50%, 50%), var(--tw-gradient-to);
}
.to-primary {
--tw-gradient-to: rgb(31, 31, 31);
Expand Down
6 changes: 4 additions & 2 deletions tests/raw-content.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@
}
.from-red-300 {
--tw-gradient-from: #fca5a5;
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(252 165 165 / 0));
--tw-gradient-to: rgb(252 165 165 / 0);
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
.via-purple-200 {
--tw-gradient-stops: var(--tw-gradient-from), #e9d5ff, var(--tw-gradient-to, rgb(233 213 255 / 0));
--tw-gradient-to: rgb(233 213 255 / 0);
--tw-gradient-stops: var(--tw-gradient-from), #e9d5ff, var(--tw-gradient-to);
}
.to-blue-400 {
--tw-gradient-to: #60a5fa;
Expand Down