@weni/unnnic-system 3.32.0 → 3.32.1

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.
@@ -10,57 +10,62 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script>
14
- import { ref, provide } from 'vue';
15
-
13
+ <script lang="ts">
16
14
  export const DEFAULT_BACKGROUND = 'var(--unnnic-color-bg-muted)';
17
15
  export const DEFAULT_HIGHLIGHT = 'var(--unnnic-color-bg-base-soft)';
18
- export const SkeletonStyle = {
16
+
17
+ export type SkeletonStyleVars = {
18
+ '--skeleton-bg': string;
19
+ '--skeleton-highlight': string;
20
+ '--skeleton-duration': string;
21
+ };
22
+
23
+ export const SkeletonStyle: SkeletonStyleVars = {
19
24
  '--skeleton-bg': DEFAULT_BACKGROUND,
20
25
  '--skeleton-highlight': DEFAULT_HIGHLIGHT,
21
26
  '--skeleton-duration': '2s',
22
27
  };
23
- export default {
28
+
29
+ export interface SkeletonThemeProps {
30
+ color?: string;
31
+ highlight?: string;
32
+ duration?: number;
33
+ tag?: string;
34
+ loading?: boolean;
35
+ }
36
+ </script>
37
+
38
+ <script setup lang="ts">
39
+ import { ref, provide, onMounted } from 'vue';
40
+
41
+ defineOptions({
24
42
  name: 'UnnnicSkeletonTheme',
25
- props: {
26
- color: {
27
- type: String,
28
- default: DEFAULT_BACKGROUND,
29
- },
30
- highlight: {
31
- type: String,
32
- default: DEFAULT_HIGHLIGHT,
33
- },
34
- duration: {
35
- type: Number,
36
- default: 2,
37
- },
38
- tag: {
39
- type: String,
40
- default: 'div',
41
- },
42
- loading: {
43
- type: Boolean,
44
- default: undefined,
45
- },
46
- },
47
- setup() {
48
- const themeStyle = ref({ ...SkeletonStyle });
49
- const theme = ref({});
43
+ });
50
44
 
51
- provide('_themeStyle', themeStyle);
52
- provide('_skeletonTheme', theme);
45
+ const props = withDefaults(defineProps<SkeletonThemeProps>(), {
46
+ color: DEFAULT_BACKGROUND,
47
+ highlight: DEFAULT_HIGHLIGHT,
48
+ duration: 2,
49
+ tag: 'div',
50
+ loading: undefined,
51
+ });
53
52
 
54
- return {
55
- themeStyle,
56
- theme,
57
- };
58
- },
59
- mounted() {
60
- const { color, highlight, duration } = this;
61
- this.themeStyle['--skeleton-bg'] = color;
62
- this.themeStyle['--skeleton-highlight'] = highlight;
63
- this.themeStyle['--skeleton-duration'] = duration ? `${duration}s` : '0s';
64
- },
65
- };
53
+ const themeStyle = ref<SkeletonStyleVars>({ ...SkeletonStyle });
54
+ const theme = ref<Record<string, unknown>>({});
55
+
56
+ provide('_themeStyle', themeStyle);
57
+ provide('_skeletonTheme', theme);
58
+
59
+ onMounted(() => {
60
+ themeStyle.value['--skeleton-bg'] = props.color;
61
+ themeStyle.value['--skeleton-highlight'] = props.highlight;
62
+ themeStyle.value['--skeleton-duration'] = props.duration
63
+ ? `${props.duration}s`
64
+ : '0s';
65
+ });
66
+
67
+ defineExpose({
68
+ themeStyle,
69
+ theme,
70
+ });
66
71
  </script>