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

Commit 90334a9

Browse files
committed
Add group-visited and group-disabled variants (fix #2)
1 parent 8e32ef8 commit 90334a9

File tree

4 files changed

+62
-54
lines changed

4 files changed

+62
-54
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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.4.0] - 2019-12-20
9+
10+
### Added
11+
- Added `group-visited` and `group-disabled` variants
12+
813
## [2.3.0] - 2019-11-29
914

1015
### Added
@@ -33,7 +38,8 @@ No change since 2.0.0-beta.1
3338

3439
Initial release
3540

36-
[Unreleased]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.3.0...HEAD
41+
[Unreleased]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.4.0...HEAD
42+
[2.4.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.3.0...v2.4.0
3743
[2.3.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.2.0...v2.3.0
3844
[2.2.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.1.0...v2.2.0
3945
[2.1.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v2.0.0...v2.1.0

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install tailwindcss-interaction-variants
1717
},
1818
},
1919
variants: {
20-
backgroundColor: ['group-focus', 'group-focus-within', 'group-active', 'hocus', 'group-hocus'],
20+
backgroundColor: ['group-focus', 'group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus'],
2121
},
2222
plugins: [
2323
require('tailwindcss-interaction-variants')(),
@@ -44,6 +44,14 @@ The above configuration would generate the following CSS:
4444
background-color: black;
4545
}
4646

47+
.group:visited .group-visited\:bg-black {
48+
background-color: black;
49+
}
50+
51+
.group:disabled .group-disabled\:bg-black {
52+
background-color: black;
53+
}
54+
4755
.hocus\:bg-black:hover, .hocus\:bg-black:focus {
4856
background-color: black;
4957
}

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module.exports = function() {
1919
addVariant('group-focus', groupPseudoClassVariant('focus'));
2020
addVariant('group-focus-within', groupPseudoClassVariant('focus-within'));
2121
addVariant('group-active', groupPseudoClassVariant('active'));
22+
addVariant('group-visited', groupPseudoClassVariant('visited'));
23+
addVariant('group-disabled', groupPseudoClassVariant('disabled'));
2224

2325
addVariant('hocus', ({ modifySelectors, separator }) => {
2426
modifySelectors(({ selector }) => {

test.js

Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const generatePluginCss = (variants = [], css = null) => {
1818
({ addUtilities }) => {
1919
addUtilities(css ? css : {
2020
'.test': {
21-
'display': 'none',
21+
'display': 'block',
2222
},
2323
}, variants);
2424
},
@@ -41,7 +41,7 @@ test('the plugin doesn’t do anything if the variants aren’t used', () => {
4141
return generatePluginCss().then(css => {
4242
expect(css).toMatchCss(`
4343
.test {
44-
display: none;
44+
display: block;
4545
}
4646
`);
4747
});
@@ -51,36 +51,10 @@ test('the group-focus variant is working', () => {
5151
return generatePluginCss(['group-focus']).then(css => {
5252
expect(css).toMatchCss(`
5353
.test {
54-
display: none;
54+
display: block;
5555
}
5656
.group:focus .group-focus\\:test {
57-
display: none;
58-
}
59-
`);
60-
});
61-
});
62-
63-
test('the group-focus-within variant is working', () => {
64-
return generatePluginCss(['group-focus-within']).then(css => {
65-
expect(css).toMatchCss(`
66-
.test {
67-
display: none;
68-
}
69-
.group:focus-within .group-focus-within\\:test {
70-
display: none;
71-
}
72-
`);
73-
});
74-
});
75-
76-
test('the group-active variant is working', () => {
77-
return generatePluginCss(['group-active']).then(css => {
78-
expect(css).toMatchCss(`
79-
.test {
80-
display: none;
81-
}
82-
.group:active .group-active\\:test {
83-
display: none;
57+
display: block;
8458
}
8559
`);
8660
});
@@ -90,10 +64,10 @@ test('the hocus variant is working', () => {
9064
return generatePluginCss(['hocus']).then(css => {
9165
expect(css).toMatchCss(`
9266
.test {
93-
display: none;
67+
display: block;
9468
}
9569
.hocus\\:test:hover, .hocus\\:test:focus {
96-
display: none;
70+
display: block;
9771
}
9872
`);
9973
});
@@ -103,48 +77,66 @@ test('the group-hocus variant is working', () => {
10377
return generatePluginCss(['group-hocus']).then(css => {
10478
expect(css).toMatchCss(`
10579
.test {
106-
display: none;
80+
display: block;
10781
}
10882
.group:hover .group-hocus\\:test, .group:focus .group-hocus\\:test {
109-
display: none;
83+
display: block;
11084
}
11185
`);
11286
});
11387
});
11488

115-
test('multiple variants can be used together', () => {
116-
return generatePluginCss(['responsive', 'hocus', 'group-active', 'group-focus', 'group-focus-within']).then(css => {
89+
test('all the variants are working', () => {
90+
return generatePluginCss(['responsive', 'group-focus', 'group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus']).then(css => {
11791
expect(css).toMatchCss(`
11892
.test {
119-
display: none;
93+
display: block;
12094
}
121-
.hocus\\:test:hover, .hocus\\:test:focus {
122-
display: none;
95+
.group:focus .group-focus\\:test {
96+
display: block;
97+
}
98+
.group:focus-within .group-focus-within\\:test {
99+
display: block;
123100
}
124101
.group:active .group-active\\:test {
125-
display: none;
102+
display: block;
126103
}
127-
.group:focus .group-focus\\:test {
128-
display: none;
104+
.group:visited .group-visited\\:test {
105+
display: block;
129106
}
130-
.group:focus-within .group-focus-within\\:test {
131-
display: none;
107+
.group:disabled .group-disabled\\:test {
108+
display: block;
109+
}
110+
.hocus\\:test:hover, .hocus\\:test:focus {
111+
display: block;
112+
}
113+
.group:hover .group-hocus\\:test, .group:focus .group-hocus\\:test {
114+
display: block;
132115
}
133116
@media (min-width: 640px) {
134117
.sm\\:test {
135-
display: none;
118+
display: block;
136119
}
137-
.sm\\:hocus\\:test:hover, .sm\\:hocus\\:test:focus {
138-
display: none;
120+
.group:focus .sm\\:group-focus\\:test {
121+
display: block;
122+
}
123+
.group:focus-within .sm\\:group-focus-within\\:test {
124+
display: block;
139125
}
140126
.group:active .sm\\:group-active\\:test {
141-
display: none;
127+
display: block;
142128
}
143-
.group:focus .sm\\:group-focus\\:test {
144-
display: none;
129+
.group:visited .sm\\:group-visited\\:test {
130+
display: block;
145131
}
146-
.group:focus-within .sm\\:group-focus-within\\:test {
147-
display: none;
132+
.group:disabled .sm\\:group-disabled\\:test {
133+
display: block;
134+
}
135+
.sm\\:hocus\\:test:hover, .sm\\:hocus\\:test:focus {
136+
display: block;
137+
}
138+
.group:hover .sm\\:group-hocus\\:test, .group:focus .sm\\:group-hocus\\:test {
139+
display: block;
148140
}
149141
}
150142
`);

0 commit comments

Comments
 (0)