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

Commit 75258ac

Browse files
committed
Initial commit
0 parents  commit 75258ac

File tree

8 files changed

+8001
-0
lines changed

8 files changed

+8001
-0
lines changed

.gitignore

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

.release-it.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"git": {
3+
"tagName": "v%s"
4+
}
5+
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## 1.0.0 - 2019-02-14
9+
10+
Initial release
11+
12+
[Unreleased]: https://github.com/benface/tailwindcss-layout/compare/v1.0.0...HEAD

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Interaction Variants Plugin for Tailwind CSS
2+
3+
## Installation
4+
5+
```bash
6+
npm install tailwindcss-interaction-variants
7+
```
8+
9+
## Usage
10+
11+
```js
12+
// In your Tailwind CSS config
13+
{
14+
backgroundColors: {
15+
'black': 'black',
16+
},
17+
18+
// ...
19+
20+
modules: {
21+
backgroundColors: ['hocus', 'group-hocus', 'group-focus', 'group-active', 'visited'],
22+
},
23+
24+
// ...
25+
26+
plugins: [
27+
require('tailwindcss-interaction-variants')(), // nothing to configure!
28+
],
29+
}
30+
```
31+
32+
The above configuration would generate the following classes:
33+
34+
```css
35+
.bg-black {
36+
background-color: black;
37+
}
38+
39+
.hocus\:bg-black:hover, .hocus\:bg-black:focus {
40+
background-color: black;
41+
}
42+
43+
.group:hover .group-hocus\:bg-black, .group:focus .group-hocus\:bg-black {
44+
background-color: black;
45+
}
46+
47+
.group:focus .group-focus\:bg-black {
48+
background-color: black;
49+
}
50+
51+
.group:active .group-active\:bg-black {
52+
background-color: black;
53+
}
54+
55+
.visited\:bg-black:visited {
56+
background-color: black;
57+
}
58+
```

index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const _ = require('lodash');
2+
3+
module.exports = () => ({ e, addVariant }) => {
4+
addVariant('hocus', ({ modifySelectors, separator }) => {
5+
modifySelectors(({ className }) => {
6+
return `.hocus${separator}${className}:hover, .hocus${separator}${className}:focus`;
7+
});
8+
});
9+
addVariant('group-hocus', ({ modifySelectors, separator }) => {
10+
modifySelectors(({ className }) => {
11+
return `.group:hover .group-hocus${separator}${className}, .group:focus .group-hocus${separator}${className}`;
12+
});
13+
});
14+
addVariant('group-focus', ({ modifySelectors, separator }) => {
15+
modifySelectors(({ className }) => {
16+
return `.group:focus .group-focus${separator}${className}`;
17+
});
18+
});
19+
addVariant('group-active', ({ modifySelectors, separator }) => {
20+
modifySelectors(({ className }) => {
21+
return `.group:active .group-active${separator}${className}`;
22+
});
23+
});
24+
addVariant('visited', ({ modifySelectors, separator }) => {
25+
modifySelectors(({ className }) => {
26+
return `.visited${separator}${className}:visited`;
27+
});
28+
});
29+
};

0 commit comments

Comments
 (0)