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

Commit ce7da0d

Browse files
committed
Add group-focus-visible variant (fix #9)
1 parent 95dc464 commit ce7da0d

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project mostly adheres to [Semantic Versioning](https://semver.org/spec
77

88
## [5.0.0] - 2020-08-04
99

10+
### Added
11+
- Added a `group-focus-visible` variant
12+
1013
### Removed
1114
- Removed the `checked` variant since it is built into Tailwind as of v1.5
1215

@@ -69,7 +72,8 @@ No change since 2.0.0-beta.1
6972

7073
Initial release
7174

72-
[Unreleased]: https://github.com/benface/tailwindcss-interaction-variants/compare/v4.0.0...HEAD
75+
[Unreleased]: https://github.com/benface/tailwindcss-interaction-variants/compare/v5.0.0...HEAD
76+
[5.0.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v4.0.0...v5.0.0
7377
[4.0.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v3.1.1...v4.0.0
7478
[3.1.1]: https://github.com/benface/tailwindcss-interaction-variants/compare/v3.1.0...v3.1.1
7579
[3.1.0]: https://github.com/benface/tailwindcss-interaction-variants/compare/v3.0.0...v3.1.0

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
},
2626
},
2727
variants: {
28-
backgroundColor: ['group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover'],
28+
backgroundColor: ['group-focus-within', 'group-focus-visible', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover'],
2929
},
3030
plugins: [
3131
require('tailwindcss-interaction-variants'),
@@ -44,6 +44,10 @@ The above configuration would generate the following CSS:
4444
background-color: black;
4545
}
4646

47+
.group:focus-visible .group-focus-visible\:bg-black {
48+
background-color: black;
49+
}
50+
4751
.group:active .group-active\:bg-black {
4852
background-color: black;
4953
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module.exports = plugin(function({ addVariant, config, e, postcss }) {
3838
};
3939

4040
addVariant('group-focus-within', groupPseudoClassVariant('focus-within'));
41+
addVariant('group-focus-visible', groupPseudoClassVariant('focus-visible'));
4142
addVariant('group-active', groupPseudoClassVariant('active'));
4243
addVariant('group-visited', groupPseudoClassVariant('visited'));
4344
addVariant('group-disabled', groupPseudoClassVariant('disabled'));

test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ test('the no-hover variant is working', () => {
105105
});
106106

107107
test('all the variants are working', () => {
108-
return generatePluginCss(['group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover']).then(css => {
108+
return generatePluginCss(['group-focus-within', 'group-focus-visible', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover']).then(css => {
109109
expect(css).toMatchCss(`
110110
.w-1\\/2 {
111111
width: 50%;
112112
}
113113
.group:focus-within .group-focus-within\\:w-1\\/2 {
114114
width: 50%;
115115
}
116+
.group:focus-visible .group-focus-visible\\:w-1\\/2 {
117+
width: 50%;
118+
}
116119
.group:active .group-active\\:w-1\\/2 {
117120
width: 50%;
118121
}
@@ -143,14 +146,17 @@ test('all the variants are working', () => {
143146
});
144147

145148
test('all variants can be chained with the responsive variant', () => {
146-
return generatePluginCss(['group-focus-within', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover', 'responsive']).then(css => {
149+
return generatePluginCss(['group-focus-within', 'group-focus-visible', 'group-active', 'group-visited', 'group-disabled', 'hocus', 'group-hocus', 'can-hover', 'no-hover', 'responsive']).then(css => {
147150
expect(css).toMatchCss(`
148151
.w-1\\/2 {
149152
width: 50%;
150153
}
151154
.group:focus-within .group-focus-within\\:w-1\\/2 {
152155
width: 50%;
153156
}
157+
.group:focus-visible .group-focus-visible\\:w-1\\/2 {
158+
width: 50%;
159+
}
154160
.group:active .group-active\\:w-1\\/2 {
155161
width: 50%;
156162
}
@@ -183,6 +189,9 @@ test('all variants can be chained with the responsive variant', () => {
183189
.group:focus-within .sm\\:group-focus-within\\:w-1\\/2 {
184190
width: 50%;
185191
}
192+
.group:focus-visible .sm\\:group-focus-visible\\:w-1\\/2 {
193+
width: 50%;
194+
}
186195
.group:active .sm\\:group-active\\:w-1\\/2 {
187196
width: 50%;
188197
}

0 commit comments

Comments
 (0)