vueless 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,347 +0,0 @@
1
- # Customisation
2
-
3
- ## Overview
4
-
5
- To customize the look and feel of components change a default configuration in the `vueless.config.js`.
6
-
7
- ## Colors
8
-
9
- ### Predefined colors
10
-
11
- Components are based on a `brand` and a `gray` color. You can change them in your `vueless.config.js`.
12
-
13
- ```js
14
- // vueless.config.js
15
-
16
- export default {
17
- brand: "green",
18
- gray: "zinc",
19
- };
20
- ```
21
-
22
- As this module uses Tailwind CSS under the hood,
23
- you can use any of the [Tailwind CSS colors](https://tailwindcss.com/docs/customizing-colors#color-palette-reference) or your own custom colors.
24
-
25
- **By default:**
26
- * the `brand` color is `green`,
27
- * the `gray` color is `zinc`.
28
-
29
- ### Custom colors
30
-
31
- When [using custom colors](https://tailwindcss.com/docs/customizing-colors#using-custom-colors) or [adding additional colors](https://tailwindcss.com/docs/customizing-colors#adding-additional-colors) through the `extend` key in your `tailwind.config.js`,
32
- you'll need to make sure to define all the shades from `50` to `950` as most of them are used in the package components.
33
-
34
- You can [generate your colors](https://tailwindcss.com/docs/customizing-colors#generating-colors) using tools such as https://uicolors.app for example.
35
-
36
- ```js
37
- // tailwind.config.js
38
-
39
- export default {
40
- theme: {
41
- extend: {
42
- colors: {
43
- green: {
44
- 50: '#EFFDF5',
45
- 100: '#D9FBE8',
46
- 200: '#B3F5D1',
47
- 300: '#75EDAE',
48
- 400: '#00DC82',
49
- 500: '#00C16A',
50
- 600: '#00A155',
51
- 700: '#007F45',
52
- 800: '#016538',
53
- 900: '#0A5331',
54
- 950: '#052e16'
55
- }
56
- }
57
- }
58
- }
59
- }
60
- ```
61
-
62
- ### Opacity mode
63
-
64
- You can use `mode: "opacity"` to generate all the shades automatically by using `opacity` based on your brand color.
65
-
66
- ```js
67
- // vueless.config.js
68
-
69
- export default {
70
- brand: "orange",
71
- gray: "slate",
72
- mode: "opacity",
73
- };
74
- ```
75
-
76
- You can set your own brand color in `HEX` format as well.
77
-
78
- ```js
79
- // vueless.config.js
80
-
81
- export default {
82
- brand: "#00C16A",
83
- gray: "slate",
84
- mode: "opacity",
85
- };
86
- ```
87
-
88
- ### Brand CSS Variable
89
-
90
- To provide dynamic brand color that can be changed at runtime, this module uses CSS variable.
91
-
92
- > We'd advise you to use that color in your components and pages, e.g. `text-brand dark:text-brand`, etc.
93
- > so your app automatically adapts when changing your `vueless.config.js`.
94
-
95
- To change the brand color, you should call this function whatever you need:
96
-
97
- ```js
98
- import { setBrandColor } from "vueless/service.ui";
99
-
100
- // set default brand color
101
- setBrandColor();
102
-
103
- // or set brand color from tailwind colors palette
104
- setBrandColor("red");
105
-
106
- // or set your own custom brand color
107
- setBrandColor("#00C16A");
108
- ```
109
-
110
- The `brand` color also has a `DEFAULT` shade that changes based on the theme.
111
- It is `500` in light mode and `400` in dark mode.
112
- You can use it as a shortcut in your components and pages, e.g. `text-brand`, `bg-brand`, `focus-visible:ring-brand`, etc.
113
-
114
- > For custom hex color, there is only one shade for dark and light themes.
115
-
116
- ### Smart Safelisting
117
-
118
- Components having a `color` prop like `UAvatar`, `UButton`, `URadioGroup`, `UCheckbox`, `UHeader` etc.
119
- will use the `brand` or `grayscale` color by default,
120
- but will handle all the colors defined in your `tailwind.config.ts` or the default Tailwind CSS colors.
121
-
122
- Variant classes of those components are defined with a syntax like `bg-{color}-500 dark:bg-{color}-400` so they can be used with any color.
123
- However, this means that Tailwind will not find those classes and therefore will not generate the corresponding CSS.
124
-
125
- The library uses the [Tailwind CSS safelist](https://tailwindcss.com/docs/content-configuration#safelisting-classes) feature
126
- to force the generation of component colors.
127
-
128
- The Vueless will **automatically** detect when you use one of those components with a color and will safelist it for you.
129
- This means that if you use a `red` color for a UButton component, the `red` color classes will be safelisted for the UButton component only.
130
- This will allow to keep the CSS bundle size as small as possible.
131
-
132
- If you bind a dynamic color to a component: `<UBadge :color="color" />`, `<UButton :color="statuses[button.status]" />`, etc.
133
- You'll need to safelist the possible color values manually as well.
134
-
135
- ```js [vueless.config.js]
136
- // vueless.config.js
137
-
138
- export default {
139
- safelistColors: ["orange", "amber", "sky"], // applies for all components
140
- component: {
141
- UButton: {
142
- safelistColors: ["red"], // applies only for UButton
143
- }
144
- }
145
- }
146
- ```
147
-
148
- ### Replacing safelist patterns
149
-
150
- In some specific cases you can replace safelist config as well:
151
-
152
- ```js
153
- // vueless.config.js
154
-
155
- export default {
156
- component: {
157
- UButton: {
158
- safelist: (colors) => [
159
- { pattern: `bg-(${colors})-500`, variants: ["hover", "focus", "active"] },
160
- { pattern: `text-(${colors})-500` },
161
- ],
162
- }
163
- }
164
- };
165
- ```
166
-
167
- ## Components
168
-
169
- ### `vueless.config.js`
170
-
171
- Components are styled with Tailwind CSS but classes are all defined in the default `configs/default.config.js` file
172
- located in each component folder. You can override those in your own `vueless.config.js`.
173
-
174
- ```js
175
- // vueless.config.js
176
-
177
- export default {
178
- component: {
179
- UButton: {
180
- button: {
181
- base: "bg-red-500 w-full",
182
- }
183
- }
184
- }
185
- };
186
- ```
187
-
188
- Thanks to [tailwind-merge](https://github.com/dcastil/tailwind-merge), the `vueless.config.js` is smartly merged with the default config.
189
- This means you don't have to rewrite everything.
190
-
191
- You can change this behavior by changing `strategy` in your `vueless.config.js` to:
192
- * `override` – override default config by custom defined config (keeps only custom config and remove everything else).
193
- * `replace` – replace default config keys by custom defined config keys, (the rest classes takes from the default config).
194
- * `merge` – smartly merge custom defined classes with default config classes (default strategy).
195
-
196
- ```js
197
- // vueless.config.js
198
-
199
- export default {
200
- strategy: 'override',
201
- component: {
202
- UButton: {
203
- button: {
204
- base: "bg-red-500 w-full",
205
- }
206
- }
207
- }
208
- };
209
- ```
210
-
211
- ### `config` prop
212
-
213
- Each component has a `config` prop that allows you to customize everything specifically.
214
-
215
- ```jsx
216
- <template>
217
- <UButton :config="{ button: { base: 'max-w-2xl' } }">
218
- <slot />
219
- </UButton>
220
- </template>
221
- ```
222
-
223
- > You can find the default classes for each component under the `Config` section.
224
-
225
- Thanks to [tailwind-merge](https://github.com/dcastil/tailwind-merge), the `config` prop is smartly merged with the config.
226
- This means you don't have to rewrite everything.
227
-
228
- For example, the default preset of the `UEmpty` component looks like this:
229
-
230
- ```js
231
- {
232
- wrapper: "flex flex-col items-center w-full bg-center",
233
- header: "mb-4 flex justify-center",
234
- footer: "mt-4 flex justify-center",
235
- title: {
236
- base: "mb-2 font-medium text-center",
237
- variants: {
238
- size: {
239
- sm: "text-base",
240
- md: "text-lg",
241
- lg: "text-xl",
242
- },
243
- },
244
- },
245
- description: {
246
- base: "text-center",
247
- variants: {
248
- size: {
249
- sm: "text-sm",
250
- md: "text-base",
251
- lg: "text-lg",
252
- },
253
- },
254
- },
255
- defaultVariants: {
256
- size: "md",
257
- },
258
- }
259
- ```
260
-
261
- To change the font of the `title`, you only need to write:
262
-
263
- ```jsx
264
- <UEmpty
265
- title="The list is empty"
266
- :config="{ title: { base: 'font-bold' } }"
267
- />
268
- ```
269
-
270
- This will smartly replace the `font-medium` by `font-bold` and prevent any class duplication and any class priority issue.
271
-
272
- You can change this behavior by setting `strategy` to `replace` or `override` inside the `config` prop:
273
-
274
- ```jsx
275
- <UButton
276
- label="Submmit"
277
- :config="{
278
- strategy: 'replace',
279
- color: {
280
- white: {
281
- solid: 'bg-white dark:bg-gray-900'
282
- }
283
- }
284
- }"
285
- />
286
- ```
287
-
288
- ### `class` attribute
289
-
290
- You can also use the `class` attribute to add classes to the component.
291
-
292
- ```vue
293
- <template>
294
- <UButton label="Button" class="font-bold" />
295
- </template>
296
- ```
297
-
298
- Again, with [tailwind-merge](https://github.com/dcastil/tailwind-merge), this will smartly merge the classes with the `config` prop and the global and default configs.
299
-
300
- ### Default values
301
-
302
- Some component props like `size`, `color`, `variant`, etc. have a default value that you can override in your `vueless.config.js`
303
- or by the `config` prop as well.
304
-
305
- ```js
306
- // vueless.config.js
307
-
308
- export default {
309
- component: {
310
- UButton: {
311
- defaultVariants: {
312
- size: "lg",
313
- color: "red",
314
- variant: "secondary"
315
- }
316
- }
317
- }
318
- };
319
- ```
320
-
321
- ## Icons
322
-
323
- The library supports three popular icon libraries:
324
- * `@material-symbols/svg-{weight}`, where {weight} is number from 100 to 700 (`@material-symbols/svg-500` is default).
325
- * `bootstrap-icons`
326
- * `heroicons`
327
-
328
- > The package works only with SVG icons.
329
-
330
- ### Icons safelist colors
331
-
332
- If you set some icon names dynamically in `UIcon` component, then them may be skipped on a build stage.
333
- To avoid this behavior and include the icons in the build, you can add them into a safelist.
334
-
335
- ```js
336
- // vueless.config.js
337
-
338
- export default {
339
- component: {
340
- UIcon: {
341
- safelistIcons: ["1k", "2d", "close"],
342
- }
343
- }
344
- };
345
- ```
346
-
347
- > In this case, the regular and filled icon variants will be added into the build.
@@ -1,139 +0,0 @@
1
- # Installation
2
- Learn how to install and configure the package in your Vue app.
3
-
4
- ## Quick Start
5
-
6
- 1\. Install `vueless` to your project:
7
-
8
- ```bash
9
- # npm
10
- npm install vueless
11
-
12
- # yarn
13
- yarn add vueless
14
-
15
- # pnpm
16
- pnpm add vueless
17
- ```
18
-
19
- 2\. Create `vueless.config.js` at the root of your project.
20
-
21
- ```js
22
- export default {
23
- color: {},
24
- component: {},
25
- };
26
- ```
27
-
28
- 3\. Add vueless preset into `tailwind.config.js`.
29
-
30
- ```js
31
- import { vuelessPreset } from "vueless/service.tailwind";
32
-
33
- export default {
34
- presets: [vuelessPreset],
35
- ...
36
- };
37
- ```
38
-
39
- 4\. Add Vueless Vite plugins into `vite.config.js`.
40
-
41
- ```js
42
- import { Vueless, VuelessUnpluginComponents } from "vueless/plugin.vite";
43
-
44
- export default defineConfig({
45
- plugins: [
46
- ...
47
- Vueless(),
48
- VuelessUnpluginComponents(),
49
- ],
50
- ...
51
- })
52
- ```
53
-
54
- 5\. Configure your `package.json`.
55
-
56
- ```json
57
- {
58
- ...
59
- "web-types": "vueless/web-types.json"
60
- }
61
- ```
62
-
63
- Where:
64
- * `web-types` – add props and values autocompletion to your IDE.
65
-
66
- <br/>
67
-
68
- That's it! You can now use all the components in your Vue app ✨
69
-
70
- ## IntelliSense
71
- If you're using **VSCode** or **JetBrains** IDEs (WebStorm, PHPStorm, etc..) you can configure autocompletion for the classes.
72
-
73
- **What you'll get:**
74
- * Autocompletion on typing.
75
- * Autocompletion on objects by prefixing them with `/*tw*/`
76
- * Autocompletion when using the `config` prop.
77
-
78
- **An example SFC using IntelliSense:**
79
-
80
- ```jsx
81
- <template>
82
- <UCard :config="config" />
83
- </template>
84
-
85
- <script setup>
86
- const config = /*tw*/ {
87
- background: 'bg-white dark:bg-slate-900'
88
- }
89
- </script>
90
- ```
91
-
92
- ### VSCode
93
- * Install [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
94
- extension.
95
- * Set the plugin configuration below in the file `.vscode/settings.json`.
96
-
97
- ```json
98
- {
99
- "files.associations": {
100
- "*.css": "tailwindcss"
101
- },
102
- "editor.quickSuggestions": {
103
- "strings": true
104
- },
105
- "tailwindCSS.experimental.classRegex": [
106
- ["config:\\s*{([^)]*)\\s*}", "[\"'`]([^\"'`]*).*?[\"'`]"],
107
- ["/\\*tw\\*/\\s*{([^;]*)}", ":\\s*[\"'`]([^\"'`]*).*?[\"'`]"]
108
- ],
109
- "tailwindCSS.classAttributes": ["class", "className", "ngClass", "config"]
110
- }
111
- ```
112
-
113
-
114
- ### JetBrains IDEs
115
- * Check if [Tailwind CSS IntelliSense](https://www.jetbrains.com/help/webstorm/tailwind-css.html)
116
- already installed in the IDE, if not, install it in extensions.
117
- * Set the plugin configuration below in `Settings` > `Languages & Frameworks` > `Style Sheets` > `Tailwind CSS`.
118
-
119
- ```json
120
- {
121
- "includeLanguages": {
122
- "javascript": "javascript"
123
- },
124
- "suggestions": true,
125
- "classAttributes": ["class", "className", "ngClass", "config"],
126
- "experimental": {
127
- "classRegex": [
128
- ["config:\\s*{([^)]*)\\s*}", "[\"'`]([^\"'`]*).*?[\"'`]"],
129
- ["/\\*tw\\*/\\s*{([^;]*)}", ":\\s*[\"'`]([^\"'`]*).*?[\"'`]"]
130
- ]
131
- }
132
- }
133
- ```
134
-
135
-
136
-
137
-
138
-
139
-
@@ -1,6 +0,0 @@
1
- import { Markdown, Meta } from "@storybook/blocks";
2
-
3
- import customization from "../customization.md?raw"
4
-
5
- <Meta title="2. Customisation" />
6
- <Markdown className="markdown">{customization}</Markdown>
@@ -1,7 +0,0 @@
1
- import { Markdown, Meta } from "@storybook/blocks";
2
-
3
- import installation from "../installation.md?raw"
4
-
5
- <Meta title="1. Installation" />
6
- <Markdown className="markdown">{installation}</Markdown>
7
-
@@ -1,69 +0,0 @@
1
- const colors = require("tailwindcss/colors");
2
-
3
- export default {
4
- content: ["./index.html", "./vueless.config.{js,ts}", "./src/**/*.{js,ts,vue}"],
5
- theme: {
6
- fontFamily: {
7
- roboto: ["Roboto", "sans-serif"],
8
- },
9
- extend: {
10
- spacing: {
11
- 100: "25rem", // 400px
12
- 125: "31.25rem", // 500px
13
- 150: "37.5rem", // 600px
14
- 175: "43.75rem", // 700px
15
- 200: "50rem", // 800px
16
- 225: "56.25rem", // 900px
17
- 250: "62.5rem", // 1000px
18
- 275: "68.75rem", // 1100px
19
- 300: "75rem", // 1200px
20
- "safe-top": "env(safe-area-inset-top)",
21
- "safe-bottom": "env(safe-area-inset-bottom)",
22
- "safe-left": "env(safe-area-inset-left)",
23
- "safe-right": "env(safe-area-inset-right)",
24
- "mobile-menu-height": "3.5rem",
25
- },
26
- fontSize: {
27
- "2xs": ["0.625rem", "0.75rem"], // 10px
28
- xs: ["0.75rem", "0.875rem"], // 12px
29
- sm: ["0.875rem", "1rem"], // 14px
30
- base: ["1rem", "1.1875rem"], // 16px
31
- lg: ["1.125rem", "1.3125rem"], // 18px
32
- xl: ["1.375rem", "1.6rem"], // 22px
33
- "2xl": ["1.5rem", "1.75rem"], // 24px
34
- "3xl": ["1.75rem", "2.0625rem"], // 28px
35
- "4xl": ["2rem", "2.3125rem"], // 32px
36
- "5xl": ["3rem", "3.5rem"], // 48px
37
- },
38
- opacity: {
39
- 15: ".15",
40
- },
41
- },
42
- colors: {
43
- transparent: "transparent",
44
- current: "currentColor",
45
- brand: withOpacity("--brand-color"),
46
- gray: colors.gray,
47
- red: colors.red,
48
- yellow: colors.amber,
49
- green: colors.green,
50
- blue: colors.blue,
51
- violet: colors.violet,
52
- black: colors.black,
53
- white: colors.white,
54
- orange: colors.orange,
55
- fuchsia: colors.fuchsia,
56
- },
57
- },
58
- plugins: [require("@tailwindcss/forms")],
59
- };
60
-
61
- function withOpacity(variableName) {
62
- return ({ opacityValue }) => {
63
- if (opacityValue !== undefined) {
64
- return `rgba(var(${variableName}), ${opacityValue})`;
65
- }
66
-
67
- return `rgb(var(${variableName}))`;
68
- };
69
- }
package/vite.config.mjs DELETED
@@ -1,40 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import path from "path";
3
-
4
- import Vue from "@vitejs/plugin-vue";
5
- import Eslint from "vite-plugin-eslint";
6
- import { Vueless, VuelessUnpluginComponents } from "@vueless/vite-plugin";
7
-
8
- export default defineConfig({
9
- plugins: [
10
- Vue(),
11
- Eslint(),
12
- Vueless(),
13
- VuelessUnpluginComponents(),
14
- ],
15
- resolve: {
16
- extensions: [".vue", ".mjs", ".js", ".ts", ".mdx"],
17
- alias: {
18
- "vueless/src": path.resolve(__dirname, "./src"),
19
- },
20
- },
21
- optimizeDeps: {
22
- include: [
23
- "vuex",
24
- "vue-i18n",
25
- "vue-router",
26
- "vue-tippy",
27
- "@uppy/core",
28
- "@uppy/vue/src/drag-drop",
29
- //"@kyvg/vue3-notification",
30
- //"@tailwindcss/forms",
31
- "tailwindcss/colors.js",
32
- "cva",
33
- "tailwind-merge",
34
- "prettier2",
35
- "prettier2/parser-html",
36
- "@storybook/blocks",
37
- "@storybook/theming/create",
38
- ],
39
- },
40
- });
package/vueless.config.js DELETED
@@ -1,7 +0,0 @@
1
- export default {
2
- brand: "grayscale",
3
- gray: "gray",
4
- component: /*tw*/ {
5
- // component configs
6
- },
7
- };