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

Commit 6606903

Browse files
committed
Add checked variant (fix #4)
1 parent ee2a38a commit 6606903

File tree

7 files changed

+1994
-1930
lines changed

7 files changed

+1994
-1930
lines changed

.release-it.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"git": {
3-
"tagName": "v%s"
3+
"tagName": "v%s",
4+
"requireCleanWorkingDir": false
45
}
56
}

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ 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-
## [3.0.0] - XXXX-XX-XX
8+
## [3.0.0] - 2020-02-05
9+
10+
### Added
11+
- Added a `checked` variant
912

1013
### Changed
1114
- Changed to use Tailwind 1.2’s new plugin definition syntax

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
},
1818
},
1919
variants: {
20-
backgroundColor: ['group-focus', 'group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus'],
20+
backgroundColor: ['checked', 'group-focus', 'group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus'],
2121
},
2222
plugins: [
2323
require('tailwindcss-interaction-variants'),
@@ -32,6 +32,10 @@ The above configuration would generate the following CSS:
3232
background-color: black;
3333
}
3434

35+
.checked\:bg-black:checked {
36+
background-color: black;
37+
}
38+
3539
.group:focus .group-focus\:bg-black {
3640
background-color: black;
3741
}

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ module.exports = plugin(function({ addVariant, config }) {
99
return `${getPrefix(`.${className}`)}${className}`;
1010
};
1111

12+
const pseudoClassVariant = function(pseudoClass) {
13+
return ({ modifySelectors, separator }) => {
14+
return modifySelectors(({ selector }) => {
15+
return selectorParser(selectors => {
16+
selectors.walkClasses(classNode => {
17+
classNode.value = `${pseudoClass}${separator}${classNode.value}`;
18+
classNode.parent.insertAfter(classNode, selectorParser.pseudo({ value: `:${pseudoClass}` }));
19+
});
20+
}).processSync(selector);
21+
});
22+
};
23+
};
24+
1225
const groupPseudoClassVariant = function(pseudoClass) {
1326
return ({ modifySelectors, separator }) => {
1427
return modifySelectors(({ selector }) => {
@@ -22,6 +35,7 @@ module.exports = plugin(function({ addVariant, config }) {
2235
};
2336
};
2437

38+
addVariant('checked', pseudoClassVariant('checked'));
2539
addVariant('group-focus', groupPseudoClassVariant('focus'));
2640
addVariant('group-focus-within', groupPseudoClassVariant('focus-within'));
2741
addVariant('group-active', groupPseudoClassVariant('active'));

0 commit comments

Comments
 (0)