@hlw-uni/mp-vue 1.0.35 → 1.1.0

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.
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <scroll-view class="hlw-tabs" :scroll-x="scrollable" :enhanced="true" :show-scrollbar="false">
3
+ <view class="hlw-tabs-wrap">
4
+ <view
5
+ v-for="(item, index) in items"
6
+ :key="index"
7
+ class="hlw-tab"
8
+ :class="{ 'hlw-tab--active': modelValue === index }"
9
+ @tap="onChange(index)"
10
+ >
11
+ <text class="hlw-tab-text">{{ typeof item === "string" ? item : item.label }}</text>
12
+ <view
13
+ v-if="typeof item !== 'string' && item.badge"
14
+ class="hlw-tab-badge"
15
+ >{{ item.badge }}</view>
16
+ <view v-if="modelValue === index" class="hlw-tab-line" :style="{ width: lineWidth }" />
17
+ </view>
18
+ </view>
19
+ </scroll-view>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ export interface HlwTabItem {
24
+ label: string;
25
+ badge?: string;
26
+ }
27
+
28
+ interface Props {
29
+ modelValue?: number;
30
+ items?: (string | HlwTabItem)[];
31
+ scrollable?: boolean;
32
+ lineWidth?: string;
33
+ }
34
+
35
+ withDefaults(defineProps<Props>(), {
36
+ modelValue: 0,
37
+ items: () => [],
38
+ scrollable: false,
39
+ lineWidth: "40rpx",
40
+ });
41
+
42
+ const emit = defineEmits<{ "update:modelValue": [index: number]; change: [index: number] }>();
43
+
44
+ function onChange(index: number) {
45
+ emit("update:modelValue", index);
46
+ emit("change", index);
47
+ }
48
+ </script>
49
+
50
+ <style lang="scss" scoped>
51
+ .hlw-tabs {
52
+ background: #fff;
53
+ white-space: nowrap;
54
+ }
55
+
56
+ .hlw-tabs-wrap {
57
+ display: inline-flex;
58
+ min-width: 100%;
59
+ }
60
+
61
+ .hlw-tab {
62
+ position: relative;
63
+ flex: 1;
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ padding: 24rpx 28rpx;
68
+ gap: 6rpx;
69
+ transition: color 0.2s;
70
+
71
+ &--active .hlw-tab-text {
72
+ color: var(--primary-color, #3b82f6);
73
+ font-weight: 600;
74
+ }
75
+ }
76
+
77
+ .hlw-tab-text {
78
+ font-size: var(--font-base, 28rpx);
79
+ color: #64748b;
80
+ }
81
+
82
+ .hlw-tab-badge {
83
+ padding: 0 8rpx;
84
+ min-width: 28rpx;
85
+ height: 28rpx;
86
+ line-height: 28rpx;
87
+ font-size: 18rpx;
88
+ text-align: center;
89
+ color: #fff;
90
+ background: #ef4444;
91
+ border-radius: 999rpx;
92
+ }
93
+
94
+ .hlw-tab-line {
95
+ position: absolute;
96
+ bottom: 4rpx;
97
+ left: 50%;
98
+ transform: translateX(-50%);
99
+ height: 6rpx;
100
+ border-radius: 6rpx;
101
+ background: var(--primary-color, #3b82f6);
102
+ transition: width 0.2s;
103
+ }
104
+ </style>
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <view
3
+ class="hlw-tag"
4
+ :class="[`hlw-tag--${type}`, `hlw-tag--${size}`, { 'hlw-tag--plain': plain, 'hlw-tag--round': round }]"
5
+ :style="customStyle"
6
+ @tap="$emit('click')"
7
+ >
8
+ <slot />
9
+ <view v-if="closable" class="hlw-tag-close" @tap.stop="$emit('close')">&#215;</view>
10
+ </view>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed } from "vue";
15
+
16
+ interface Props {
17
+ type?: "primary" | "success" | "warning" | "danger" | "info";
18
+ plain?: boolean;
19
+ closable?: boolean;
20
+ size?: "small" | "medium";
21
+ round?: boolean;
22
+ color?: string;
23
+ }
24
+
25
+ const props = withDefaults(defineProps<Props>(), {
26
+ type: "primary",
27
+ plain: false,
28
+ closable: false,
29
+ size: "medium",
30
+ round: false,
31
+ color: "",
32
+ });
33
+
34
+ defineEmits<{ click: []; close: [] }>();
35
+
36
+ const customStyle = computed(() => {
37
+ if (!props.color) return {};
38
+ return props.plain
39
+ ? { color: props.color, borderColor: props.color, background: "transparent" }
40
+ : { background: props.color, color: "#fff", borderColor: props.color };
41
+ });
42
+ </script>
43
+
44
+ <style lang="scss" scoped>
45
+ $colors: (
46
+ primary: var(--primary-color, #3b82f6),
47
+ success: #10b981,
48
+ warning: #f59e0b,
49
+ danger: #ef4444,
50
+ info: #64748b,
51
+ );
52
+
53
+ .hlw-tag {
54
+ display: inline-flex;
55
+ align-items: center;
56
+ gap: 4rpx;
57
+ font-weight: 500;
58
+ border: 2rpx solid transparent;
59
+
60
+ &--medium { padding: 4rpx 16rpx; font-size: var(--font-xs, 20rpx); border-radius: var(--radius-sm, 8rpx); }
61
+ &--small { padding: 2rpx 10rpx; font-size: 18rpx; border-radius: 6rpx; }
62
+ &--round { border-radius: 999rpx; }
63
+
64
+ @each $name, $c in $colors {
65
+ &--#{$name} { background: #{$c}; color: #fff; border-color: #{$c}; }
66
+ &--#{$name}.hlw-tag--plain { background: transparent; color: #{$c}; }
67
+ }
68
+ }
69
+
70
+ .hlw-tag-close {
71
+ font-size: 1.2em;
72
+ line-height: 1;
73
+ margin-left: 2rpx;
74
+ opacity: 0.8;
75
+ }
76
+ </style>
package/src/index.ts CHANGED
@@ -4,13 +4,24 @@
4
4
 
5
5
  export { default as HlwAd } from "./components/hlw-ad/index.vue";
6
6
  export { default as HlwAvatar } from "./components/hlw-avatar/index.vue";
7
+ export { default as HlwButton } from "./components/hlw-button/index.vue";
7
8
  export { default as HlwCard } from "./components/hlw-card/index.vue";
9
+ export { default as HlwCell } from "./components/hlw-cell/index.vue";
10
+ export { default as HlwDivider } from "./components/hlw-divider/index.vue";
8
11
  export { default as HlwEmpty } from "./components/hlw-empty/index.vue";
9
12
  export { default as HlwHeader } from "./components/hlw-header/index.vue";
10
13
  export { default as HlwLoading } from "./components/hlw-loading/index.vue";
11
14
  export { default as HlwMenu } from "./components/hlw-menu/index.vue";
12
15
  export type { HlwMenuItem } from "./components/hlw-menu/types";
16
+ export { default as HlwModal } from "./components/hlw-modal/index.vue";
17
+ export { default as HlwNoticeBar } from "./components/hlw-notice-bar/index.vue";
13
18
  export { default as HlwPage } from "./components/hlw-page/index.vue";
19
+ export { default as HlwPopup } from "./components/hlw-popup/index.vue";
20
+ export { default as HlwSearch } from "./components/hlw-search/index.vue";
21
+ export { default as HlwSkeleton } from "./components/hlw-skeleton/index.vue";
22
+ export { default as HlwTabs } from "./components/hlw-tabs/index.vue";
23
+ export { default as HlwTag } from "./components/hlw-tag/index.vue";
24
+ export type { HlwTabItem } from "./components/hlw-tabs/index.vue";
14
25
  export type { FontScale, FontPreset, ThemeColor } from "./composables/theme";
15
26
  export { FONT_PRESETS, FONT_SCALE_KEY, DEFAULT_THEMES, THEME_COLOR_KEY, THEME_CHANGE_EVENT, getCurrentFontScale, getCurrentFontVars, getCurrentThemeColor, getCurrentThemeVars, buildThemeStyle, useThemePageStyle } from "./composables/theme";
16
27
  export { useThemeStore } from "./stores/theme";