vue3-tailwind-components 0.0.1 → 0.0.3

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