Skip to content

Commit a0d5965

Browse files
committed
Initial commit 🌈
0 parents  commit a0d5965

8 files changed

+9437
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"git": {
3+
"tagName": "v${version}"
4+
},
5+
"github": {
6+
"release": true
7+
}
8+
}

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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-01-06
9+
10+
Initial release

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Tailwind CSS Border Gradients Plugin
2+
3+
This plugin is based on the [tailwindcss-gradients](https://github.com/benface/tailwindcss-gradients) plugin. Usage is the same, it just outputs `border-image` gradients, instead of `background-image`.
4+
5+
## Installation
6+
7+
```bash
8+
npm install tailwindcss-border-gradients
9+
```
10+
11+
## Usage
12+
13+
```js
14+
// In your Tailwind CSS config
15+
16+
{
17+
plugins: [
18+
require('tailwindcss-border-gradients')({
19+
variants: ['responsive'],
20+
directions: {
21+
't': 'to top',
22+
'r': 'to right',
23+
'b': 'to bottom',
24+
'l': 'to left',
25+
},
26+
gradients: {
27+
'red': '#f00',
28+
'red-blue': ['#f00', '#00f'],
29+
'red-green-blue': ['#f00', '#0f0', '#00f'],
30+
},
31+
}),
32+
],
33+
}
34+
```
35+
36+
This plugin generates the following utilities:
37+
38+
```css
39+
/* configurable with the "directions" and "gradients" options */
40+
41+
.border-gradient-[direction-name]-[gradient-name] {
42+
border-image: linear-gradient([direction-value], [gradient-color-1], [gradient-color-2], [...]) 1;
43+
}
44+
```
45+
46+
`directions` is optional and it defaults to:
47+
48+
```js
49+
{
50+
't': 'to top',
51+
'tr': 'to top right',
52+
'r': 'to right',
53+
'br': 'to bottom right',
54+
'b': 'to bottom',
55+
'bl': 'to bottom left',
56+
'l': 'to left',
57+
'tl': 'to top left',
58+
}
59+
```

index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = ({
2+
variants = {},
3+
directions = {
4+
't': 'to top',
5+
'tr': 'to top right',
6+
'r': 'to right',
7+
'br': 'to bottom right',
8+
'b': 'to bottom',
9+
'bl': 'to bottom left',
10+
'l': 'to left',
11+
'tl': 'to top left',
12+
},
13+
gradients = {},
14+
} = {}) => ({ e, addUtilities }) => {
15+
addUtilities(
16+
{
17+
...(function() {
18+
const utilities = {};
19+
Object.entries(gradients).map(([gradientName, gradientColors]) => {
20+
if (!Array.isArray(gradientColors) || gradientColors.length === 1) {
21+
gradientColors = ['transparent', Array.isArray(gradientColors) ? gradientColors[0] : gradientColors];
22+
}
23+
Object.entries(directions).map(([directionName, directionValue]) => {
24+
utilities[`.${e(`border-gradient-${directionName}-${gradientName}`)}`] = {
25+
borderImage: `linear-gradient(${directionValue}, ${gradientColors.join(', ')}) 1`,
26+
};
27+
});
28+
});
29+
return utilities;
30+
})(),
31+
},
32+
variants,
33+
);
34+
};

0 commit comments

Comments
 (0)