vue3-tailwind-components 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +73 -15
- package/dist/vue3-tailwind-components.es.js +11689 -103
- package/dist/vue3-tailwind-components.umd.js +758 -1
- package/package.json +10 -2
package/README.md
CHANGED
@@ -4,22 +4,70 @@ This is a simple set of Vue 3, Tailwind based components. At the moment these co
|
|
4
4
|
* [Table](./src/components/table/README.md)
|
5
5
|
* [Paginator](./src/components/paginator/README.md)
|
6
6
|
* [Switch](./src/components/switch/README.md)
|
7
|
+
* [Icons](./src/components/icons/README.md)
|
8
|
+
* [Modal](./src/components/modal/README.md)
|
7
9
|
|
10
|
+
## Installation
|
8
11
|
|
9
12
|
|
10
|
-
I will be extending them as I need more Vue 3 Tailwind components. To use them you can
|
11
|
-
|
12
13
|
```shell
|
13
|
-
npm
|
14
|
+
npm i vue3-tailwind-components --save
|
15
|
+
```
|
16
|
+
|
17
|
+
Edit `tailwind.config.js` to look like this.
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
/** @type {import('tailwindcss').Config} */
|
21
|
+
const colors = require('tailwindcss/colors')
|
22
|
+
module.exports = {
|
23
|
+
content: [
|
24
|
+
"./index.html",
|
25
|
+
"./src/**/*.{js,ts,jsx,vue}",
|
26
|
+
],
|
27
|
+
safelist: [
|
28
|
+
{
|
29
|
+
pattern: /bg-(primary|secondary|warning|success|danger|info)-(\d00)/,
|
30
|
+
variants: ['hover', 'focus'],
|
31
|
+
},
|
32
|
+
{
|
33
|
+
pattern: /border-(primary|secondary|warning|success|danger|info)-(\d00)/,
|
34
|
+
},
|
35
|
+
{
|
36
|
+
pattern: /text-(primary|secondary|warning|success|danger|info)-(\d00)/,
|
37
|
+
},
|
38
|
+
],
|
39
|
+
theme: {
|
40
|
+
extend: {
|
41
|
+
colors:{
|
42
|
+
primary:colors.slate,
|
43
|
+
secondary:colors.lime,
|
44
|
+
warning:colors.amber,
|
45
|
+
success:colors.green,
|
46
|
+
danger:colors.red,
|
47
|
+
info:colors.indigo
|
48
|
+
}
|
49
|
+
},
|
50
|
+
},
|
51
|
+
plugins: [require("tailwindcss-animate")],
|
52
|
+
}
|
53
|
+
|
54
|
+
|
14
55
|
```
|
56
|
+
|
15
57
|
You can then just import the ones you want to use.
|
16
58
|
|
59
|
+
```vue
|
60
|
+
|
61
|
+
```
|
62
|
+
|
17
63
|
### Colors
|
18
64
|
I expect that if you use this library you will already understand how to use Tailwind generally. It comes with a generous
|
19
65
|
color pallet of gradated colors. In the background Tailwind strips out the classes it does not see directly in your code to keep your css small
|
20
66
|
but this creates a problem for us. It cannot see computed (concatenated strings). In order to use our components you will need to edit your.
|
21
67
|
`tailwind.config.js` file in the root of your project.
|
22
68
|
|
69
|
+
If you want to use every color that Tailwind supply in their default theme you could use this safe list:
|
70
|
+
|
23
71
|
```javascript
|
24
72
|
...
|
25
73
|
safelist: [
|
@@ -36,27 +84,37 @@ safelist: [
|
|
36
84
|
],
|
37
85
|
...
|
38
86
|
```
|
39
|
-
This tells Tailwind - Do not remove these classes from the CSS
|
40
87
|
|
41
|
-
|
88
|
+
This tells Tailwind - Do not remove any color classes for background, border or text (that is over 2000!) from the CSS.
|
89
|
+
|
90
|
+
A more optimal solution is to use color aliases. Those who have used Bootstrap css will be familiar with color aliasing.
|
91
|
+
The advantage of this approach is that we can control the look of all components from one place.
|
92
|
+
|
42
93
|
|
43
|
-
```javascript
|
44
|
-
{
|
45
|
-
pattern: /border-(slate|amber|primary)-(200|500|700)/
|
46
|
-
}
|
47
|
-
```
|
48
94
|
Another suggestion would be to create color aliases in `tailwind.config.js` like this:
|
49
95
|
|
50
96
|
```javascript
|
97
|
+
...
|
51
98
|
theme: {
|
52
99
|
extend: {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
100
|
+
colors:{
|
101
|
+
primary:colors.slate,
|
102
|
+
secondary:colors.lime,
|
103
|
+
warning:colors.amber,
|
104
|
+
success:colors.green,
|
105
|
+
danger:colors.red,
|
106
|
+
info:colors.indigo
|
107
|
+
}
|
57
108
|
},
|
58
|
-
|
109
|
+
}
|
110
|
+
...
|
111
|
+
```
|
112
|
+
You can be more specific and therefore reduce the size of the resultant css by doing something like this
|
59
113
|
|
114
|
+
```javascript
|
115
|
+
{
|
116
|
+
pattern: /border-(primary|seconday|warning|success|danger|info)-(50|100|200|300|500|700)/
|
117
|
+
}
|
60
118
|
```
|
61
119
|
|
62
120
|
You can then do something like this:
|