nubomed-ui 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. package/.env.bi +13 -0
  2. package/.env.terminal +13 -0
  3. package/.vscode/extensions.json +3 -0
  4. package/README.md +17 -0
  5. package/index.html +13 -0
  6. package/nubomed-ui/nubomed-ui.es.js +2005 -0
  7. package/nubomed-ui/nubomed-ui.umd.js +1 -0
  8. package/nubomed-ui/style.css +1 -0
  9. package/package.json +19 -7
  10. package/src/App.vue +31 -0
  11. package/src/bi-demos/Header.vue +29 -0
  12. package/src/bi-demos/Table.vue +69 -0
  13. package/src/bi-demos/index.vue +132 -0
  14. package/src/bi-packages/components/Box/images/corner-error.png +0 -0
  15. package/src/bi-packages/components/Box/images/corner-warning.png +0 -0
  16. package/src/bi-packages/components/Box/images/corner.png +0 -0
  17. package/src/bi-packages/components/Box/index.scss +86 -0
  18. package/src/bi-packages/components/Box/index.vue +53 -0
  19. package/src/bi-packages/components/Carousel/CarouselItem.vue +0 -0
  20. package/src/bi-packages/components/Carousel/index.vue +0 -0
  21. package/src/bi-packages/components/Header/images/left-bg.png +0 -0
  22. package/src/bi-packages/components/Header/images/logo.png +0 -0
  23. package/src/bi-packages/components/Header/images/right-bg.png +0 -0
  24. package/src/bi-packages/components/Header/index.scss +50 -0
  25. package/src/bi-packages/components/Header/index.vue +54 -0
  26. package/src/bi-packages/components/Table/TableColgroup.vue +43 -0
  27. package/src/bi-packages/components/Table/index copy.vue +107 -0
  28. package/src/bi-packages/components/Table/index.scss +118 -0
  29. package/src/bi-packages/components/Table/index.vue +108 -0
  30. package/src/bi-packages/components/TableColumn/index.scss +7 -0
  31. package/src/bi-packages/components/TableColumn/index.vue +60 -0
  32. package/src/bi-packages/fonts/OPPOSans-B.ttf +0 -0
  33. package/src/bi-packages/fonts/OPPOSans-M.ttf +0 -0
  34. package/src/bi-packages/fonts/font.scss +11 -0
  35. package/src/bi-packages/iconfont-svg/demo.css +539 -0
  36. package/src/bi-packages/iconfont-svg/demo_index.html +4811 -0
  37. package/src/bi-packages/iconfont-svg/iconfont.css +819 -0
  38. package/src/bi-packages/iconfont-svg/iconfont.js +1 -0
  39. package/src/bi-packages/iconfont-svg/iconfont.json +1416 -0
  40. package/src/bi-packages/iconfont-svg/iconfont.ttf +0 -0
  41. package/src/bi-packages/iconfont-svg/iconfont.woff +0 -0
  42. package/src/bi-packages/iconfont-svg/iconfont.woff2 +0 -0
  43. package/src/bi-packages/index.js +34 -0
  44. package/src/bi-packages/styles/mixin.scss +12 -0
  45. package/src/bi-packages/styles/var.scss +11 -0
  46. package/src/demos/ActionBar.vue +59 -0
  47. package/src/demos/Badge.vue +28 -0
  48. package/src/demos/Button copy.vue +302 -0
  49. package/src/demos/Button.vue +116 -0
  50. package/src/demos/ButtonGroup.vue +40 -0
  51. package/src/demos/Check.vue +29 -0
  52. package/src/demos/Dialog.vue +255 -0
  53. package/src/demos/Empty.vue +38 -0
  54. package/src/demos/FooterMenu.vue +49 -0
  55. package/src/demos/Header.vue +71 -0
  56. package/src/demos/Icons.vue +314 -0
  57. package/src/demos/Input.vue +87 -0
  58. package/src/demos/InputKeyboard.vue +30 -0
  59. package/src/demos/InputNumber.vue +34 -0
  60. package/src/demos/LeftMenu.vue +128 -0
  61. package/src/demos/Menus.vue +106 -0
  62. package/src/demos/OpenCabinetBall.vue +37 -0
  63. package/src/demos/Statusbar.vue +146 -0
  64. package/src/demos/Steps.vue +45 -0
  65. package/src/demos/Tost.vue +35 -0
  66. package/src/demos/button/button.md +19 -0
  67. package/src/demos/data/terList.json +145 -0
  68. package/src/demos/images/cabinets/H3000-D.png +0 -0
  69. package/src/demos/images/cabinets/H3000-R.png +0 -0
  70. package/src/demos/images/cabinets/H3000-Rh.png +0 -0
  71. package/src/demos/images/cabinets/H3000-Rh2.png +0 -0
  72. package/src/demos/images/cabinets/H3010-R.png +0 -0
  73. package/src/demos/index.vue +348 -0
  74. package/src/docs/icons/Icon.vue +72 -0
  75. package/src/docs/icons/icon.md +21 -0
  76. package/src/docs/index.html +15 -0
  77. package/src/docs/index.vue +301 -0
  78. package/src/main.js +23 -0
  79. package/src/packages/components/ActionBar/images/error.png +0 -0
  80. package/src/packages/components/ActionBar/images/loading.gif +0 -0
  81. package/src/packages/components/ActionBar/images/success.png +0 -0
  82. package/src/packages/components/ActionBar/images/warning.png +0 -0
  83. package/src/packages/components/ActionBar/images/warning_yellow.png +0 -0
  84. package/src/packages/components/ActionBar/index.scss +81 -0
  85. package/src/packages/components/ActionBar/index.vue +100 -0
  86. package/src/packages/components/Badge/index.scss +50 -0
  87. package/src/packages/components/Badge/index.vue +75 -0
  88. package/src/packages/components/Button/index.scss +241 -0
  89. package/src/packages/components/Button/index.vue +111 -0
  90. package/src/packages/components/ButtonGroup/index.scss +54 -0
  91. package/src/packages/components/ButtonGroup/index.vue +75 -0
  92. package/src/packages/components/Check/Cate.vue +138 -0
  93. package/src/packages/components/Check/index.scss +47 -0
  94. package/src/packages/components/Check/index.vue +105 -0
  95. package/src/packages/components/Dialog/images/error.png +0 -0
  96. package/src/packages/components/Dialog/images/success.png +0 -0
  97. package/src/packages/components/Dialog/images/warning-red.png +0 -0
  98. package/src/packages/components/Dialog/images/warning-yellow.png +0 -0
  99. package/src/packages/components/Dialog/index.scss +154 -0
  100. package/src/packages/components/Dialog/index.vue +305 -0
  101. package/src/packages/components/Empty/images/empty-abnormal.png +0 -0
  102. package/src/packages/components/Empty/images/empty-data.png +0 -0
  103. package/src/packages/components/Empty/images/empty-search.png +0 -0
  104. package/src/packages/components/Empty/index.vue +68 -0
  105. package/src/packages/components/Form/FormItem.vue +73 -0
  106. package/src/packages/components/Form/index.vue +76 -0
  107. package/src/packages/components/Icon/index.vue +30 -0
  108. package/src/packages/components/Input/index.scss +184 -0
  109. package/src/packages/components/Input/index.vue +189 -0
  110. package/src/packages/components/InputKeyboard/index.scss +63 -0
  111. package/src/packages/components/InputKeyboard/index.vue +117 -0
  112. package/src/packages/components/InputNumber/index.scss +103 -0
  113. package/src/packages/components/InputNumber/index.vue +160 -0
  114. package/src/packages/components/Menu/index.scss +559 -0
  115. package/src/packages/components/Menu/index.vue +211 -0
  116. package/src/packages/components/OpenCabinetBall/CabinetStatus.vue +94 -0
  117. package/src/packages/components/OpenCabinetBall/index.scss +204 -0
  118. package/src/packages/components/OpenCabinetBall/index.vue +113 -0
  119. package/src/packages/components/Statusbar/CabinetList.vue +125 -0
  120. package/src/packages/components/Statusbar/CabinetListStatus.vue +75 -0
  121. package/src/packages/components/Statusbar/CabinetListTempHum.vue +108 -0
  122. package/src/packages/components/Statusbar/index.scss +205 -0
  123. package/src/packages/components/Statusbar/index.vue +83 -0
  124. package/src/packages/components/Steps/index.scss +104 -0
  125. package/src/packages/components/Steps/index.vue +66 -0
  126. package/src/packages/components/SvgIcon/index.vue +41 -0
  127. package/src/packages/components/Toast/index.vue +72 -0
  128. package/src/packages/fonts/OPPOSans-B.ttf +0 -0
  129. package/src/packages/fonts/OPPOSans-M.ttf +0 -0
  130. package/src/packages/fonts/font.scss +11 -0
  131. package/src/packages/iconfont-svg/demo.css +539 -0
  132. package/src/packages/iconfont-svg/demo_index.html +4811 -0
  133. package/src/packages/iconfont-svg/iconfont.css +819 -0
  134. package/src/packages/iconfont-svg/iconfont.js +1 -0
  135. package/src/packages/iconfont-svg/iconfont.json +1416 -0
  136. package/src/packages/iconfont-svg/iconfont.ttf +0 -0
  137. package/src/packages/iconfont-svg/iconfont.woff +0 -0
  138. package/src/packages/iconfont-svg/iconfont.woff2 +0 -0
  139. package/src/packages/index.js +64 -0
  140. package/src/packages/styles/var.scss +24 -0
  141. package/src/utils/create.js +48 -0
  142. package/src/utils/index.js +13 -0
  143. package/src/utils/validate.js +3 -0
  144. package/vite.config.js +47 -0
  145. package/nubomed-ui.es.js +0 -152
  146. package/nubomed-ui.umd.js +0 -1
  147. package/style.css +0 -1
@@ -0,0 +1,301 @@
1
+ <template>
2
+ <div class="container">
3
+ <div class="container-header"></div>
4
+ <div class="container">
5
+ <div class="container-aside">
6
+ <div class="menu">
7
+ <div v-for="item in navList" :key="item.text" class="menu__group">
8
+ <p class="menu__group__text">{{ item.text }}</p>
9
+ <div
10
+ v-for="(child, index) in item.children"
11
+ :key="index"
12
+ class="menu__group__child"
13
+ :class="
14
+ active.text === child.text ? 'menu__group__child--active' : ''
15
+ "
16
+ >
17
+ {{ child.text }}
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ <div class="container-main">
23
+ <component :is="active.component"></component>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </template>
28
+
29
+ <script setup>
30
+ import { ref, nextTick } from 'vue'
31
+ import Icons from '../demos/Icons.vue'
32
+ import Button from '../demos/Button.vue'
33
+
34
+ const navList = ref([])
35
+ navList.value.push({
36
+ text: '基础组件',
37
+ children: [
38
+ {
39
+ text: '图标',
40
+ id: 'Icons',
41
+ component: Icons
42
+ },
43
+ {
44
+ text: '按钮',
45
+ id: 'Button',
46
+ component: Button
47
+ }
48
+ ]
49
+ })
50
+ navList.value.push({
51
+ text: '表单组件',
52
+ children: [
53
+ { text: 'Input 输入框', id: 'Input' },
54
+ { text: 'Input Number 数字器', id: 'InputNumber' },
55
+ { text: '多选按钮', id: 'ButtonGroup' },
56
+ { text: '下拉框', id: '' },
57
+ { text: '开关', id: '' },
58
+ { text: '日期选择器', id: '' },
59
+ { text: '时间选择器', id: '' }
60
+ ]
61
+ })
62
+ navList.value.push({
63
+ text: '数据展示',
64
+ children: [
65
+ { text: 'Badge 徽章', id: 'Badge' },
66
+ { text: 'Empty 空状态', id: 'Empty' },
67
+ { text: 'Steps 步骤条', id: 'Steps' },
68
+ { text: '走马灯', id: '' },
69
+ { text: '分页', id: '' },
70
+ { text: '进度条', id: '' },
71
+ { text: '表格', id: '' },
72
+ { text: '时间线', id: '' }
73
+ ]
74
+ })
75
+ navList.value.push({
76
+ text: '导航',
77
+ children: [
78
+ { text: '标题栏', id: 'Header' },
79
+ { text: '底部导航', id: 'FooterMenu' },
80
+ { text: '侧边栏', id: 'LeftMenu' },
81
+ { text: '宫格菜单', id: 'Menus' },
82
+ { text: '下拉菜单', id: '' }
83
+ ]
84
+ })
85
+ navList.value.push({
86
+ text: '反馈组件',
87
+ children: [
88
+ { text: 'Dialog 对话框', id: 'Dialog' },
89
+ { text: 'Loading 加载', id: '' },
90
+ { text: 'Tost 提示', id: 'Tost' },
91
+ { text: 'Message 消息弹框', id: '' },
92
+ { text: 'Popover 气泡卡片', id: '' },
93
+ { text: 'Tooltip 文字提示', id: '' }
94
+ ]
95
+ })
96
+
97
+ navList.value.push({
98
+ text: '键盘',
99
+ children: [
100
+ { text: '输入框键盘', id: 'InputKeyboard' },
101
+ { text: '通用键盘', id: '' }
102
+ ]
103
+ })
104
+
105
+ navList.value.push({
106
+ text: '业务组件',
107
+ children: [
108
+ { text: '状态栏', id: 'Statusbar' },
109
+ { text: '动作栏', id: 'ActionBar' },
110
+ { text: '检测页', id: 'CheckPage' },
111
+ { text: '开柜浮球', id: 'OpenCabinetBall' }
112
+ ]
113
+ })
114
+
115
+ const active = ref(navList.value[0].children[1])
116
+
117
+ const handleRef = (id) => {
118
+ nextTick(() => {
119
+ const returnEle = document.querySelector('#' + id) // 将要跳转区域的id
120
+ if (returnEle) {
121
+ returnEle.scrollIntoView({
122
+ behavior: 'smooth',
123
+ block: 'start',
124
+ inline: 'nearest'
125
+ }) // true 是默认的
126
+ }
127
+ })
128
+ }
129
+ </script>
130
+
131
+ <style lang="scss">
132
+ .container {
133
+ width: 100%;
134
+ height: 100%;
135
+ overflow: hidden;
136
+ display: flex;
137
+ flex-direction: column;
138
+ .container-header {
139
+ height: 60px;
140
+ border-bottom: 1px solid #dcdfe6;
141
+ }
142
+ .container {
143
+ width: 100%;
144
+ flex: 1;
145
+ display: flex;
146
+ flex-direction: row;
147
+ overflow: hidden;
148
+ .container-aside {
149
+ width: 200px;
150
+ height: 100%;
151
+ overflow: auto;
152
+ border-right: 1px solid #dcdfe6;
153
+ }
154
+ .container-main {
155
+ flex: 1;
156
+ height: 100%;
157
+ overflow: hidden;
158
+ }
159
+ }
160
+ }
161
+
162
+ .menu {
163
+ margin: 0 20px;
164
+ &__group {
165
+ margin-bottom: 15px;
166
+ &__text {
167
+ font-size: 16px;
168
+ line-height: 28px;
169
+ }
170
+ &__child {
171
+ font-size: 14px;
172
+ line-height: 40px;
173
+ border-radius: 10px;
174
+ padding: 0 15px;
175
+ cursor: pointer;
176
+ &--active {
177
+ background-color: rgba(#79bbff, 0.1);
178
+ color: #79bbff;
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ .component {
185
+ width: 100%;
186
+ height: 100%;
187
+ box-sizing: border-box;
188
+ display: flex;
189
+ overflow: hidden;
190
+ &__left {
191
+ flex: 1;
192
+ height: 100%;
193
+ overflow: auto;
194
+ padding: 30px;
195
+ box-sizing: border-box;
196
+ }
197
+ &__right {
198
+ width: 180px;
199
+ height: 100%;
200
+ overflow: auto;
201
+ padding: 30px;
202
+ box-sizing: border-box;
203
+ }
204
+ &__title {
205
+ font-size: 36px;
206
+ font-weight: 700;
207
+ line-height: 56px;
208
+ }
209
+ &__intro {
210
+ font-size: 14px;
211
+ line-height: 28px;
212
+ }
213
+ &__detail {
214
+ &__title {
215
+ font-size: 18px;
216
+ font-weight: 700;
217
+ line-height: 36px;
218
+ }
219
+ &__intro {
220
+ font-size: 14px;
221
+ line-height: 28px;
222
+ }
223
+ &__box {
224
+ border: 1px solid #dcdfe6;
225
+ border-radius: 5px;
226
+ }
227
+ &__demo {
228
+ padding: 15px;
229
+ border-bottom: 1px solid #dcdfe6;
230
+ }
231
+ &__toggle {
232
+ padding: 15px;
233
+ border-bottom: 1px solid #dcdfe6;
234
+ text-align: right;
235
+ }
236
+ &__code {
237
+ background-color: #f0f2f5;
238
+ padding: 15px;
239
+ }
240
+ }
241
+ }
242
+
243
+ .table{
244
+ width: 100%;
245
+ td, th{
246
+ text-align: left;border: 1px solid #cad0e0;font-size: 16px;line-height: 24px;padding: 5px 12px;
247
+ }
248
+ }
249
+
250
+ .demo {
251
+ width: 100%;
252
+ height: 100%;
253
+ overflow: auto;
254
+ background-color: #f3f7fd;
255
+ padding-top: 150px;
256
+ }
257
+ .demo-nav {
258
+ padding: 10px 30px;
259
+ position: fixed;
260
+ top: 0;
261
+ left: 0;
262
+ right: 0;
263
+ min-height: 40px;
264
+ line-height: 40px;
265
+ background-color: #ffffff;
266
+ z-index: 1;
267
+ box-shadow: 0px -1px 6px 0px rgba(0, 0, 0, 0.15);
268
+ div {
269
+ display: inline-block;
270
+ margin-right: 20px;
271
+ }
272
+ strong {
273
+ font-size: 24px;
274
+ }
275
+ span {
276
+ margin-left: 10px;
277
+ font-size: 20px;
278
+ cursor: pointer;
279
+ }
280
+ }
281
+ .demo-box {
282
+ background-color: #ffffff;
283
+ }
284
+ .demo-box-title {
285
+ border-bottom: 1px solid #cad0e0;
286
+ padding-bottom: 20px;
287
+ margin-bottom: 20px;
288
+ .demo-box-title-name {
289
+ height: 76px;
290
+ font-size: 50px;
291
+ line-height: 76px;
292
+ }
293
+ .demo-box-title-desc {
294
+ height: 32px;
295
+ font-size: 24px;
296
+ color: #f98900;
297
+ line-height: 32px;
298
+ margin-left: 20px;
299
+ }
300
+ }
301
+ </style>
package/src/main.js ADDED
@@ -0,0 +1,23 @@
1
+ /*
2
+ * @Author: chenghuan.dong
3
+ * @Date: 2023-06-27 16:24:35
4
+ * @LastEditors: chenghuan.dong
5
+ * @LastEditTime: 2023-09-12 18:38:40
6
+ * @Description:
7
+ */
8
+ import { createApp } from 'vue'
9
+ import App from './App.vue'
10
+
11
+ const app = createApp(App)
12
+
13
+ import NuboMedUI from './packages' //导入
14
+ app.use(NuboMedUI)
15
+
16
+ // import NuboMedUIBI from './bi-packages' //导入
17
+ // app.use(NuboMedUIBI)
18
+
19
+ // svg图标
20
+ import SvgIcon from './packages/components/SvgIcon/index.vue'
21
+ app.component('SvgIcon', SvgIcon)
22
+
23
+ app.mount('#app')
@@ -0,0 +1,81 @@
1
+ :root {
2
+ // 通用
3
+ --nb-action-bar-height: 112px;
4
+ }
5
+
6
+ .nb-action-bar {
7
+ position: relative;
8
+ width: 100%;
9
+ height: var(--nb-action-bar-height);
10
+ background: #ffffff;
11
+ box-shadow: 0px 4px 40px 0px rgba(24, 29, 65, 0.08), 0px 2px 28px 0px rgba(24, 29, 65, 0.1),
12
+ 0px 0px 10px 0px rgba(24, 29, 65, 0.08);
13
+ border-radius: 16px;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ padding: 0 32px;
18
+ box-sizing: border-box;
19
+ &__left {
20
+ display: flex;
21
+ align-items: center;
22
+ img {
23
+ width: 80px;
24
+ height: 80px;
25
+ margin-right: 20px;
26
+ }
27
+ span {
28
+ font-size: 28px;
29
+ line-height: 42px;
30
+ }
31
+ }
32
+ &__right {
33
+ display: flex;
34
+ align-items: center;
35
+ .nb-button + .nb-button {
36
+ margin-left: 24px;
37
+ }
38
+ }
39
+ &--loading {
40
+ .nb-action-bar__left span {
41
+ strong {
42
+ font-size: 36px;
43
+ font-family: var(--nb-font-bold-family);
44
+ font-weight: normal;
45
+ color: #00a572;
46
+ line-height: 54px;
47
+ margin-left: 4px;
48
+ }
49
+ }
50
+ }
51
+ &--abnormal {
52
+ .nb-action-bar__left span {
53
+ font-size: 32px;
54
+ font-family: var(--nb-font-bold-family);
55
+ color: var(--nb-abnormal-color);
56
+ line-height: 50px;
57
+ }
58
+ }
59
+ &--success {
60
+ .nb-action-bar__left span {
61
+ color: var(--nb-font-color-7);
62
+ display: flex;
63
+ align-items: center;
64
+ strong {
65
+ font-size: 36px;
66
+ font-family: OPPOSans-B, OPPOSans;
67
+ font-weight: normal;
68
+ color: #00a572;
69
+ line-height: 54px;
70
+ margin-left: 4px;
71
+ }
72
+ }
73
+ }
74
+ &--fixed {
75
+ position: fixed;
76
+ bottom: 30px;
77
+ left: 30px;
78
+ right: 30px;
79
+ width: auto;
80
+ }
81
+ }
@@ -0,0 +1,100 @@
1
+ <!--
2
+ * @Author: chenghuan.dong
3
+ * @Date: 2023-06-29 15:15:27
4
+ * @LastEditors: chenghuan.dong
5
+ * @LastEditTime: 2023-07-24 18:13:22
6
+ * @Description: 检测动作栏
7
+ -->
8
+ <template>
9
+ <div class="nb-action-bar" :class="classes">
10
+ <!-- 检测中 -->
11
+ <div v-if="loading" class="nb-action-bar__left">
12
+ <slot name="loading">
13
+ <img src="./images/loading.gif" />
14
+ <span>{{ loadingText }}</span>
15
+ </slot>
16
+ </div>
17
+ <!-- 检测异常 -->
18
+ <div v-if="abnormal" class="nb-action-bar__left">
19
+ <slot name="abnormal">
20
+ <img src="./images/warning.png" />
21
+ <span>{{ abnormalText }}</span>
22
+ </slot>
23
+ </div>
24
+ <!-- 检测正常 -->
25
+ <div v-if="success" class="nb-action-bar__left">
26
+ <slot name="success">
27
+ <img src="./images/success.png" />
28
+ <span v-html="successText"></span>
29
+ </slot>
30
+ </div>
31
+
32
+ <!-- 右侧显示按钮 -->
33
+ <div class="nb-action-bar__right">
34
+ <slot>
35
+ </slot>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <script setup>
41
+ import { createNamespace } from '../../../utils/create.js'
42
+
43
+ defineOptions({
44
+ name: 'NbActionBar'
45
+ })
46
+
47
+ const props = defineProps({
48
+ // 是否定位fixed
49
+ fixed: {
50
+ type: Boolean,
51
+ default: true
52
+ },
53
+ // 检测中
54
+ loading: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ // 检测中的提示语
59
+ loadingText: {
60
+ type: String,
61
+ default: ''
62
+ },
63
+ // 是否异常
64
+ abnormal: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ // 异常提示语
69
+ abnormalText: {
70
+ type: String,
71
+ default: ''
72
+ },
73
+ // 是否正常
74
+ success: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ // 正常的提示语
79
+ successText: {
80
+ type: String,
81
+ default: ''
82
+ }
83
+ })
84
+
85
+ const [name, bem] = createNamespace('action-bar')
86
+
87
+ // 样式
88
+ const classes = bem([
89
+ {
90
+ fixed: props.fixed,
91
+ loading: props.loading,
92
+ abnormal: props.abnormal,
93
+ success: props.success
94
+ }
95
+ ])
96
+ </script>
97
+
98
+ <style lang="scss">
99
+ @import './index.scss';
100
+ </style>
@@ -0,0 +1,50 @@
1
+ :root {
2
+ // 通用
3
+ --nb-badge-border-radius: 16px;
4
+ --nb-badge-font-size: 24px;
5
+ --nb-badge-color: #ffffff;
6
+ --nb-badge-height: 32px;
7
+ --nb-badge-bg-color: var(--nb-abnormal-color);
8
+ }
9
+
10
+ .nb-badge {
11
+ position: relative;
12
+ vertical-align: middle;
13
+ display: inline-block;
14
+ width: fit-content;
15
+
16
+ &__content {
17
+ display: inline-flex;
18
+ justify-content: center;
19
+ align-items: center;
20
+
21
+ height: var(--nb-badge-height);
22
+ min-width: var(--nb-badge-height);
23
+ padding: 0 4px;
24
+
25
+ background-color: var(--nb-badge-bg-color);
26
+ border-radius: var(--nb-badge-border-radius);
27
+ color: var(--nb-badge-color);
28
+ font-size: var(--nb-badge-font-size);
29
+ line-height: var(--nb-badge-height);
30
+ white-space: nowrap;
31
+
32
+ &--fixed {
33
+ position: absolute;
34
+ top: 0;
35
+ right: calc(1px + #{var(--nb-badge-font-size)} / 2);
36
+ transform: translateY(-50%) translateX(100%);
37
+ &.nb-badge__content--dot{
38
+ right: 5px;
39
+ }
40
+ }
41
+ &--dot {
42
+ height: 10px;
43
+ width: 10px;
44
+ min-width: 0;
45
+ padding: 0;
46
+ right: 0;
47
+ border-radius: 50%;
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,75 @@
1
+ <!--
2
+ * @Author: chenghuan.dong
3
+ * @Date: 2023-06-29 15:15:27
4
+ * @LastEditors: chenghuan.dong
5
+ * @LastEditTime: 2023-06-29 18:25:27
6
+ * @Description: 徽章
7
+ -->
8
+ <template>
9
+ <div class="nb-badge">
10
+ <slot />
11
+ <sup v-show="!hidden && (content || isDot)" :class="classes" v-text="content" />
12
+ </div>
13
+ </template>
14
+
15
+ <script setup>
16
+ import { computed } from 'vue'
17
+ import { createNamespace } from '../../../utils/create.js'
18
+ import { isNumber } from '../../../utils/validate.js'
19
+
20
+ defineOptions({
21
+ name: 'NbBadge'
22
+ })
23
+
24
+ const props = defineProps({
25
+ // 显示值
26
+ value: {
27
+ type: [String, Number],
28
+ default: ''
29
+ },
30
+ // 最大值,超过最大值会显示 {max}+。 只有当 value 是数字类型时起作用。
31
+ max: {
32
+ type: [String, Number],
33
+ default: 99
34
+ },
35
+ // 是否隐藏 Badge。
36
+ hidden: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ // 是否显示小圆点。
41
+ isDot: {
42
+ type: Boolean,
43
+ default: false
44
+ }
45
+ })
46
+ const slots = defineSlots()
47
+
48
+ const [name, bem] = createNamespace('badge__content')
49
+
50
+ // 样式
51
+ const classes = bem([
52
+ {
53
+ fixed: !!slots.default,
54
+ dot: props.isDot
55
+ }
56
+ ])
57
+
58
+ // 显示内容
59
+ const content = computed(() => {
60
+ if (props.isDot) return ''
61
+
62
+ if (isNumber(props.value) && isNumber(props.max)) {
63
+ return props.max < props.value ? `${props.max}+` : `${props.value}`
64
+ }
65
+ return `${props.value}`
66
+ })
67
+
68
+ defineExpose({
69
+ content
70
+ })
71
+ </script>
72
+
73
+ <style lang="scss">
74
+ @import './index.scss';
75
+ </style>