@atooyu/uxto-ui 1.0.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.
Files changed (141) hide show
  1. package/README.md +259 -0
  2. package/dist/index.js +5055 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +5055 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/style.css +2528 -0
  7. package/package.json +93 -0
  8. package/src/components/index.ts +51 -0
  9. package/src/components/u-avatar/u-avatar.vue +205 -0
  10. package/src/components/u-badge/u-badge.vue +145 -0
  11. package/src/components/u-button/u-button.vue +239 -0
  12. package/src/components/u-cell/u-cell.vue +179 -0
  13. package/src/components/u-cell-group/u-cell-group.vue +46 -0
  14. package/src/components/u-checkbox/u-checkbox.vue +174 -0
  15. package/src/components/u-checkbox-group/u-checkbox-group.vue +72 -0
  16. package/src/components/u-code-input/u-code-input.vue +248 -0
  17. package/src/components/u-count-down/u-count-down.vue +182 -0
  18. package/src/components/u-datetime-picker/u-datetime-picker.vue +377 -0
  19. package/src/components/u-divider/u-divider.vue +71 -0
  20. package/src/components/u-empty/u-empty.vue +98 -0
  21. package/src/components/u-grid/u-grid.vue +63 -0
  22. package/src/components/u-grid-item/u-grid-item.vue +170 -0
  23. package/src/components/u-icon/icons/account.svg +3 -0
  24. package/src/components/u-icon/icons/arrow-down.svg +3 -0
  25. package/src/components/u-icon/icons/arrow-left.svg +3 -0
  26. package/src/components/u-icon/icons/arrow-right.svg +3 -0
  27. package/src/components/u-icon/icons/arrow-up.svg +3 -0
  28. package/src/components/u-icon/icons/bell.svg +3 -0
  29. package/src/components/u-icon/icons/bookmark-o.svg +3 -0
  30. package/src/components/u-icon/icons/bookmark.svg +3 -0
  31. package/src/components/u-icon/icons/chat.svg +3 -0
  32. package/src/components/u-icon/icons/check-circle.svg +3 -0
  33. package/src/components/u-icon/icons/check.svg +3 -0
  34. package/src/components/u-icon/icons/chevron-left.svg +3 -0
  35. package/src/components/u-icon/icons/chevron-right.svg +3 -0
  36. package/src/components/u-icon/icons/clear-o.svg +3 -0
  37. package/src/components/u-icon/icons/clear.svg +3 -0
  38. package/src/components/u-icon/icons/clipboard.svg +3 -0
  39. package/src/components/u-icon/icons/clock.svg +3 -0
  40. package/src/components/u-icon/icons/close.svg +3 -0
  41. package/src/components/u-icon/icons/code.svg +3 -0
  42. package/src/components/u-icon/icons/copy.svg +3 -0
  43. package/src/components/u-icon/icons/delete.svg +3 -0
  44. package/src/components/u-icon/icons/download.svg +3 -0
  45. package/src/components/u-icon/icons/edit.svg +3 -0
  46. package/src/components/u-icon/icons/email.svg +3 -0
  47. package/src/components/u-icon/icons/error-o.svg +3 -0
  48. package/src/components/u-icon/icons/error.svg +3 -0
  49. package/src/components/u-icon/icons/exit-fullscreen.svg +3 -0
  50. package/src/components/u-icon/icons/expand-less.svg +3 -0
  51. package/src/components/u-icon/icons/expand-more.svg +3 -0
  52. package/src/components/u-icon/icons/eye-off.svg +3 -0
  53. package/src/components/u-icon/icons/eye.svg +3 -0
  54. package/src/components/u-icon/icons/flag-o.svg +3 -0
  55. package/src/components/u-icon/icons/flag.svg +3 -0
  56. package/src/components/u-icon/icons/fullscreen.svg +3 -0
  57. package/src/components/u-icon/icons/grid.svg +3 -0
  58. package/src/components/u-icon/icons/group.svg +3 -0
  59. package/src/components/u-icon/icons/heart-o.svg +3 -0
  60. package/src/components/u-icon/icons/heart.svg +3 -0
  61. package/src/components/u-icon/icons/info-o.svg +3 -0
  62. package/src/components/u-icon/icons/info.svg +3 -0
  63. package/src/components/u-icon/icons/keyboard-arrow-down.svg +3 -0
  64. package/src/components/u-icon/icons/keyboard-arrow-left.svg +3 -0
  65. package/src/components/u-icon/icons/keyboard-arrow-right.svg +3 -0
  66. package/src/components/u-icon/icons/keyboard-arrow-up.svg +3 -0
  67. package/src/components/u-icon/icons/like-o.svg +3 -0
  68. package/src/components/u-icon/icons/like.svg +3 -0
  69. package/src/components/u-icon/icons/link.svg +3 -0
  70. package/src/components/u-icon/icons/list.svg +3 -0
  71. package/src/components/u-icon/icons/loading.svg +3 -0
  72. package/src/components/u-icon/icons/lock.svg +3 -0
  73. package/src/components/u-icon/icons/menu-o.svg +3 -0
  74. package/src/components/u-icon/icons/menu.svg +3 -0
  75. package/src/components/u-icon/icons/message.svg +3 -0
  76. package/src/components/u-icon/icons/minus.svg +3 -0
  77. package/src/components/u-icon/icons/notification.svg +3 -0
  78. package/src/components/u-icon/icons/phone.svg +3 -0
  79. package/src/components/u-icon/icons/plus.svg +3 -0
  80. package/src/components/u-icon/icons/question.svg +3 -0
  81. package/src/components/u-icon/icons/redo.svg +3 -0
  82. package/src/components/u-icon/icons/refresh-o.svg +3 -0
  83. package/src/components/u-icon/icons/refresh.svg +3 -0
  84. package/src/components/u-icon/icons/reload.svg +3 -0
  85. package/src/components/u-icon/icons/search-o.svg +3 -0
  86. package/src/components/u-icon/icons/search.svg +3 -0
  87. package/src/components/u-icon/icons/setting.svg +3 -0
  88. package/src/components/u-icon/icons/share.svg +3 -0
  89. package/src/components/u-icon/icons/smile-o.svg +3 -0
  90. package/src/components/u-icon/icons/smile.svg +3 -0
  91. package/src/components/u-icon/icons/star-o.svg +3 -0
  92. package/src/components/u-icon/icons/star.svg +3 -0
  93. package/src/components/u-icon/icons/success-o.svg +3 -0
  94. package/src/components/u-icon/icons/success.svg +3 -0
  95. package/src/components/u-icon/icons/sync.svg +3 -0
  96. package/src/components/u-icon/icons/tick.svg +3 -0
  97. package/src/components/u-icon/icons/undo.svg +3 -0
  98. package/src/components/u-icon/icons/unlock.svg +3 -0
  99. package/src/components/u-icon/icons/upload.svg +3 -0
  100. package/src/components/u-icon/icons/user.svg +3 -0
  101. package/src/components/u-icon/icons/warning-o.svg +3 -0
  102. package/src/components/u-icon/icons/warning.svg +3 -0
  103. package/src/components/u-icon/icons/zoom-in.svg +3 -0
  104. package/src/components/u-icon/icons/zoom-out.svg +3 -0
  105. package/src/components/u-icon/index.ts +219 -0
  106. package/src/components/u-icon/u-icon.vue +117 -0
  107. package/src/components/u-image/u-image.vue +106 -0
  108. package/src/components/u-input/u-input.vue +208 -0
  109. package/src/components/u-keyboard/u-keyboard.vue +213 -0
  110. package/src/components/u-layout/u-layout.vue +58 -0
  111. package/src/components/u-line-progress/u-line-progress.vue +156 -0
  112. package/src/components/u-link/u-link.vue +113 -0
  113. package/src/components/u-list/u-list.vue +148 -0
  114. package/src/components/u-list-item/u-list-item.vue +180 -0
  115. package/src/components/u-loading/u-loading.vue +80 -0
  116. package/src/components/u-loading-page/u-loading-page.vue +94 -0
  117. package/src/components/u-modal/u-modal.vue +159 -0
  118. package/src/components/u-notice-bar/u-notice-bar.vue +113 -0
  119. package/src/components/u-number-box/u-number-box.vue +262 -0
  120. package/src/components/u-parse/u-parse.vue +197 -0
  121. package/src/components/u-picker/u-picker.vue +219 -0
  122. package/src/components/u-popup/u-popup.vue +257 -0
  123. package/src/components/u-radio/u-radio.vue +159 -0
  124. package/src/components/u-radio-group/u-radio-group.vue +61 -0
  125. package/src/components/u-rate/u-rate.vue +187 -0
  126. package/src/components/u-read-more/u-read-more.vue +117 -0
  127. package/src/components/u-search/u-search.vue +238 -0
  128. package/src/components/u-skeleton/u-skeleton.vue +192 -0
  129. package/src/components/u-slider/u-slider.vue +453 -0
  130. package/src/components/u-swiper/u-swiper.vue +301 -0
  131. package/src/components/u-swiper-item/u-swiper-item.vue +82 -0
  132. package/src/components/u-switch/u-switch.vue +105 -0
  133. package/src/components/u-tabbar/u-tabbar.vue +221 -0
  134. package/src/components/u-tag/u-tag.vue +144 -0
  135. package/src/components/u-textarea/u-textarea.vue +189 -0
  136. package/src/components/u-toast/u-toast.vue +186 -0
  137. package/src/components/u-tooltip/u-tooltip.vue +364 -0
  138. package/src/components/u-transition/u-transition.vue +216 -0
  139. package/src/components/u-upload/u-upload.vue +403 -0
  140. package/src/styles/index.scss +59 -0
  141. package/src/styles/variables.scss +68 -0
@@ -0,0 +1,180 @@
1
+ <template>
2
+ <view
3
+ class="u-list-item"
4
+ :class="{
5
+ 'u-list-item--clickable': clickable,
6
+ 'u-list-item--disabled': disabled
7
+ }"
8
+ @click="handleClick"
9
+ >
10
+ <!-- 列表项图标/图片 -->
11
+ <view v-if="$slots.icon || icon || thumb" class="u-list-item__icon">
12
+ <slot name="icon">
13
+ <image v-if="thumb" class="u-list-item__thumb" :src="thumb" mode="aspectFill" />
14
+ <text v-else-if="icon" class="u-list-item__icon-text">{{ icon }}</text>
15
+ </slot>
16
+ </view>
17
+
18
+ <!-- 列表项主体 -->
19
+ <view class="u-list-item__body">
20
+ <view v-if="title || $slots.title" class="u-list-item__title">
21
+ <slot name="title">{{ title }}</slot>
22
+ </view>
23
+ <view v-if="desc || $slots.desc" class="u-list-item__desc">
24
+ <slot name="desc">{{ desc }}</slot>
25
+ </view>
26
+ <view v-if="$slots.default" class="u-list-item__content">
27
+ <slot />
28
+ </view>
29
+ </view>
30
+
31
+ <!-- 列表项右侧内容 -->
32
+ <view v-if="$slots.extra || extra || value" class="u-list-item__extra">
33
+ <slot name="extra">
34
+ <text v-if="value" class="u-list-item__value">{{ value }}</text>
35
+ <text v-if="extra" class="u-list-item__extra-text">{{ extra }}</text>
36
+ </slot>
37
+ <view v-if="showArrow" class="u-list-item__arrow">
38
+ <text class="u-list-item__arrow-icon">›</text>
39
+ </view>
40
+ </view>
41
+ </view>
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ interface Props {
46
+ title?: string
47
+ desc?: string
48
+ value?: string
49
+ extra?: string
50
+ icon?: string
51
+ thumb?: string
52
+ clickable?: boolean
53
+ disabled?: boolean
54
+ showArrow?: boolean
55
+ }
56
+
57
+ const props = withDefaults(defineProps<Props>(), {
58
+ title: '',
59
+ desc: '',
60
+ value: '',
61
+ extra: '',
62
+ icon: '',
63
+ thumb: '',
64
+ clickable: false,
65
+ disabled: false,
66
+ showArrow: false
67
+ })
68
+
69
+ const emit = defineEmits<{
70
+ click: [event: Event]
71
+ }>()
72
+
73
+ const handleClick = (event: Event) => {
74
+ if (props.disabled) return
75
+ emit('click', event)
76
+ }
77
+ </script>
78
+
79
+ <script lang="ts">
80
+ export default {
81
+ options: {
82
+ virtualHost: true,
83
+ styleIsolation: 'shared'
84
+ }
85
+ }
86
+ </script>
87
+
88
+ <style lang="scss" scoped>
89
+ .u-list-item {
90
+ display: flex;
91
+ align-items: flex-start;
92
+ padding: $--spacing-md $--spacing-lg;
93
+ background-color: $--bg-color-2;
94
+ border-bottom: 1px solid $--border-color;
95
+ transition: background-color $--transition-duration;
96
+
97
+ &:last-child {
98
+ border-bottom: none;
99
+ }
100
+
101
+ &--clickable {
102
+ &:active {
103
+ background-color: $--bg-color;
104
+ }
105
+ }
106
+
107
+ &--disabled {
108
+ opacity: 0.5;
109
+ }
110
+
111
+ &__icon {
112
+ display: flex;
113
+ align-items: center;
114
+ margin-right: $--spacing-md;
115
+ }
116
+
117
+ &__thumb {
118
+ width: 40px;
119
+ height: 40px;
120
+ border-radius: $--border-radius-sm;
121
+ object-fit: cover;
122
+ }
123
+
124
+ &__icon-text {
125
+ font-size: 20px;
126
+ }
127
+
128
+ &__body {
129
+ flex: 1;
130
+ display: flex;
131
+ flex-direction: column;
132
+ min-width: 0;
133
+ }
134
+
135
+ &__title {
136
+ font-size: $--font-size-md;
137
+ color: $--text-color;
138
+ line-height: 1.5;
139
+ }
140
+
141
+ &__desc {
142
+ margin-top: $--spacing-xs;
143
+ font-size: $--font-size-sm;
144
+ color: $--text-color-2;
145
+ line-height: 1.4;
146
+ }
147
+
148
+ &__content {
149
+ margin-top: $--spacing-sm;
150
+ }
151
+
152
+ &__extra {
153
+ display: flex;
154
+ align-items: center;
155
+ margin-left: $--spacing-md;
156
+ flex-shrink: 0;
157
+ }
158
+
159
+ &__value {
160
+ font-size: $--font-size-md;
161
+ color: $--text-color-2;
162
+ }
163
+
164
+ &__extra-text {
165
+ font-size: $--font-size-sm;
166
+ color: $--text-color-3;
167
+ }
168
+
169
+ &__arrow {
170
+ display: flex;
171
+ align-items: center;
172
+ margin-left: $--spacing-sm;
173
+ color: $--text-color-3;
174
+ }
175
+
176
+ &__arrow-icon {
177
+ font-size: 16px;
178
+ }
179
+ }
180
+ </style>
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <view class="u-loading" :class="{ 'u-loading--vertical': vertical }">
3
+ <view class="u-loading__spinner" :style="{ width: size + 'px', height: size + 'px' }">
4
+ <view
5
+ v-for="i in 12"
6
+ :key="i"
7
+ class="u-loading__line"
8
+ :style="{
9
+ transform: `rotate(${i * 30}deg)`,
10
+ backgroundColor: color
11
+ }"
12
+ />
13
+ </view>
14
+ <text v-if="text" class="u-loading__text" :style="{ color: textColor || color }">{{ text }}</text>
15
+ </view>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ interface Props {
20
+ size?: number | string
21
+ color?: string
22
+ text?: string
23
+ textColor?: string
24
+ vertical?: boolean
25
+ }
26
+
27
+ withDefaults(defineProps<Props>(), {
28
+ size: 30,
29
+ color: '#1989fa'
30
+ })
31
+ </script>
32
+
33
+ <script lang="ts">
34
+ export default {
35
+ options: {
36
+ virtualHost: true,
37
+ styleIsolation: 'shared'
38
+ }
39
+ }
40
+ </script>
41
+
42
+ <style lang="scss" scoped>
43
+ .u-loading {
44
+ display: inline-flex;
45
+ align-items: center;
46
+ gap: $--spacing-sm;
47
+
48
+ &--vertical {
49
+ flex-direction: column;
50
+ }
51
+
52
+ &__spinner {
53
+ position: relative;
54
+ display: inline-block;
55
+ }
56
+
57
+ &__line {
58
+ position: absolute;
59
+ top: 0;
60
+ left: 50%;
61
+ width: 2px;
62
+ height: 25%;
63
+ margin-left: -1px;
64
+ border-radius: 1px;
65
+ transform-origin: center 200%;
66
+ opacity: 0.2;
67
+
68
+ @for $i from 1 through 12 {
69
+ &:nth-child(#{$i}) {
70
+ opacity: 0.2 + ($i - 1) * 0.06;
71
+ }
72
+ }
73
+ }
74
+
75
+ &__text {
76
+ font-size: $--font-size-sm;
77
+ line-height: 1.5;
78
+ }
79
+ }
80
+ </style>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <view v-if="visible" class="u-loading-page">
3
+ <view class="u-loading-page__content">
4
+ <view class="u-loading-page__spinner" :style="{ width: size + 'px', height: size + 'px' }">
5
+ <view
6
+ v-for="i in 12"
7
+ :key="i"
8
+ class="u-loading-page__line"
9
+ :style="{
10
+ transform: `rotate(${i * 30}deg)`,
11
+ backgroundColor: color
12
+ }"
13
+ />
14
+ </view>
15
+ <text v-if="text" class="u-loading-page__text" :style="{ color: textColor || color }">{{ text }}</text>
16
+ </view>
17
+ </view>
18
+ </template>
19
+
20
+ <script setup lang="ts">
21
+ interface Props {
22
+ visible?: boolean
23
+ text?: string
24
+ color?: string
25
+ textColor?: string
26
+ size?: number | string
27
+ }
28
+
29
+ withDefaults(defineProps<Props>(), {
30
+ visible: false,
31
+ text: '加载中...',
32
+ color: '#1989fa',
33
+ size: 40
34
+ })
35
+ </script>
36
+
37
+ <script lang="ts">
38
+ export default {
39
+ options: {
40
+ virtualHost: true,
41
+ styleIsolation: 'shared'
42
+ }
43
+ }
44
+ </script>
45
+
46
+ <style lang="scss" scoped>
47
+ .u-loading-page {
48
+ position: fixed;
49
+ top: 0;
50
+ left: 0;
51
+ right: 0;
52
+ bottom: 0;
53
+ z-index: 999;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ background-color: $--bg-color-2;
58
+
59
+ &__content {
60
+ display: flex;
61
+ flex-direction: column;
62
+ align-items: center;
63
+ gap: $--spacing-md;
64
+ }
65
+
66
+ &__spinner {
67
+ position: relative;
68
+ display: inline-block;
69
+ }
70
+
71
+ &__line {
72
+ position: absolute;
73
+ top: 0;
74
+ left: 50%;
75
+ width: 3px;
76
+ height: 25%;
77
+ margin-left: -1.5px;
78
+ border-radius: 2px;
79
+ transform-origin: center 200%;
80
+ opacity: 0.2;
81
+
82
+ @for $i from 1 through 12 {
83
+ &:nth-child(#{$i}) {
84
+ opacity: 0.2 + ($i - 1) * 0.06;
85
+ }
86
+ }
87
+ }
88
+
89
+ &__text {
90
+ font-size: $--font-size-md;
91
+ line-height: 1.5;
92
+ }
93
+ }
94
+ </style>
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <view v-if="visible" class="u-modal" @click="handleMaskClick">
3
+ <view class="u-modal__container" @click.stop>
4
+ <view v-if="title" class="u-modal__header">
5
+ <text class="u-modal__title">{{ title }}</text>
6
+ </view>
7
+
8
+ <view class="u-modal__body">
9
+ <slot>
10
+ <text class="u-modal__message">{{ message }}</text>
11
+ </slot>
12
+ </view>
13
+
14
+ <view class="u-modal__footer">
15
+ <view
16
+ v-if="showCancel"
17
+ class="u-modal__button u-modal__button--cancel"
18
+ @click="handleCancel"
19
+ >
20
+ <text>{{ cancelText }}</text>
21
+ </view>
22
+ <view
23
+ class="u-modal__button u-modal__button--confirm"
24
+ @click="handleConfirm"
25
+ >
26
+ <text>{{ confirmText }}</text>
27
+ </view>
28
+ </view>
29
+ </view>
30
+ </view>
31
+ </template>
32
+
33
+ <script setup lang="ts">
34
+ interface Props {
35
+ visible?: boolean
36
+ title?: string
37
+ message?: string
38
+ showCancel?: boolean
39
+ cancelText?: string
40
+ confirmText?: string
41
+ closeOnClickOverlay?: boolean
42
+ }
43
+
44
+ const props = withDefaults(defineProps<Props>(), {
45
+ visible: false,
46
+ title: '',
47
+ message: '',
48
+ showCancel: true,
49
+ cancelText: '取消',
50
+ confirmText: '确定',
51
+ closeOnClickOverlay: false
52
+ })
53
+
54
+ const emit = defineEmits<{
55
+ 'update:visible': [value: boolean]
56
+ cancel: []
57
+ confirm: []
58
+ }>()
59
+
60
+ const handleMaskClick = () => {
61
+ if (props.closeOnClickOverlay) {
62
+ emit('update:visible', false)
63
+ }
64
+ }
65
+
66
+ const handleCancel = () => {
67
+ emit('update:visible', false)
68
+ emit('cancel')
69
+ }
70
+
71
+ const handleConfirm = () => {
72
+ emit('update:visible', false)
73
+ emit('confirm')
74
+ }
75
+ </script>
76
+
77
+ <script lang="ts">
78
+ export default {
79
+ options: {
80
+ virtualHost: true,
81
+ styleIsolation: 'shared'
82
+ }
83
+ }
84
+ </script>
85
+
86
+ <style lang="scss" scoped>
87
+ .u-modal {
88
+ position: fixed;
89
+ top: 0;
90
+ left: 0;
91
+ right: 0;
92
+ bottom: 0;
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: center;
96
+ background-color: rgba(0, 0, 0, 0.5);
97
+ z-index: 999;
98
+
99
+ &__container {
100
+ width: 280px;
101
+ background-color: $--bg-color-2;
102
+ border-radius: $--border-radius-lg;
103
+ overflow: hidden;
104
+ }
105
+
106
+ &__header {
107
+ padding: $--spacing-lg $--spacing-lg $--spacing-sm;
108
+ text-align: center;
109
+ }
110
+
111
+ &__title {
112
+ font-size: $--font-size-lg;
113
+ font-weight: 600;
114
+ color: $--text-color;
115
+ }
116
+
117
+ &__body {
118
+ padding: $--spacing-md $--spacing-lg $--spacing-lg;
119
+ text-align: center;
120
+ max-height: 300px;
121
+ overflow-y: auto;
122
+ }
123
+
124
+ &__message {
125
+ font-size: $--font-size-md;
126
+ color: $--text-color-2;
127
+ line-height: 1.5;
128
+ }
129
+
130
+ &__footer {
131
+ display: flex;
132
+ border-top: 1px solid $--border-color;
133
+ }
134
+
135
+ &__button {
136
+ flex: 1;
137
+ height: 48px;
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ font-size: $--font-size-md;
142
+ transition: background-color $--transition-duration;
143
+
144
+ &:active {
145
+ background-color: $--bg-color;
146
+ }
147
+
148
+ &--cancel {
149
+ color: $--text-color-2;
150
+ border-right: 1px solid $--border-color;
151
+ }
152
+
153
+ &--confirm {
154
+ color: $--color-primary;
155
+ font-weight: 500;
156
+ }
157
+ }
158
+ }
159
+ </style>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <view class="u-notice-bar" :class="{ 'u-notice-bar--wrapable': wrapable }" :style="{ color, background: background }">
3
+ <view v-if="$slots.leftIcon || leftIcon" class="u-notice-bar__left-icon">
4
+ <slot name="leftIcon">
5
+ <text>{{ leftIcon }}</text>
6
+ </slot>
7
+ </view>
8
+ <view class="u-notice-bar__content" :class="{ 'u-notice-bar__content--scrollable': scrollable }">
9
+ <view
10
+ v-if="scrollable"
11
+ class="u-notice-bar__text"
12
+ :style="{ animationDuration: speed + 's' }"
13
+ >
14
+ {{ text }}
15
+ </view>
16
+ <text v-else class="u-notice-bar__text">{{ text }}</text>
17
+ </view>
18
+ <view v-if="$slots.rightIcon || rightIcon" class="u-notice-bar__right-icon" @click="handleRightIconClick">
19
+ <slot name="rightIcon">
20
+ <text>{{ rightIcon }}</text>
21
+ </slot>
22
+ </view>
23
+ </view>
24
+ </template>
25
+
26
+ <script setup lang="ts">
27
+ interface Props {
28
+ text: string
29
+ color?: string
30
+ background?: string
31
+ leftIcon?: string
32
+ rightIcon?: string
33
+ scrollable?: boolean
34
+ speed?: number
35
+ wrapable?: boolean
36
+ }
37
+
38
+ withDefaults(defineProps<Props>(), {
39
+ color: '#ed6a0c',
40
+ background: '#fffbe8',
41
+ scrollable: false,
42
+ speed: 10,
43
+ wrapable: false
44
+ })
45
+
46
+ const emit = defineEmits<{
47
+ 'right-icon-click': []
48
+ }>()
49
+
50
+ const handleRightIconClick = () => {
51
+ emit('right-icon-click')
52
+ }
53
+ </script>
54
+
55
+ <script lang="ts">
56
+ export default {
57
+ options: {
58
+ virtualHost: true,
59
+ styleIsolation: 'shared'
60
+ }
61
+ }
62
+ </script>
63
+
64
+ <style lang="scss" scoped>
65
+ .u-notice-bar {
66
+ display: flex;
67
+ align-items: center;
68
+ padding: $--spacing-md $--spacing-lg;
69
+ font-size: $--font-size-sm;
70
+ line-height: 24px;
71
+
72
+ &--wrapable {
73
+ flex-wrap: wrap;
74
+ padding: $--spacing-md $--spacing-lg;
75
+ }
76
+
77
+ &__content {
78
+ flex: 1;
79
+ overflow: hidden;
80
+ position: relative;
81
+
82
+ &--scrollable {
83
+ overflow: hidden;
84
+ white-space: nowrap;
85
+ }
86
+ }
87
+
88
+ &__text {
89
+ display: inline-block;
90
+
91
+ .u-notice-bar__content--scrollable & {
92
+ animation: u-notice-bar-scroll linear infinite;
93
+ }
94
+ }
95
+
96
+ &__left-icon {
97
+ margin-right: $--spacing-sm;
98
+ }
99
+
100
+ &__right-icon {
101
+ margin-left: $--spacing-sm;
102
+ }
103
+ }
104
+
105
+ @keyframes u-notice-bar-scroll {
106
+ 0% {
107
+ transform: translateX(100%);
108
+ }
109
+ 100% {
110
+ transform: translateX(-100%);
111
+ }
112
+ }
113
+ </style>