Skip to content

Commit 788fce5

Browse files
committed
create plugin
0 parents  commit 788fce5

File tree

6 files changed

+623
-0
lines changed

6 files changed

+623
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 - tailwindcss-first-line
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Tailwindcss plugin for :first-line
2+
3+
This Tailwind plugin implements the [CSS :first-line pseudo-element](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-line)
4+
5+
## Installation
6+
7+
```bash
8+
npm install tailwindcss-first-line
9+
```
10+
11+
or
12+
13+
```bash
14+
yarn add tailwindcss-first-line
15+
```
16+
17+
## Usage
18+
19+
```javascript
20+
// tailwind.config.js
21+
22+
module.exports = {
23+
...
24+
plugins: [
25+
require('tailwindcss-first-line'),
26+
...
27+
]
28+
}
29+
```
30+
31+
Then, add the `first-line` variant to each property you'd like to use it with.
32+
33+
```javascript
34+
textColor: [
35+
'responsive',
36+
'hover',
37+
'focus',
38+
'first-line',
39+
],
40+
```
41+
42+
You can then use it by preprending `first-line:` to your classes, like `first-line:your-class`.
43+
44+
For example, to change the color of the first line of a paragraph to white, you would write `first-line:text-white`.
45+
46+
If you have a prefix set in your config (e.g. `tw`), you would use the following syntax: `first-line:tw-text-white`.
47+
48+
**`:first-line` only applies to [block-level elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements#elements).**

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const plugin = require("tailwindcss/plugin");
2+
3+
module.exports = plugin(function ({ addVariant, e }) {
4+
addVariant("first-line", ({ modifySelectors, separator }) => {
5+
modifySelectors(({ className }) => {
6+
const newClass = e(`first-line${separator}${className}`);
7+
return `.${newClass}:first-line`;
8+
});
9+
});
10+
});

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@netlify/tailwindcss-first-line",
3+
"version": "1.0.0",
4+
"description": "Tailwind plugin for the :first-line CSS pseudo-element",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/netlify/tailwindcss-first-line.git"
12+
},
13+
"devDependencies": {
14+
"tailwindcss": "^2.0.3"
15+
},
16+
"author": "Netlify",
17+
"contributors": [
18+
"Charlie Gerard <[email protected]> (https://charliegerard.dev)"
19+
],
20+
"bugs": {
21+
"url": "https://github.com/netlify/tailwindcss-first-line/issues"
22+
},
23+
"homepage": "https://github.com/netlify/tailwindcss-first-line#readme",
24+
"keywords": [
25+
"CSS",
26+
"netlify",
27+
"Tailwind"
28+
],
29+
"license": "MIT"
30+
}

0 commit comments

Comments
 (0)