Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Commit 007015c

Browse files
committed
Changes for Tailwind 1.0.0
1 parent b9a4195 commit 007015c

File tree

8 files changed

+2752
-3851
lines changed

8 files changed

+2752
-3851
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/node_modules/
1+
/node_modules/

.release-it.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"src": {
2+
"git": {
33
"tagName": "v%s"
44
}
5-
}
5+
}

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ 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.0.0-beta.1] - 2019-04-07
9+
10+
### Added
11+
- Tailwind 1.0.0 compatibility
12+
13+
### Changed
14+
- The plugin doesn’t accept a config object anymore; instead it finds what it needs in the `theme` and `variants` keys of your config (see `README` for more info)
15+
- Responsive variants are now generated by default
16+
817
## [1.0.2] - 2018-11-04
918

1019
### Added
@@ -19,6 +28,7 @@ and this project mostly adheres to [Semantic Versioning](https://semver.org/spec
1928

2029
Initial release
2130

22-
[Unreleased]: https://github.com/benface/tailwindcss-filters/compare/v1.0.2...HEAD
31+
[Unreleased]: https://github.com/benface/tailwindcss-filters/compare/v2.0.0-beta.1...HEAD
32+
[2.0.0-beta.1]: https://github.com/benface/tailwindcss-filters/compare/v1.0.2...v2.0.0-beta.1
2333
[1.0.2]: https://github.com/benface/tailwindcss-filters/compare/v1.0.1...v1.0.2
24-
[1.0.1]: https://github.com/benface/tailwindcss-filters/compare/v1.0.0...v1.0.1
34+
[1.0.1]: https://github.com/benface/tailwindcss-filters/compare/v1.0.0...v1.0.1

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Filters Tailwind CSS Plugin
1+
# Filters Plugin for Tailwind CSS
22

33
## Installation
44

@@ -11,33 +11,38 @@ npm install tailwindcss-filters
1111
```js
1212
// In your Tailwind CSS config
1313
{
14+
theme: {
15+
filter: { // defaults to {}
16+
'none': 'none',
17+
'grayscale': 'grayscale(1)',
18+
'invert': 'invert(1)',
19+
'sepia': 'sepia(1)',
20+
},
21+
backdropFilter: { // defaults to {}
22+
'none': 'none',
23+
'blur': 'blur(20px)',
24+
},
25+
},
26+
variants: {
27+
filter: ['responsive'], // defaults to ['responsive']
28+
backdropFilter: ['responsive'], // defaults to ['responsive']
29+
},
1430
plugins: [
15-
require('tailwindcss-filters')({
16-
variants: ['responsive'],
17-
filters: {
18-
'none': 'none',
19-
'blur': 'blur(5px)',
20-
},
21-
backdropFilters: {
22-
'none': 'none',
23-
'blur': 'blur(20px)',
24-
'grayscale': 'grayscale(100%)',
25-
},
26-
}),
31+
require('tailwindcss-filters')(),
2732
],
2833
}
2934
```
3035

3136
This plugin generates the following utilities:
3237

3338
```css
34-
/* configurable with the "filters" option */
35-
.filter-[name] {
39+
/* configurable with the "filter" theme object */
40+
.filter-[key] {
3641
filter: [value];
3742
}
3843

39-
/* configurable with the "backdropFilters" option */
40-
.backdrop-[name] {
44+
/* configurable with the "backdropFilter" theme object */
45+
.backdrop-[key] {
4146
backdrop-filter: [value];
4247
}
43-
```
48+
```

index.js

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
const _ = require('lodash');
22

3-
module.exports = ({
4-
variants = {},
5-
filters = {},
6-
backdropFilters = {},
7-
} = {}) => ({ e, addUtilities }) => {
8-
addUtilities(
9-
{
10-
...Object.assign(
11-
{},
12-
..._.map(filters, (value, name) => ({
13-
[`.${e(`filter-${name}`)}`]: { filter: value },
14-
})),
15-
..._.map(backdropFilters, (value, name) => ({
16-
[`.${e(`backdrop-${name}`)}`]: { backdropFilter: value },
17-
})),
18-
),
19-
},
20-
variants,
21-
);
3+
module.exports = function() {
4+
return ({ config, e, addUtilities }) => {
5+
const defaultFilterTheme = {};
6+
const defaultFilterVariants = ['responsive'];
7+
const defaultBackdropFilterTheme = {};
8+
const defaultBackdropFilterVariants = ['responsive'];
9+
10+
const filterUtilities = _.fromPairs(
11+
_.map(config('theme.filter', defaultFilterTheme), (value, modifier) => {
12+
return [
13+
`.${e(`filter-${modifier}`)}`,
14+
{
15+
filter: value,
16+
},
17+
];
18+
})
19+
);
20+
21+
const backdropFilterUtilities = _.fromPairs(
22+
_.map(config('theme.backdropFilter', defaultBackdropFilterTheme), (value, modifier) => {
23+
return [
24+
`.${e(`backdrop-${modifier}`)}`,
25+
{
26+
backdropFilter: value,
27+
},
28+
];
29+
})
30+
);
31+
32+
addUtilities(filterUtilities, config('variants.filter', defaultFilterVariants));
33+
addUtilities(backdropFilterUtilities, config('variants.backdropFilter', defaultBackdropFilterVariants));
34+
};
2235
};

0 commit comments

Comments
 (0)