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

Commit 01cb3a4

Browse files
committed
Add default transition property + shadow + more durations
1 parent 00b864a commit 01cb3a4

File tree

6 files changed

+2651
-1670
lines changed

6 files changed

+2651
-1670
lines changed

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.2.0] - 2020-02-03
9+
10+
### Added
11+
- Added a `default` transition property, which generates a simple `transition` class and includes all the properties from `colors` as well as `opacity`, `box-shadow`, and `transform` (taken from Tailwind 1.2)
12+
- Added a `shadow` transition property (taken from Tailwind 1.2)
13+
- Added `50`, `75`, `150`, `200`, `300`, and `400` transition durations
14+
15+
### Changed
16+
- The `transition-colors` utility now includes the `fill` and `stroke` properties, in addition to `background-color`, `border-color`, and `color` (taken from Tailwind 1.2)
17+
818
## [2.1.0] - 2019-09-04
919

1020
### Changed since 2.1.0-beta.2
@@ -104,7 +114,8 @@ and this project mostly adheres to [Semantic Versioning](https://semver.org/spec
104114

105115
Initial release
106116

107-
[Unreleased]: https://github.com/benface/tailwindcss-transitions/compare/v2.1.0...HEAD
117+
[Unreleased]: https://github.com/benface/tailwindcss-transitions/compare/v2.2.0...HEAD
118+
[2.2.0]: https://github.com/benface/tailwindcss-transitions/compare/v2.1.0...v2.2.0
108119
[2.1.0]: https://github.com/benface/tailwindcss-transitions/compare/v2.1.0-beta.2...v2.1.0
109120
[2.1.0-beta.2]: https://github.com/benface/tailwindcss-transitions/compare/v2.0.1...v2.1.0-beta.2
110121
[2.1.0-beta.1]: https://github.com/benface/tailwindcss-transitions/compare/v2.0.1...v2.1.0-beta.1

README.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,31 @@ npm install tailwindcss-transitions
1010

1111
```js
1212
// tailwind.config.js
13-
{
13+
module.exports = {
1414
theme: {
1515
transitionProperty: { // defaults to these values
1616
'none': 'none',
1717
'all': 'all',
18-
'color': 'color',
18+
'default': ['background-color', 'border-color', 'color', 'fill', 'stroke', 'opacity', 'box-shadow', 'transform'],
19+
'colors': ['background-color', 'border-color', 'color', 'fill', 'stroke'],
1920
'bg': 'background-color',
2021
'border': 'border-color',
21-
'colors': ['color', 'background-color', 'border-color'],
22+
'color': 'color',
2223
'opacity': 'opacity',
24+
'shadow': 'box-shadow',
2325
'transform': 'transform',
2426
},
2527
transitionDuration: { // defaults to these values
2628
'default': '250ms',
2729
'0': '0ms',
30+
'50': '50ms',
31+
'75': '75ms',
2832
'100': '100ms',
33+
'150': '150ms',
34+
'200': '200ms',
2935
'250': '250ms',
36+
'300': '300ms',
37+
'400': '400ms',
3038
'500': '500ms',
3139
'750': '750ms',
3240
'1000': '1000ms',
@@ -66,7 +74,7 @@ npm install tailwindcss-transitions
6674
plugins: [
6775
require('tailwindcss-transitions')(),
6876
],
69-
}
77+
};
7078
```
7179

7280
The default configuration generates the following CSS:
@@ -92,6 +100,11 @@ The default configuration generates the following CSS:
92100
transition-duration: 250ms;
93101
transition-duration: var(--transition-duration);
94102
}
103+
.transition {
104+
transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
105+
transition-duration: 250ms;
106+
transition-duration: var(--transition-duration);
107+
}
95108
.transition-[property-key] {
96109
transition-property: [property-value];
97110
/* when the default duration is a value other than zero: */
@@ -111,9 +124,9 @@ The default configuration generates the following CSS:
111124
transition-duration: 0ms;
112125
transition-duration: var(--transition-duration);
113126
}
114-
.transition-100 {
115-
--transition-duration: 100ms;
116-
transition-duration: 100ms;
127+
.transition-50 {
128+
--transition-duration: 50ms;
129+
transition-duration: 50ms;
117130
transition-duration: var(--transition-duration);
118131
}
119132
.transition-[duration-key] {
@@ -181,4 +194,4 @@ Which you can then use in your HTML like this:
181194
</button>
182195
```
183196

184-
Note: The `transitionDuration`, `transitionTimingFunction`, and `transitionDelay` theme objects accept a `default` key that doesn’t generate any class; it is used to define a custom property on all elements and pseudo-elements (`*, *::before, *::after`) if the value differs from the CSS-defined default. These custom properties are then used to set actual properties on elements that have a `transition-[property]` or `transition-[duration]` class, so that you don’t have to define a duration, timing function, or delay every time.
197+
Note: The `transitionProperty`, `transitionDuration`, `transitionTimingFunction`, and `transitionDelay` theme objects accept a `default` key. For `transitionProperty`, it generates a simple `transition` class (instead of `transition-default`), but for the other three, `default` doesn’t generate any class; it is used to define a custom property on all elements and pseudo-elements (`*, *::before, *::after`) if the value differs from the CSS-defined default. These custom properties are then used to set actual properties on elements that have a `transition-[property]` or `transition-[duration]` class, so that you don’t have to define a duration, timing function, or delay every time.

index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ module.exports = function() {
77
const defaultPropertyTheme = {
88
'none': 'none',
99
'all': 'all',
10-
'color': 'color',
10+
'default': ['background-color', 'border-color', 'color', 'fill', 'stroke', 'opacity', 'box-shadow', 'transform'],
11+
'colors': ['background-color', 'border-color', 'color', 'fill', 'stroke'],
1112
'bg': 'background-color',
1213
'border': 'border-color',
13-
'colors': ['color', 'background-color', 'border-color'],
14+
'color': 'color',
1415
'opacity': 'opacity',
16+
'shadow': 'box-shadow',
1517
'transform': 'transform',
1618
};
1719
const defaultPropertyVariants = ['responsive'];
1820
const defaultDurationTheme = {
1921
'default': '250ms',
2022
'0': '0ms',
23+
'50': '50ms',
24+
'75': '75ms',
2125
'100': '100ms',
26+
'150': '150ms',
27+
'200': '200ms',
2228
'250': '250ms',
29+
'300': '300ms',
30+
'400': '400ms',
2331
'500': '500ms',
2432
'750': '750ms',
2533
'1000': '1000ms',
@@ -138,7 +146,7 @@ module.exports = function() {
138146
const propertyUtilities = _.fromPairs(
139147
_.map(propertyTheme, (value, modifier) => {
140148
return [
141-
`.${e(`transition-${modifier}`)}`,
149+
`.${e(`transition${modifier === 'default' ? '' : `-${modifier}`}`)}`,
142150
{
143151
transitionProperty: _.isArray(value) ? value.join(', ') : value,
144152
...defaultDurationStyles,

0 commit comments

Comments
 (0)