vueless 0.0.167 → 0.0.169

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -21,7 +21,7 @@
21
21
  "sb:dev": "npx @vueless/web-types && node prepare.icons && storybook dev -p 6006 --docs --no-open",
22
22
  "sb:build": "npx @vueless/web-types && node prepare.icons && storybook build --docs",
23
23
  "sb:preview": "vite preview --host --outDir=storybook-static",
24
- "package:prepare": "npx @vueless/web-types && node prepare.icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE web-types.json README.md dist/"
24
+ "package:prepare": "npx @vueless/web-types && node prepare.icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE web-types.json README.md dist/ && node prepare.package"
25
25
  },
26
26
  "dependencies": {
27
27
  "@tailwindcss/forms": "^0.5.7",
@@ -39,7 +39,7 @@
39
39
  "@vue/eslint-config-prettier": "^9.0.0",
40
40
  "@vueless/plugin-vite": "^0.0.30",
41
41
  "@vueless/storybook": "^0.0.31",
42
- "@vueless/web-types": "^0.0.11",
42
+ "@vueless/web-types": "^0.0.12",
43
43
  "autoprefixer": "^10.4.19",
44
44
  "cssnano": "^6.1.2",
45
45
  "eslint": "^8.55.0",
@@ -28,6 +28,7 @@ export function useAttrs(props) {
28
28
  cvaWrapper({
29
29
  color: getColor(props.color),
30
30
  bordered: props.bordered,
31
+ variant: props.variant,
31
32
  }),
32
33
  props.color,
33
34
  ),
@@ -37,6 +38,9 @@ export function useAttrs(props) {
37
38
 
38
39
  const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
39
40
  const bodyAttrs = getAttrs("body", { classes: bodyClasses });
41
+ const titleAttrs = getAttrs("title");
42
+ const descriptionAttrs = getAttrs("description");
43
+
40
44
  const buttonAttrs = getAttrs("button", { isComponent: true });
41
45
  const iconAttrs = getAttrs("icon", { isComponent: true });
42
46
 
@@ -47,5 +51,7 @@ export function useAttrs(props) {
47
51
  buttonAttrs,
48
52
  iconAttrs,
49
53
  hasSlotContent,
54
+ titleAttrs,
55
+ descriptionAttrs,
50
56
  };
51
57
  }
@@ -1,19 +1,21 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: {
3
- base: "p-4 space-x-4 flex justify-between items-start rounded-lg bg-{color}-50 text-{color}-700",
3
+ base: "p-4 flex flex-col rounded-lg",
4
4
  variants: {
5
- color: {
6
- grayscale: "bg-gray-100 text-gray-900",
7
- },
8
- bordered: {
9
- true: "border border-{color}-100",
5
+ variant: {
6
+ primary: `bg-{color}-500 text-white`,
7
+ secondary: `bg-transparent border border-{color}-500`,
8
+ thirdary: `bg-{color}-50 text-{color}-700`,
10
9
  },
11
10
  },
12
- compoundVariants: [{ color: "grayscale", bordered: true, class: "border-gray-200" }],
11
+ compoundVariants: [
12
+ { color: "grayscale", bordered: true, class: "border-gray-200" },
13
+ { variant: "thirdary", bordered: true, class: "border border-{color}-100" },
14
+ ],
13
15
  },
14
16
  body: {
15
17
  base: `
16
- space-y-4 font-normal leading-normal
18
+ flex gap-2 items-baseline font-normal
17
19
  [&_b]:font-bold [&_i]:italic [&_p]:font-normal
18
20
  [&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4
19
21
  [&_a:not([class]):hover]:no-underline [&_a:not([class])]:font-bold
@@ -32,20 +34,25 @@ export default /*tw*/ {
32
34
  },
33
35
  },
34
36
  },
37
+ title: "font-bold text-lg leading-tight",
38
+ description: "text-sm",
35
39
  button: "",
36
40
  icon: "",
37
41
  iconName: "close",
38
42
  defaultVariants: {
39
- color: "grayscale",
43
+ variant: "thirdary",
44
+ color: "brand",
40
45
  size: "md",
41
46
  timeout: 0,
42
47
  html: undefined,
43
48
  bordered: false,
44
- closeIcon: false,
49
+ closable: false,
45
50
  },
46
51
  safelist: (colors) => [
47
52
  { pattern: `bg-(${colors})-50` },
53
+ { pattern: `bg-(${colors})-500` },
48
54
  { pattern: `text-(${colors})-700` },
49
55
  { pattern: `border-(${colors})-100` },
56
+ { pattern: `border-(${colors})-500` },
50
57
  ],
51
58
  };
@@ -2,6 +2,8 @@ import { getArgTypes, getSlotNames } from "../service.storybook";
2
2
 
3
3
  import UAlert from "../ui.text-alert";
4
4
  import URow from "../ui.container-row";
5
+ import UGroup from "../ui.container-group";
6
+ import UIcon from "../ui.image-icon";
5
7
 
6
8
  /**
7
9
  * The `UAlert` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.text-alert)
@@ -12,7 +14,7 @@ export default {
12
14
  component: UAlert,
13
15
  args: {
14
16
  text: "UHint",
15
- slotTemplate: `
17
+ slotDefaultTemplate: `
16
18
  <template #default>
17
19
  <p>
18
20
  <b>Lorem ipsum dolor sit amet,</b>
@@ -30,19 +32,42 @@ export default {
30
32
  };
31
33
 
32
34
  const DefaultTemplate = (args) => ({
33
- components: { UAlert },
35
+ components: { UAlert, UIcon },
34
36
  setup() {
35
37
  const slots = getSlotNames(UAlert.name);
36
38
 
37
39
  return { args, slots };
38
40
  },
39
41
  template: `
40
- <UAlert v-bind="args">
41
- ${args.slotTemplate || ""}
42
+ <UAlert v-bind="args" v-model="args.value">
43
+ ${args.slotDefaultTemplate}
44
+ ${args.slotTemplate || ""}
42
45
  </UAlert>
43
46
  `,
44
47
  });
45
48
 
49
+ const VariantsTemplate = (args, { argTypes } = {}) => ({
50
+ components: { UAlert, UGroup },
51
+ setup() {
52
+ return {
53
+ args,
54
+ variants: argTypes.variant.options,
55
+ };
56
+ },
57
+ template: `
58
+ <UGroup>
59
+ <UAlert
60
+ v-for="(variant, index) in variants"
61
+ v-bind="args"
62
+ :variant="variant"
63
+ :key="index"
64
+ :title="variant"
65
+ color="gray"
66
+ />
67
+ </UGroup>
68
+ `,
69
+ });
70
+
46
71
  const ColorsTemplate = (args, { argTypes } = {}) => ({
47
72
  components: { UAlert, URow },
48
73
  setup() {
@@ -57,10 +82,9 @@ const ColorsTemplate = (args, { argTypes } = {}) => ({
57
82
  v-for="(color, index) in colors"
58
83
  v-bind="args"
59
84
  :color="color"
85
+ :title="color"
60
86
  :key="index"
61
- >
62
- ${args.slotTemplate}
63
- </UAlert>
87
+ />
64
88
  </URow>
65
89
  `,
66
90
  });
@@ -81,48 +105,60 @@ const SizeTemplate = (args, { argTypes } = {}) => ({
81
105
  :size="size"
82
106
  :key="index"
83
107
  >
84
- ${args.slotTemplate}
108
+ text
85
109
  </UAlert>
86
110
  </URow>
87
111
  `,
88
112
  });
89
113
 
114
+ const HTMLTemplate = (args) => ({
115
+ components: { UAlert },
116
+ setup() {
117
+ return { args };
118
+ },
119
+ template: `
120
+ <UAlert :html="args.html" />
121
+ `,
122
+ });
123
+
90
124
  export const Default = DefaultTemplate.bind({});
91
125
  Default.args = {};
92
126
 
127
+ export const variants = VariantsTemplate.bind({});
128
+ variants.args = {};
129
+
93
130
  export const colors = ColorsTemplate.bind({});
94
- colors.args = {
95
- closeIcon: true,
96
- slotTemplate: `
97
- <template #default>
98
- text
99
- </template>
100
- `,
101
- };
131
+ colors.args = {};
102
132
 
103
- export const size = SizeTemplate.bind({});
104
- size.args = {
105
- closeIcon: true,
106
- slotTemplate: `
107
- <template #default>
108
- text
109
- </template>
133
+ export const sizes = SizeTemplate.bind({});
134
+ sizes.args = {};
135
+
136
+ export const HTML = HTMLTemplate.bind({});
137
+ HTML.args = {
138
+ html: `
139
+ <p>
140
+ <b>Lorem ipsum dolor sit amet,</b>
141
+ <u>consectetur adipiscing elit,</u>
142
+ <em>sed do eiusmod tempor incididunt
143
+ ut labore et dolore magna aliqua.</em>
144
+ <a href="https://uk.wikipedia.org/wiki/Lorem_ipsum" target="_blank">Wikipedia</a>
145
+ </p>
110
146
  `,
111
147
  };
112
148
 
113
- export const closeIcon = DefaultTemplate.bind({});
114
- closeIcon.args = {
115
- closeIcon: true,
116
- slotTemplate: `
117
- <template #default>
118
- some text
119
- </template>
149
+ export const closable = DefaultTemplate.bind({});
150
+ closable.args = {
151
+ closable: true,
152
+ slotDefaultTemplate: `
153
+ <template #default>
154
+ some text
155
+ </template>
120
156
  `,
121
157
  };
122
158
 
123
159
  export const paragraphs = DefaultTemplate.bind({});
124
160
  paragraphs.args = {
125
- slotTemplate: `
161
+ slotDefaultTemplate: `
126
162
  <template #default>
127
163
  <p>
128
164
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@@ -141,8 +177,7 @@ paragraphs.args = {
141
177
 
142
178
  export const list = DefaultTemplate.bind({});
143
179
  list.args = {
144
- slotTemplate: `
145
- <template #default>
180
+ slotDefaultTemplate: `
146
181
  <URow>
147
182
  <ul>
148
183
  <li> Lorem ipsum dolor </li>
@@ -156,6 +191,65 @@ list.args = {
156
191
  <li> Lorem ipsum dolor </li>
157
192
  </ol>
158
193
  </URow>
159
- </template>
160
194
  `,
161
195
  };
196
+
197
+ export const slotTitleAndDescription = DefaultTemplate.bind({});
198
+ slotTitleAndDescription.args = {
199
+ slotTemplate: `
200
+ <template #title>
201
+ <div>Alert Title</div>
202
+ </template>
203
+ <template #description>
204
+ <div>This is a custom description for the alert.</div>
205
+ </template>
206
+ `,
207
+ };
208
+
209
+ export const slotAlertLeft = DefaultTemplate.bind({});
210
+ slotAlertLeft.args = {
211
+ slotTemplate: `
212
+ <template #left>
213
+ <UIcon
214
+ name="star"
215
+ color="gray"
216
+ />
217
+ </template>
218
+ `,
219
+ };
220
+
221
+ export const slotAlertRight = DefaultTemplate.bind({});
222
+ slotAlertRight.args = {
223
+ slotTemplate: `
224
+ <template #right>
225
+ <UIcon
226
+ name="star"
227
+ color="gray"
228
+ />
229
+ </template>
230
+ `,
231
+ };
232
+
233
+ export const slotAlertTop = DefaultTemplate.bind({});
234
+ slotAlertTop.args = {
235
+ slotTemplate: `
236
+ <template #top>
237
+ <UIcon
238
+ name="star"
239
+ color="gray"
240
+ />
241
+ </template>
242
+ `,
243
+ };
244
+
245
+ export const slotAlertBottom = DefaultTemplate.bind({});
246
+ slotAlertBottom.args = {
247
+ slotTemplate: `
248
+ <template #bottom>
249
+ <UIcon
250
+ name="star"
251
+ color="gray"
252
+ />
253
+ </template>
254
+ `,
255
+ };
@@ -1,30 +1,51 @@
1
1
  <template>
2
2
  <div v-if="isShownAlert" :data-cy="dataCy" v-bind="wrapperAttrs">
3
+ <!-- @slot Use it to add something above text. -->
4
+ <slot name="top" />
5
+
6
+ <!-- Use it to add something instead of the title. -->
7
+ <slot name="title" :title="title">
8
+ <div v-bind="titleAttrs" v-text="title" />
9
+ </slot>
10
+
11
+ <!-- @slot Use it to add something instead of the description. -->
12
+ <slot name="description" :description="description">
13
+ <div v-bind="descriptionAttrs" v-text="description" />
14
+ </slot>
15
+
3
16
  <div v-bind="bodyAttrs">
4
- <!-- @slot Use it to add something inside. -->
17
+ <!-- @slot Use it to add something before text. -->
18
+ <slot name="left" />
19
+
20
+ <!-- @slot Default slot. -->
5
21
  <slot />
22
+ <div v-if="!hasSlotContent($slots.default)" v-bind="bodyAttrs" v-html="html" />
6
23
 
7
- <div v-if="!hasSlotContent($slots['default'])" v-html="html" />
24
+ <UButton
25
+ v-if="closable"
26
+ size="sm"
27
+ variant="thirdary"
28
+ :color="color"
29
+ square
30
+ v-bind="buttonAttrs"
31
+ @click="onClickClose"
32
+ >
33
+ <UIcon
34
+ internal
35
+ size="xs"
36
+ :color="color"
37
+ :name="config.iconName"
38
+ :data-cy="`${dataCy}-button`"
39
+ v-bind="iconAttrs"
40
+ />
41
+ </UButton>
42
+
43
+ <!-- @slot Use it to add something after text. -->
44
+ <slot name="right" />
8
45
  </div>
9
46
 
10
- <UButton
11
- v-if="closeIcon"
12
- size="sm"
13
- variant="thirdary"
14
- :color="color"
15
- square
16
- v-bind="buttonAttrs"
17
- >
18
- <UIcon
19
- internal
20
- size="xs"
21
- :color="color"
22
- :name="config.iconName"
23
- :data-cy="`${dataCy}-button`"
24
- v-bind="iconAttrs"
25
- @click="onHidden"
26
- />
27
- </UButton>
47
+ <!-- @slot Use it to add something under text. -->
48
+ <slot name="bottom" />
28
49
  </div>
29
50
  </template>
30
51
 
@@ -43,6 +64,15 @@ import { useAttrs } from "./composables/attrs.composable";
43
64
  defineOptions({ name: "UAlert" });
44
65
 
45
66
  const props = defineProps({
67
+ /**
68
+ * Alert variant.
69
+ * @values primary, secondary, thirdary
70
+ */
71
+ variant: {
72
+ type: String,
73
+ default: UIService.get(defaultConfig, UAlert).default.variant,
74
+ },
75
+
46
76
  /**
47
77
  * HTML or plain text.
48
78
  */
@@ -87,9 +117,9 @@ const props = defineProps({
87
117
  /**
88
118
  * Show close button.
89
119
  */
90
- closeIcon: {
120
+ closable: {
91
121
  type: Boolean,
92
- default: UIService.get(defaultConfig, UAlert).default.closeIcon,
122
+ default: UIService.get(defaultConfig, UAlert).default.closable,
93
123
  },
94
124
 
95
125
  /**
@@ -107,21 +137,46 @@ const props = defineProps({
107
137
  type: String,
108
138
  default: "",
109
139
  },
140
+
141
+ /**
142
+ * Alert title.
143
+ */
144
+ title: {
145
+ type: String,
146
+ default: "",
147
+ },
148
+
149
+ /**
150
+ * Alert description.
151
+ */
152
+ description: {
153
+ type: String,
154
+ default: "",
155
+ },
110
156
  });
111
157
 
112
158
  const emit = defineEmits(["hidden"]);
113
159
 
114
160
  const isShownAlert = ref(true);
115
161
 
116
- const { config, wrapperAttrs, bodyAttrs, iconAttrs, buttonAttrs, hasSlotContent } = useAttrs(props);
162
+ const {
163
+ config,
164
+ wrapperAttrs,
165
+ bodyAttrs,
166
+ titleAttrs,
167
+ descriptionAttrs,
168
+ iconAttrs,
169
+ buttonAttrs,
170
+ hasSlotContent,
171
+ } = useAttrs(props);
117
172
 
118
173
  onMounted(() => {
119
174
  if (props.timeout > 0) {
120
- setTimeout(() => onHidden(), props.timeout);
175
+ setTimeout(() => onClickClose(), props.timeout);
121
176
  }
122
177
  });
123
178
 
124
- function onHidden() {
179
+ function onClickClose() {
125
180
  isShownAlert.value = false;
126
181
  emit("hidden");
127
182
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.167",
4
+ "version": "0.0.169",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -254,6 +254,15 @@
254
254
  "name": "UAlert",
255
255
  "description": "",
256
256
  "attributes": [
257
+ {
258
+ "name": "variant",
259
+ "description": "Alert variant.",
260
+ "value": {
261
+ "kind": "expression",
262
+ "type": "'primary' | 'secondary' | 'thirdary'"
263
+ },
264
+ "default": "thirdary"
265
+ },
257
266
  {
258
267
  "name": "html",
259
268
  "description": "HTML or plain text.",
@@ -278,7 +287,7 @@
278
287
  "kind": "expression",
279
288
  "type": "'brand' | 'grayscale' | 'gray' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'white'"
280
289
  },
281
- "default": "grayscale"
290
+ "default": "brand"
282
291
  },
283
292
  {
284
293
  "name": "bordered",
@@ -299,7 +308,7 @@
299
308
  "default": "0"
300
309
  },
301
310
  {
302
- "name": "closeIcon",
311
+ "name": "closable",
303
312
  "description": "Show close button.",
304
313
  "value": {
305
314
  "kind": "expression",
@@ -324,6 +333,24 @@
324
333
  "type": "string"
325
334
  },
326
335
  "default": "\"\""
336
+ },
337
+ {
338
+ "name": "title",
339
+ "description": "Alert title.",
340
+ "value": {
341
+ "kind": "expression",
342
+ "type": "string"
343
+ },
344
+ "default": "\"\""
345
+ },
346
+ {
347
+ "name": "description",
348
+ "description": "Alert description.",
349
+ "value": {
350
+ "kind": "expression",
351
+ "type": "string"
352
+ },
353
+ "default": "\"\""
327
354
  }
328
355
  ],
329
356
  "events": [
@@ -332,9 +359,32 @@
332
359
  }
333
360
  ],
334
361
  "slots": [
362
+ {
363
+ "name": "top",
364
+ "description": "Use it to add something above text."
365
+ },
366
+ {
367
+ "name": "title"
368
+ },
369
+ {
370
+ "name": "description",
371
+ "description": "Use it to add something instead of the description."
372
+ },
373
+ {
374
+ "name": "left",
375
+ "description": "Use it to add something before text."
376
+ },
335
377
  {
336
378
  "name": "default",
337
- "description": "Use it to add something inside."
379
+ "description": "Default slot."
380
+ },
381
+ {
382
+ "name": "right",
383
+ "description": "Use it to add something after text."
384
+ },
385
+ {
386
+ "name": "bottom",
387
+ "description": "Use it to add something under text."
338
388
  }
339
389
  ],
340
390
  "source": {