vueless 0.0.141 → 0.0.143

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.141",
3
+ "version": "0.0.143",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -28,7 +28,7 @@ export function useAttrs(props) {
28
28
  variant: props.variant,
29
29
  pill: props.pill,
30
30
  block: props.block,
31
- square: props.square,
31
+ square: props.loading || props.square,
32
32
  filled: props.filled,
33
33
  loading: props.loading,
34
34
  disabled: props.disabled,
@@ -37,12 +37,22 @@ export function useAttrs(props) {
37
37
  ),
38
38
  );
39
39
 
40
- const textClasses = computed(() => setColor(cvaText({ color: props.color }), props.color));
40
+ const textClasses = computed(() =>
41
+ setColor(
42
+ cvaText({
43
+ color: props.color,
44
+ }),
45
+ props.color,
46
+ ),
47
+ );
48
+
41
49
  const buttonAttrs = getAttrs("button", { classes: buttonClasses });
50
+ const loaderAttrs = getAttrs("loader");
42
51
  const textAttrs = getAttrs("text", { classes: textClasses });
43
52
 
44
53
  return {
45
- textAttrs,
46
54
  buttonAttrs,
55
+ loaderAttrs,
56
+ textAttrs,
47
57
  };
48
58
  }
@@ -44,7 +44,7 @@ export default /*tw*/ {
44
44
  `,
45
45
  },
46
46
  loading: {
47
- true: "pointer-events-none",
47
+ true: "pointer-events-none gap-0",
48
48
  },
49
49
  pill: {
50
50
  true: "rounded-full",
@@ -8,22 +8,28 @@
8
8
  v-bind="buttonAttrs"
9
9
  @click="onClick"
10
10
  >
11
- <!-- @slot Use it to add something before text. -->
12
- <slot v-if="!loading" name="left" />
13
-
14
- <!-- @slot Use it to add something instead of text. -->
15
- <slot v-if="!loading" />
16
-
17
- <div v-if="label" v-bind="textAttrs" tabindex="-1" v-text="label" />
18
- <ULoader v-if="loading" :size="size" color="white" />
19
-
20
- <!-- @slot Use it to add something after text. -->
21
- <slot v-if="!loading" name="right" />
11
+ <template v-if="loading">
12
+ <!-- Label is needed to prevent changing button height -->
13
+ <div v-bind="textAttrs" tabindex="-1" class="invisible w-0" v-text="label" />
14
+ <ULoader :size="loaderSize" :color="loaderColor" v-bind="loaderAttrs" />
15
+ </template>
16
+
17
+ <template v-else>
18
+ <!-- @slot Use it to add something before text. -->
19
+ <slot name="left" />
20
+
21
+ <!-- @slot Use it to add something instead of text. -->
22
+ <slot />
23
+ <div v-if="label" v-bind="textAttrs" tabindex="-1" v-text="label" />
24
+
25
+ <!-- @slot Use it to add something after text. -->
26
+ <slot name="right" />
27
+ </template>
22
28
  </component>
23
29
  </template>
24
30
 
25
31
  <script setup>
26
- import { ref } from "vue";
32
+ import { computed, ref } from "vue";
27
33
 
28
34
  import UIService, { getRandomId } from "../service.ui";
29
35
  import ULoader from "../ui.loader";
@@ -155,12 +161,29 @@ const props = defineProps({
155
161
 
156
162
  const emit = defineEmits(["click"]);
157
163
 
158
- const { textAttrs, buttonAttrs } = useAttrs(props);
164
+ const { buttonAttrs, loaderAttrs, textAttrs } = useAttrs(props);
159
165
 
160
166
  const buttonRef = ref(null);
161
167
 
162
168
  defineExpose({ buttonRef });
163
169
 
170
+ const loaderSize = computed(() => {
171
+ const sizes = {
172
+ "2xs": "sm",
173
+ xs: "sm",
174
+ sm: "md",
175
+ md: "md",
176
+ lg: "lg",
177
+ xl: "lg",
178
+ };
179
+
180
+ return sizes[props.size];
181
+ });
182
+
183
+ const loaderColor = computed(() => {
184
+ return props.variant === "primary" ? "white" : props.color;
185
+ });
186
+
164
187
  function onClick(event) {
165
188
  if (props.disabled) return;
166
189
 
@@ -36,7 +36,7 @@ export default /*tw*/ {
36
36
  },
37
37
  defaultVariants: {
38
38
  gap: "md",
39
- align: "start",
39
+ align: "stretch",
40
40
  upperlined: true,
41
41
  underlined: false,
42
42
  },
@@ -1,16 +1,16 @@
1
1
  export default /*tw*/ {
2
2
  loader: {
3
- base: "relative mx-1 flex h-4 items-center",
3
+ base: "relative flex items-center",
4
4
  variants: {
5
5
  size: {
6
- sm: "w-9",
7
- md: "w-[3.625rem]",
8
- lg: "w-20",
6
+ sm: "h-1.5 w-9",
7
+ md: "h-2.5 w-[3.625rem]",
8
+ lg: "h-4 w-20",
9
9
  },
10
10
  },
11
11
  },
12
12
  ellipse: {
13
- base: `absolute rounded-full bg-{color}-500 ease-[cubic-bezier(0,1,1,0)]`,
13
+ base: "absolute rounded-full bg-{color}-600 ease-[cubic-bezier(0,1,1,0)]",
14
14
  variants: {
15
15
  color: {
16
16
  white: "bg-white",
@@ -18,30 +18,32 @@ export default /*tw*/ {
18
18
  },
19
19
  size: {
20
20
  sm: `
21
- h-1.5 w-1.5
22
- [&:nth-child(1)]:left-1
23
- [&:nth-child(4)]:left-7
24
- `,
21
+ h-1.5 w-1.5
22
+ [&:nth-child(1)]:left-1
23
+ [&:nth-child(2)]:left-1
24
+ [&:nth-child(3)]:left-4
25
+ [&:nth-child(4)]:left-7
26
+ `,
25
27
  md: `
26
- h-2.5 w-2.5
27
- [&:nth-child(1)]:left-1.5
28
- [&:nth-child(2)]:left-1.5
29
- [&:nth-child(3)]:left-6
30
- [&:nth-child(4)]:left-[2.625rem]
31
- `,
28
+ h-2.5 w-2.5
29
+ [&:nth-child(1)]:left-1.5
30
+ [&:nth-child(2)]:left-1.5
31
+ [&:nth-child(3)]:left-6
32
+ [&:nth-child(4)]:left-[2.625rem]
33
+ `,
32
34
  lg: `
33
- h-4 w-4
34
- [&:nth-child(1)]:left-2
35
- [&:nth-child(2)]:left-2
36
- [&:nth-child(3)]:left-8
37
- [&:nth-child(4)]:left-14
38
- `,
35
+ h-4 w-4
36
+ [&:nth-child(1)]:left-2
37
+ [&:nth-child(2)]:left-2
38
+ [&:nth-child(3)]:left-8
39
+ [&:nth-child(4)]:left-14
40
+ `,
39
41
  },
40
42
  },
41
43
  },
42
44
  defaultVariants: {
43
- size: "md",
44
45
  color: "brand",
46
+ size: "md",
45
47
  },
46
- safelist: (colors) => [{ pattern: `bg-(${colors})-500` }],
48
+ safelist: (colors) => [{ pattern: `bg-(${colors})-600` }],
47
49
  };
@@ -34,14 +34,14 @@ const ColorsTemplate = (args, { argTypes } = {}) => ({
34
34
  };
35
35
  },
36
36
  template: `
37
- <div class="flex gap-4 flex-wrap">
37
+ <URow class="flex-wrap">
38
38
  <ULoader
39
39
  v-for="(color, index) in colors"
40
40
  :color="color"
41
41
  v-bind="args"
42
42
  :key="index"
43
43
  />
44
- </div>
44
+ </URow>
45
45
  `,
46
46
  });
47
47
 
@@ -57,25 +57,19 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
57
57
  <URow>
58
58
  <ULoader
59
59
  v-for="(size, index) in sizes"
60
- :size="size"
61
- :label="getText(size)"
62
- v-bind="args"
63
60
  :key="index"
61
+ v-bind="args"
62
+ :size="size"
64
63
  />
65
64
  </URow>
66
65
  `,
67
- methods: {
68
- getText(value) {
69
- return `Tag ${value}`;
70
- },
71
- },
72
66
  });
73
67
 
74
68
  export const Default = DefaultTemplate.bind({});
75
69
  Default.args = {};
76
70
 
77
- export const Colors = ColorsTemplate.bind({});
78
- Colors.args = {};
71
+ export const sizes = SizesTemplate.bind({});
72
+ sizes.args = {};
79
73
 
80
- export const Sizes = SizesTemplate.bind({});
81
- Sizes.args = {};
74
+ export const colors = ColorsTemplate.bind({});
75
+ colors.args = {};
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <div v-bind="loaderAttrs">
3
- <div v-for="ellipse in ellipsesAmount" :key="ellipse" v-bind="ellipseAttrs(ellipseClasses)" />
3
+ <div v-for="ellipse in ELLIPSES_AMOUNT" :key="ellipse" v-bind="ellipseAttrs(ellipseClasses)" />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script setup>
8
- import { computed, ref } from "vue";
8
+ import { computed } from "vue";
9
9
  import UIService from "../service.ui";
10
10
 
11
11
  import { ULoader } from "./constants";
@@ -17,7 +17,7 @@ defineOptions({ name: "ULoader", inheritAttrs: false });
17
17
 
18
18
  const props = defineProps({
19
19
  /**
20
- * The size of the button.
20
+ * Loader size.
21
21
  * @values sm, md, lg
22
22
  */
23
23
  size: {
@@ -35,7 +35,7 @@ const props = defineProps({
35
35
  },
36
36
  });
37
37
 
38
- const ellipsesAmount = ref(4);
38
+ const ELLIPSES_AMOUNT = 4;
39
39
 
40
40
  const { loaderAttrs, ellipseAttrs } = useAttrs(props);
41
41
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.141",
4
+ "version": "0.0.143",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -2914,7 +2914,7 @@
2914
2914
  "kind": "expression",
2915
2915
  "type": "'start' | 'end' | 'center' | 'stretch' | 'baseline'"
2916
2916
  },
2917
- "default": "start"
2917
+ "default": "stretch"
2918
2918
  },
2919
2919
  {
2920
2920
  "name": "upperlined",
@@ -4480,7 +4480,7 @@
4480
4480
  "attributes": [
4481
4481
  {
4482
4482
  "name": "size",
4483
- "description": "The size of the button.",
4483
+ "description": "Loader size.",
4484
4484
  "value": {
4485
4485
  "kind": "expression",
4486
4486
  "type": "'sm' | 'md' | 'lg'"