windly-ui 1.0.1 → 1.0.3
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/dist/module.d.mts +3 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +26 -0
- package/dist/runtime/components/Accordion.d.vue.ts +39 -0
- package/{ui-library → dist/runtime}/components/Accordion.vue +44 -70
- package/dist/runtime/components/Accordion.vue.d.ts +39 -0
- package/dist/runtime/components/Avatar.d.vue.ts +141 -0
- package/dist/runtime/components/Avatar.vue +72 -0
- package/dist/runtime/components/Avatar.vue.d.ts +141 -0
- package/dist/runtime/components/Badge.d.vue.ts +133 -0
- package/dist/runtime/components/Badge.vue +99 -0
- package/dist/runtime/components/Badge.vue.d.ts +133 -0
- package/dist/runtime/components/Breadcrumbs.d.vue.ts +83 -0
- package/{ui-library → dist/runtime}/components/Breadcrumbs.vue +37 -59
- package/dist/runtime/components/Breadcrumbs.vue.d.ts +83 -0
- package/dist/runtime/components/Button.d.vue.ts +199 -0
- package/dist/runtime/components/Button.vue +125 -0
- package/dist/runtime/components/Button.vue.d.ts +199 -0
- package/dist/runtime/components/Card.d.vue.ts +83 -0
- package/{ui-library → dist/runtime}/components/Card.vue +26 -39
- package/dist/runtime/components/Card.vue.d.ts +83 -0
- package/dist/runtime/components/Checkbox.d.vue.ts +190 -0
- package/{ui-library → dist/runtime}/components/Checkbox.vue +45 -68
- package/dist/runtime/components/Checkbox.vue.d.ts +190 -0
- package/dist/runtime/components/CodeBlock.d.vue.ts +16 -0
- package/dist/runtime/components/CodeBlock.vue +75 -0
- package/dist/runtime/components/CodeBlock.vue.d.ts +16 -0
- package/dist/runtime/components/ColorPicker.d.vue.ts +91 -0
- package/dist/runtime/components/ColorPicker.vue +244 -0
- package/dist/runtime/components/ColorPicker.vue.d.ts +91 -0
- package/dist/runtime/components/Date.d.vue.ts +137 -0
- package/dist/runtime/components/Date.vue +201 -0
- package/dist/runtime/components/Date.vue.d.ts +137 -0
- package/dist/runtime/components/Dialog.d.vue.ts +103 -0
- package/{ui-library → dist/runtime}/components/Dialog.vue +30 -65
- package/dist/runtime/components/Dialog.vue.d.ts +103 -0
- package/dist/runtime/components/Divider.d.vue.ts +51 -0
- package/dist/runtime/components/Divider.vue +52 -0
- package/dist/runtime/components/Divider.vue.d.ts +51 -0
- package/dist/runtime/components/Drawer.d.vue.ts +30 -0
- package/dist/runtime/components/Drawer.vue +43 -0
- package/dist/runtime/components/Drawer.vue.d.ts +30 -0
- package/dist/runtime/components/Dropdown.d.vue.ts +34 -0
- package/dist/runtime/components/Dropdown.vue +127 -0
- package/dist/runtime/components/Dropdown.vue.d.ts +34 -0
- package/dist/runtime/components/FileUploader.d.vue.ts +58 -0
- package/dist/runtime/components/FileUploader.vue +202 -0
- package/dist/runtime/components/FileUploader.vue.d.ts +58 -0
- package/dist/runtime/components/Icon.d.vue.ts +41 -0
- package/dist/runtime/components/Icon.vue +66 -0
- package/dist/runtime/components/Icon.vue.d.ts +41 -0
- package/dist/runtime/components/Image.d.vue.ts +77 -0
- package/dist/runtime/components/Image.vue +61 -0
- package/dist/runtime/components/Image.vue.d.ts +77 -0
- package/dist/runtime/components/Input.d.vue.ts +66 -0
- package/dist/runtime/components/Input.vue +233 -0
- package/dist/runtime/components/Input.vue.d.ts +66 -0
- package/dist/runtime/components/Radio.d.vue.ts +41 -0
- package/dist/runtime/components/Radio.vue +222 -0
- package/dist/runtime/components/Radio.vue.d.ts +41 -0
- package/dist/runtime/components/ScrollArea.d.vue.ts +79 -0
- package/dist/runtime/components/ScrollArea.vue +36 -0
- package/dist/runtime/components/ScrollArea.vue.d.ts +79 -0
- package/dist/runtime/components/Select.d.vue.ts +43 -0
- package/dist/runtime/components/Select.vue +200 -0
- package/dist/runtime/components/Select.vue.d.ts +43 -0
- package/dist/runtime/components/Stepper.d.vue.ts +46 -0
- package/dist/runtime/components/Stepper.vue +218 -0
- package/dist/runtime/components/Stepper.vue.d.ts +46 -0
- package/dist/runtime/components/TabPanel.d.vue.ts +17 -0
- package/dist/runtime/components/TabPanel.vue +21 -0
- package/dist/runtime/components/TabPanel.vue.d.ts +17 -0
- package/dist/runtime/components/Table.d.vue.ts +40 -0
- package/dist/runtime/components/Table.vue +92 -0
- package/dist/runtime/components/Table.vue.d.ts +40 -0
- package/dist/runtime/components/Tabs.d.vue.ts +20 -0
- package/dist/runtime/components/Tabs.vue +62 -0
- package/dist/runtime/components/Tabs.vue.d.ts +20 -0
- package/dist/runtime/components/Textarea.d.vue.ts +208 -0
- package/dist/runtime/components/Textarea.vue +185 -0
- package/dist/runtime/components/Textarea.vue.d.ts +208 -0
- package/dist/runtime/components/Toggle.d.vue.ts +36 -0
- package/dist/runtime/components/Toggle.vue +173 -0
- package/dist/runtime/components/Toggle.vue.d.ts +36 -0
- package/dist/runtime/components/Tooltip.d.vue.ts +63 -0
- package/dist/runtime/components/Tooltip.vue +144 -0
- package/dist/runtime/components/Tooltip.vue.d.ts +63 -0
- package/dist/runtime/components/uiProps.d.ts +38 -0
- package/{ui-library/components/uiProps.ts → dist/runtime/components/uiProps.js} +2 -2
- package/dist/runtime/components/useUiClasses.d.ts +43 -0
- package/{ui-library/components/useUiClasses.ts → dist/runtime/components/useUiClasses.js} +25 -60
- package/dist/runtime/composables/plugin.d.ts +2 -0
- package/dist/runtime/composables/plugin.js +3 -0
- package/dist/runtime/tailwind-color.d.ts +2 -0
- package/dist/runtime/tailwind-color.js +5859 -0
- package/dist/types.d.mts +7 -0
- package/package.json +14 -16
- package/README.md +0 -208
- package/ui-library/components/Avatar.vue +0 -121
- package/ui-library/components/Badge.vue +0 -116
- package/ui-library/components/Button.vue +0 -154
- package/ui-library/components/CodeBlock.vue +0 -99
- package/ui-library/components/ColorPicker.vue +0 -302
- package/ui-library/components/Date.vue +0 -240
- package/ui-library/components/Divider.vue +0 -78
- package/ui-library/components/Drawer.vue +0 -67
- package/ui-library/components/Dropdown.vue +0 -248
- package/ui-library/components/FileUploader.vue +0 -330
- package/ui-library/components/Icon.vue +0 -82
- package/ui-library/components/Image.vue +0 -78
- package/ui-library/components/Input.vue +0 -531
- package/ui-library/components/Radio.vue +0 -356
- package/ui-library/components/ScrollArea.vue +0 -43
- package/ui-library/components/Select.vue +0 -309
- package/ui-library/components/Stepper.vue +0 -361
- package/ui-library/components/TabPanel.vue +0 -25
- package/ui-library/components/Table.vue +0 -152
- package/ui-library/components/Tabs.vue +0 -71
- package/ui-library/components/Textarea.vue +0 -233
- package/ui-library/components/Toggle.vue +0 -319
- package/ui-library/components/Tooltip.vue +0 -200
- package/ui-library/components/plugin.ts +0 -8
- package/ui-library/module.ts +0 -20
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineOptions({
|
|
3
|
+
name: "UITooltip",
|
|
4
|
+
inheritAttrs: false
|
|
5
|
+
});
|
|
6
|
+
import { computed, ref } from "vue";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
text: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
placement: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "top",
|
|
15
|
+
validator: (v) => ["top", "right", "bottom", "left"].includes(v)
|
|
16
|
+
},
|
|
17
|
+
arrow: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
},
|
|
21
|
+
color: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "gray-800"
|
|
24
|
+
},
|
|
25
|
+
textColor: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "white"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const baseClasses = computed(() => "px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap");
|
|
31
|
+
const visible = ref(false);
|
|
32
|
+
const isHex = (val) => val.startsWith("#");
|
|
33
|
+
const showTooltip = () => {
|
|
34
|
+
visible.value = true;
|
|
35
|
+
};
|
|
36
|
+
const hideTooltip = () => {
|
|
37
|
+
visible.value = false;
|
|
38
|
+
};
|
|
39
|
+
const tooltipStyle = computed(() => {
|
|
40
|
+
const style = {};
|
|
41
|
+
if (isHex(props.color)) {
|
|
42
|
+
style.backgroundColor = props.color;
|
|
43
|
+
}
|
|
44
|
+
if (isHex(props.textColor)) {
|
|
45
|
+
style.color = props.textColor;
|
|
46
|
+
}
|
|
47
|
+
return style;
|
|
48
|
+
});
|
|
49
|
+
const tooltipClasses = computed(() => [
|
|
50
|
+
baseClasses.value,
|
|
51
|
+
!isHex(props.color) ? `bg-${props.color}` : "",
|
|
52
|
+
!isHex(props.textColor) ? `text-${props.textColor}` : ""
|
|
53
|
+
]);
|
|
54
|
+
const placementClasses = computed(() => {
|
|
55
|
+
switch (props.placement) {
|
|
56
|
+
case "top":
|
|
57
|
+
return "bottom-full left-1/2 -translate-x-1/2 mb-3";
|
|
58
|
+
case "right":
|
|
59
|
+
return "left-full top-1/2 -translate-y-1/2 ml-3";
|
|
60
|
+
case "bottom":
|
|
61
|
+
return "top-full left-1/2 -translate-x-1/2 mt-3";
|
|
62
|
+
case "left":
|
|
63
|
+
return "right-full top-1/2 -translate-y-1/2 mr-3";
|
|
64
|
+
default:
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const arrowClasses = computed(() => {
|
|
69
|
+
switch (props.placement) {
|
|
70
|
+
case "top":
|
|
71
|
+
return "left-1/2 -translate-x-1/2 bottom-0 -mb-3.5";
|
|
72
|
+
case "right":
|
|
73
|
+
return "top-1/2 -translate-y-1/2 left-0 -ml-3.5";
|
|
74
|
+
case "bottom":
|
|
75
|
+
return "left-1/2 -translate-x-1/2 top-0 -mt-3.5";
|
|
76
|
+
case "left":
|
|
77
|
+
return "top-1/2 -translate-y-1/2 right-0 -mr-3.5";
|
|
78
|
+
default:
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const arrowIcon = computed(() => {
|
|
83
|
+
switch (props.placement) {
|
|
84
|
+
case "top":
|
|
85
|
+
return "arrow_drop_down";
|
|
86
|
+
case "right":
|
|
87
|
+
return "arrow_left";
|
|
88
|
+
case "bottom":
|
|
89
|
+
return "arrow_drop_up";
|
|
90
|
+
case "left":
|
|
91
|
+
return "arrow_right";
|
|
92
|
+
default:
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const arrowStyle = computed(() => {
|
|
97
|
+
const style = {};
|
|
98
|
+
if (isHex(props.color))
|
|
99
|
+
style.color = props.color;
|
|
100
|
+
return style;
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<div
|
|
106
|
+
class="relative inline-block"
|
|
107
|
+
tabindex="0"
|
|
108
|
+
@mouseenter="showTooltip"
|
|
109
|
+
@mouseleave="hideTooltip"
|
|
110
|
+
@focus="showTooltip"
|
|
111
|
+
@blur="hideTooltip"
|
|
112
|
+
>
|
|
113
|
+
<!-- Trigger -->
|
|
114
|
+
<slot />
|
|
115
|
+
|
|
116
|
+
<!-- Tooltip -->
|
|
117
|
+
<transition name="fade">
|
|
118
|
+
<div
|
|
119
|
+
v-if="visible"
|
|
120
|
+
role="tooltip"
|
|
121
|
+
class="absolute z-50"
|
|
122
|
+
:class="[tooltipClasses, placementClasses]"
|
|
123
|
+
:style="tooltipStyle"
|
|
124
|
+
v-bind="$attrs"
|
|
125
|
+
>
|
|
126
|
+
<!-- Arrow -->
|
|
127
|
+
<i
|
|
128
|
+
v-if="arrow"
|
|
129
|
+
class="material-icons tooltip-arrow"
|
|
130
|
+
:class="[arrowClasses, !isHex(props.color) ? `text-${props.color}` : '']"
|
|
131
|
+
:style="arrowStyle"
|
|
132
|
+
>
|
|
133
|
+
{{ arrowIcon }}
|
|
134
|
+
</i>
|
|
135
|
+
|
|
136
|
+
{{ text }}
|
|
137
|
+
</div>
|
|
138
|
+
</transition>
|
|
139
|
+
</div>
|
|
140
|
+
</template>
|
|
141
|
+
|
|
142
|
+
<style scoped>
|
|
143
|
+
.fade-enter-active,.fade-leave-active{transition:opacity .2s ease}.fade-enter-from,.fade-leave-to{opacity:0}.tooltip-arrow{font-size:1.5rem;line-height:1;position:absolute}
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type TooltipPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
2
|
+
declare var __VLS_1: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
default?: (props: typeof __VLS_1) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
text: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
placement: {
|
|
12
|
+
type: () => TooltipPlacement;
|
|
13
|
+
default: string;
|
|
14
|
+
validator: (v: string) => any;
|
|
15
|
+
};
|
|
16
|
+
arrow: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
color: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
textColor: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
|
+
text: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
required: true;
|
|
32
|
+
};
|
|
33
|
+
placement: {
|
|
34
|
+
type: () => TooltipPlacement;
|
|
35
|
+
default: string;
|
|
36
|
+
validator: (v: string) => any;
|
|
37
|
+
};
|
|
38
|
+
arrow: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
color: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
textColor: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
}>> & Readonly<{}>, {
|
|
51
|
+
textColor: string;
|
|
52
|
+
color: string;
|
|
53
|
+
placement: TooltipPlacement;
|
|
54
|
+
arrow: boolean;
|
|
55
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
56
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
57
|
+
declare const _default: typeof __VLS_export;
|
|
58
|
+
export default _default;
|
|
59
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
60
|
+
new (): {
|
|
61
|
+
$slots: S;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const uiProps: {
|
|
2
|
+
readonly contentClass: {
|
|
3
|
+
readonly type: StringConstructor;
|
|
4
|
+
readonly default: "";
|
|
5
|
+
};
|
|
6
|
+
readonly contentStyle: {
|
|
7
|
+
readonly type: StringConstructor;
|
|
8
|
+
readonly default: "";
|
|
9
|
+
};
|
|
10
|
+
readonly textColor: {
|
|
11
|
+
readonly type: StringConstructor;
|
|
12
|
+
readonly default: "";
|
|
13
|
+
};
|
|
14
|
+
readonly disable: {
|
|
15
|
+
readonly type: BooleanConstructor;
|
|
16
|
+
readonly default: false;
|
|
17
|
+
};
|
|
18
|
+
readonly loading: {
|
|
19
|
+
readonly type: BooleanConstructor;
|
|
20
|
+
readonly default: false;
|
|
21
|
+
};
|
|
22
|
+
readonly color: {
|
|
23
|
+
readonly type: StringConstructor;
|
|
24
|
+
readonly default: "blue-900";
|
|
25
|
+
};
|
|
26
|
+
readonly rounded: {
|
|
27
|
+
readonly type: StringConstructor;
|
|
28
|
+
readonly default: "md";
|
|
29
|
+
};
|
|
30
|
+
readonly size: {
|
|
31
|
+
readonly type: StringConstructor;
|
|
32
|
+
readonly default: "md";
|
|
33
|
+
};
|
|
34
|
+
readonly iconSize: {
|
|
35
|
+
readonly type: StringConstructor;
|
|
36
|
+
readonly default: "lg";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from "vue";
|
|
2
|
+
import { uiProps } from "./uiProps.js";
|
|
3
|
+
type UiProps = ExtractPropTypes<typeof uiProps>;
|
|
4
|
+
export declare function useUiClasses(props: Partial<UiProps>): {
|
|
5
|
+
contentClass: import("vue").Ref<string, string>;
|
|
6
|
+
contentStyle: import("vue").Ref<string, string>;
|
|
7
|
+
textColor: import("vue").Ref<string, string>;
|
|
8
|
+
disable: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
loading: import("vue").Ref<boolean, boolean>;
|
|
10
|
+
color: import("vue").Ref<string, string>;
|
|
11
|
+
rounded: import("vue").Ref<string, string>;
|
|
12
|
+
size: import("vue").Ref<string, string>;
|
|
13
|
+
iconSize: import("vue").Ref<string, string>;
|
|
14
|
+
roundedClass: {
|
|
15
|
+
none: string;
|
|
16
|
+
xs: string;
|
|
17
|
+
sm: string;
|
|
18
|
+
md: string;
|
|
19
|
+
lg: string;
|
|
20
|
+
xl: string;
|
|
21
|
+
full: string;
|
|
22
|
+
};
|
|
23
|
+
sizeClass: {
|
|
24
|
+
sm: string;
|
|
25
|
+
md: string;
|
|
26
|
+
lg: string;
|
|
27
|
+
};
|
|
28
|
+
iconSizeClasses: {
|
|
29
|
+
xs: string;
|
|
30
|
+
sm: string;
|
|
31
|
+
md: string;
|
|
32
|
+
lg: string;
|
|
33
|
+
xl: string;
|
|
34
|
+
};
|
|
35
|
+
colorClass: import("vue").ComputedRef<string>;
|
|
36
|
+
computedContentClass: import("vue").ComputedRef<string>;
|
|
37
|
+
isColorDark: (color: string) => boolean;
|
|
38
|
+
isHex: (color: string) => boolean;
|
|
39
|
+
isTailwindColor: (color: string) => boolean;
|
|
40
|
+
shadeTailwind: (color: string, delta?: number) => string;
|
|
41
|
+
shadeHex: (hex: string, amount?: number) => string;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { computed, toRefs } from "vue";
|
|
2
|
-
|
|
3
|
-
import { uiProps } from "./uiProps";
|
|
4
|
-
|
|
5
|
-
type UiProps = ExtractPropTypes<typeof uiProps>;
|
|
6
|
-
|
|
7
|
-
export function useUiClasses(props: Partial<UiProps>) {
|
|
2
|
+
export function useUiClasses(props) {
|
|
8
3
|
const safeProps = {
|
|
9
4
|
contentClass: "",
|
|
10
5
|
contentStyle: "",
|
|
@@ -15,9 +10,8 @@ export function useUiClasses(props: Partial<UiProps>) {
|
|
|
15
10
|
rounded: "md",
|
|
16
11
|
size: "md",
|
|
17
12
|
iconSize: "md",
|
|
18
|
-
...props
|
|
13
|
+
...props
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
const {
|
|
22
16
|
contentClass,
|
|
23
17
|
contentStyle,
|
|
@@ -27,10 +21,8 @@ export function useUiClasses(props: Partial<UiProps>) {
|
|
|
27
21
|
color,
|
|
28
22
|
rounded,
|
|
29
23
|
size,
|
|
30
|
-
iconSize
|
|
24
|
+
iconSize
|
|
31
25
|
} = toRefs(safeProps);
|
|
32
|
-
|
|
33
|
-
// Classes maps
|
|
34
26
|
const roundedClass = {
|
|
35
27
|
none: "rounded-none",
|
|
36
28
|
xs: "rounded-xs",
|
|
@@ -38,100 +30,73 @@ export function useUiClasses(props: Partial<UiProps>) {
|
|
|
38
30
|
md: "rounded",
|
|
39
31
|
lg: "rounded-lg",
|
|
40
32
|
xl: "rounded-xl",
|
|
41
|
-
full: "rounded-full"
|
|
33
|
+
full: "rounded-full"
|
|
42
34
|
};
|
|
43
|
-
|
|
44
35
|
const sizeClass = {
|
|
45
36
|
sm: "text-xs",
|
|
46
37
|
md: "text-base",
|
|
47
|
-
lg: "text-xl"
|
|
38
|
+
lg: "text-xl"
|
|
48
39
|
};
|
|
49
|
-
|
|
50
40
|
const iconSizeClasses = {
|
|
51
41
|
xs: "text-xs",
|
|
52
42
|
sm: "text-sm",
|
|
53
43
|
md: "text-base",
|
|
54
44
|
lg: "text-lg",
|
|
55
|
-
xl: "text-xl"
|
|
45
|
+
xl: "text-xl"
|
|
56
46
|
};
|
|
57
|
-
|
|
58
|
-
// Computed for color class
|
|
59
47
|
const colorClass = computed(() => {
|
|
60
48
|
if (!color.value) return "";
|
|
61
49
|
return color.value.includes("#") ? `[${color.value}]` : color.value;
|
|
62
50
|
});
|
|
63
|
-
|
|
64
|
-
// Computed for content class with ! prefix
|
|
65
51
|
const computedContentClass = computed(() => {
|
|
66
52
|
if (!contentClass.value) return "";
|
|
67
|
-
return contentClass.value
|
|
68
|
-
.split(" ")
|
|
69
|
-
.map((cls: string) => (cls.startsWith("!") ? cls : `!${cls}`))
|
|
70
|
-
.join(" ");
|
|
53
|
+
return contentClass.value.split(" ").map((cls) => cls.startsWith("!") ? cls : `!${cls}`).join(" ");
|
|
71
54
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const match = color.match(/-(\d{2,3})$/);
|
|
55
|
+
function isTailwindColorDark(color2) {
|
|
56
|
+
const match = color2.match(/-(\d{2,3})$/);
|
|
75
57
|
if (!match) return false;
|
|
76
58
|
return Number(match[1]) >= 400;
|
|
77
59
|
}
|
|
78
|
-
|
|
79
|
-
function isHexColorDark(hex: string): boolean {
|
|
60
|
+
function isHexColorDark(hex) {
|
|
80
61
|
let c = hex.replace("#", "");
|
|
81
|
-
|
|
82
62
|
if (c.length === 3) {
|
|
83
|
-
c = c.split("").map(x => x + x).join("");
|
|
63
|
+
c = c.split("").map((x) => x + x).join("");
|
|
84
64
|
}
|
|
85
|
-
|
|
86
65
|
const r = parseInt(c.substring(0, 2), 16);
|
|
87
66
|
const g = parseInt(c.substring(2, 4), 16);
|
|
88
67
|
const b = parseInt(c.substring(4, 6), 16);
|
|
89
|
-
|
|
90
68
|
const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
91
69
|
return luminance < 140;
|
|
92
70
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return /^#([0-9A-F]{3}){1,2}$/i.test(color);
|
|
71
|
+
function isHex(color2) {
|
|
72
|
+
return /^#([0-9A-F]{3}){1,2}$/i.test(color2);
|
|
96
73
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return /^[a-z]+-\d{2,3}$/.test(color);
|
|
74
|
+
function isTailwindColor(color2) {
|
|
75
|
+
return /^[a-z]+-\d{2,3}$/.test(color2);
|
|
100
76
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return color.startsWith("#")
|
|
105
|
-
? isHexColorDark(color)
|
|
106
|
-
: isTailwindColorDark(color);
|
|
77
|
+
const isColorDark = (color2) => {
|
|
78
|
+
if (!color2) return false;
|
|
79
|
+
return color2.startsWith("#") ? isHexColorDark(color2) : isTailwindColorDark(color2);
|
|
107
80
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const [name, shade] = color.split("-");
|
|
81
|
+
function shadeTailwind(color2, delta = 100) {
|
|
82
|
+
const [name, shade] = color2.split("-");
|
|
111
83
|
const nextShade = Math.min(900, Math.max(100, Number(shade) + delta));
|
|
112
84
|
return `${name}-${nextShade}`;
|
|
113
85
|
}
|
|
114
|
-
|
|
115
|
-
function shadeHex(hex: string, amount = -10) {
|
|
86
|
+
function shadeHex(hex, amount = -10) {
|
|
116
87
|
let c = hex.substring(1);
|
|
117
88
|
if (c.length === 3) {
|
|
118
|
-
c = c.split("").map(x => x + x).join("");
|
|
89
|
+
c = c.split("").map((x) => x + x).join("");
|
|
119
90
|
}
|
|
120
|
-
|
|
121
91
|
const num = parseInt(c, 16);
|
|
122
|
-
let r =
|
|
123
|
-
let g =
|
|
92
|
+
let r = num >> 16 & 255;
|
|
93
|
+
let g = num >> 8 & 255;
|
|
124
94
|
let b = num & 255;
|
|
125
|
-
|
|
126
95
|
r = Math.min(255, Math.max(0, r + amount));
|
|
127
96
|
g = Math.min(255, Math.max(0, g + amount));
|
|
128
97
|
b = Math.min(255, Math.max(0, b + amount));
|
|
129
|
-
|
|
130
|
-
return `#${((1 << 24) + (r << 16) + (g << 8) + b)
|
|
131
|
-
.toString(16)
|
|
132
|
-
.slice(1)}`;
|
|
98
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
133
99
|
}
|
|
134
|
-
|
|
135
100
|
return {
|
|
136
101
|
// props
|
|
137
102
|
contentClass,
|