@sugarat/theme 0.5.11 → 0.5.12-beta.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.
Files changed (49) hide show
  1. package/node.d.ts +2 -4
  2. package/node.js +206 -156
  3. package/node.mjs +205 -154
  4. package/package.json +10 -15
  5. package/src/components/Alert.vue +269 -0
  6. package/src/components/Avatar.vue +65 -0
  7. package/src/components/BlogAlert.vue +8 -8
  8. package/src/components/BlogApp.vue +5 -8
  9. package/src/components/BlogArticleAnalyze.vue +99 -66
  10. package/src/components/BlogAuthor.vue +13 -15
  11. package/src/components/BlogBackToTop.vue +21 -24
  12. package/src/components/BlogButtonAfterArticle.vue +12 -15
  13. package/src/components/BlogCommentWrapper.vue +34 -41
  14. package/src/components/BlogDocCover.vue +1 -1
  15. package/src/components/BlogFooter.vue +26 -32
  16. package/src/components/BlogFriendLink.vue +91 -73
  17. package/src/components/BlogHomeBanner.vue +25 -31
  18. package/src/components/BlogHomeHeaderAvatar.vue +16 -23
  19. package/src/components/BlogHomeInfo.vue +2 -4
  20. package/src/components/BlogHomeOverview.vue +12 -15
  21. package/src/components/BlogHomeTags.vue +22 -31
  22. package/src/components/BlogHotArticle.vue +69 -80
  23. package/src/components/BlogImagePreview.vue +3 -3
  24. package/src/components/BlogItem.vue +14 -23
  25. package/src/components/BlogList.vue +15 -19
  26. package/src/components/BlogRecommendArticle.vue +56 -72
  27. package/src/components/BlogSidebar.vue +1 -1
  28. package/src/components/Button.vue +150 -0
  29. package/src/components/Carousel.vue +249 -0
  30. package/src/components/CarouselItem.vue +139 -0
  31. package/src/components/CommentArtalk.vue +1 -1
  32. package/src/components/Image.vue +33 -0
  33. package/src/components/ImageViewer.vue +407 -0
  34. package/src/components/Pagination.vue +369 -0
  35. package/src/components/Tag.vue +144 -0
  36. package/src/components/UserWorks.vue +132 -175
  37. package/src/composables/config/blog.ts +6 -1
  38. package/src/composables/config/index.ts +2 -2
  39. package/src/index.ts +12 -19
  40. package/src/node.ts +0 -3
  41. package/src/styles/el-base.css +340 -0
  42. package/src/styles/{index.scss → index.css} +56 -91
  43. package/src/utils/client/index.ts +17 -0
  44. package/src/utils/node/mdPlugins.ts +1 -1
  45. package/src/utils/node/theme.ts +5 -2
  46. package/src/utils/node/vitePlugins.ts +51 -18
  47. package/src/styles/scss/algolia.scss +0 -231
  48. package/src/styles/scss/global.scss +0 -156
  49. package/src/styles/scss/highlight.scss +0 -12
@@ -0,0 +1,369 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref, watch } from 'vue'
3
+
4
+ const props = defineProps({
5
+ total: {
6
+ type: Number,
7
+ default: 0,
8
+ },
9
+ pageSize: {
10
+ type: Number,
11
+ default: 10,
12
+ },
13
+ currentPage: {
14
+ type: Number,
15
+ default: 1,
16
+ },
17
+ layout: {
18
+ type: String,
19
+ default: 'prev, pager, next, jumper',
20
+ },
21
+ background: {
22
+ type: Boolean,
23
+ default: false,
24
+ },
25
+ small: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
29
+ })
30
+
31
+ const emit = defineEmits(['update:current-page', 'currentChange'])
32
+
33
+ const innerCurrentPage = ref(props.currentPage)
34
+
35
+ watch(() => props.currentPage, (val) => {
36
+ innerCurrentPage.value = val
37
+ })
38
+
39
+ const pageCount = computed(() => {
40
+ const count = Math.ceil(props.total / props.pageSize)
41
+ return count > 0 ? count : 1
42
+ })
43
+
44
+ const pagers = computed(() => {
45
+ const count = pageCount.value
46
+ const current = innerCurrentPage.value
47
+ const pagerCount = 7 // Default Element Plus pager count
48
+
49
+ const showPrevMore = false
50
+ const showNextMore = false
51
+
52
+ if (count <= pagerCount) {
53
+ const array = []
54
+ for (let i = 1; i <= count; i++) {
55
+ array.push(i)
56
+ }
57
+ return array
58
+ }
59
+
60
+ // Logic for large number of pages
61
+ // Simplified logic for now, Element Plus logic is complex
62
+ // If we want exact replica, we need more logic.
63
+ // For now, let's implement a simpler version that shows current +/- 2 and first/last
64
+
65
+ const array: (number | string)[] = []
66
+
67
+ if (current <= 4) {
68
+ for (let i = 1; i <= 6; i++) {
69
+ array.push(i)
70
+ }
71
+ array.push('more-next') // ...
72
+ array.push(count)
73
+ }
74
+ else if (current >= count - 3) {
75
+ array.push(1)
76
+ array.push('more-prev') // ...
77
+ for (let i = count - 5; i <= count; i++) {
78
+ array.push(i)
79
+ }
80
+ }
81
+ else {
82
+ array.push(1)
83
+ array.push('more-prev') // ...
84
+ for (let i = current - 2; i <= current + 2; i++) {
85
+ array.push(i)
86
+ }
87
+ array.push('more-next') // ...
88
+ array.push(count)
89
+ }
90
+
91
+ return array
92
+ })
93
+
94
+ function handleCurrentChange(val: number) {
95
+ if (val < 1)
96
+ val = 1
97
+ if (val > pageCount.value)
98
+ val = pageCount.value
99
+
100
+ if (innerCurrentPage.value !== val) {
101
+ innerCurrentPage.value = val
102
+ emit('update:current-page', val)
103
+ emit('currentChange', val)
104
+ }
105
+ }
106
+
107
+ function prev() {
108
+ handleCurrentChange(innerCurrentPage.value - 1)
109
+ }
110
+
111
+ function next() {
112
+ handleCurrentChange(innerCurrentPage.value + 1)
113
+ }
114
+
115
+ function onPagerClick(page: number | string) {
116
+ if (typeof page === 'number') {
117
+ handleCurrentChange(page)
118
+ }
119
+ else {
120
+ const pagerCountOffset = 5
121
+ let newPage = innerCurrentPage.value
122
+ if (page === 'more-prev') {
123
+ newPage -= pagerCountOffset
124
+ }
125
+ else if (page === 'more-next') {
126
+ newPage += pagerCountOffset
127
+ }
128
+ handleCurrentChange(newPage)
129
+ }
130
+ }
131
+
132
+ // Jumper
133
+ function handleJumperChange(evt: Event) {
134
+ const target = evt.target as HTMLInputElement
135
+ const val = parseInt(target.value)
136
+ if (!isNaN(val)) {
137
+ handleCurrentChange(val)
138
+ target.value = '' // Clear or keep? Element Plus keeps it until blur/enter
139
+ }
140
+ }
141
+ </script>
142
+
143
+ <template>
144
+ <div class="sugar-pagination" :class="{ 'is-background': background, 'sugar-pagination--small': small }">
145
+ <!-- Prev -->
146
+ <button
147
+ type="button"
148
+ class="btn-prev"
149
+ :disabled="innerCurrentPage <= 1"
150
+ @click="prev"
151
+ >
152
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path fill="currentColor" d="M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z" /></svg>
153
+ </button>
154
+
155
+ <!-- Pager -->
156
+ <ul class="sugar-pager">
157
+ <li
158
+ v-for="(page, index) in pagers"
159
+ :key="index"
160
+ :class="{ 'is-active': innerCurrentPage === page, 'more': typeof page === 'string' }"
161
+ class="number"
162
+ @click="onPagerClick(page)"
163
+ >
164
+ <template v-if="typeof page === 'number'">
165
+ {{ page }}
166
+ </template>
167
+ <template v-else>
168
+ <svg v-if="page === 'more-prev'" class="icon-more" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path fill="currentColor" d="M529.408 149.376a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L259.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L197.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224zm256 0a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L515.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L453.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224z" /></svg>
169
+ <svg v-else-if="page === 'more-next'" class="icon-more" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1em" height="1em"><path fill="currentColor" d="M452.864 149.312a29.12 29.12 0 0 1 41.728.064L826.24 489.664a32 32 0 0 1 0 44.672L494.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L764.736 512 452.864 192a30.592 30.592 0 0 1 0-42.688m-256 0a29.12 29.12 0 0 1 41.728.064L570.24 489.664a32 32 0 0 1 0 44.672L238.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L508.736 512 196.864 192a30.592 30.592 0 0 1 0-42.688z" /></svg>
170
+ <svg class="icon-more-text" viewBox="0 0 1024 1024" width="1em" height="1em"><path fill="currentColor" d="M176 416a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224" /></svg>
171
+ </template>
172
+ </li>
173
+ </ul>
174
+
175
+ <!-- Next -->
176
+ <button
177
+ type="button"
178
+ class="btn-next"
179
+ :disabled="innerCurrentPage >= pageCount"
180
+ @click="next"
181
+ >
182
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z" /></svg>
183
+ </button>
184
+
185
+ <!-- Jumper -->
186
+ <span v-if="layout.includes('jumper')" class="sugar-pagination__jump">
187
+ <span style="margin-right: 4px;white-space: nowrap;">Go to</span>
188
+ <div class="sugar-input sugar-pagination__editor is-in-pagination">
189
+ <div class="sugar-input__wrapper">
190
+ <input
191
+ class="sugar-input__inner"
192
+ type="number"
193
+ :min="1"
194
+ :max="pageCount"
195
+ :value="innerCurrentPage"
196
+ @change="handleJumperChange"
197
+ >
198
+ </div>
199
+ </div>
200
+ </span>
201
+ </div>
202
+ </template>
203
+
204
+ <style scoped>
205
+ .sugar-pagination {
206
+ display: flex;
207
+ justify-content: center;
208
+ align-items: center;
209
+ padding: 2px 5px;
210
+ color: var(--vp-c-text-1);
211
+ font-size: 12px;
212
+ }
213
+ .sugar-pagination--small .btn-prev, .sugar-pagination--small .btn-next, .sugar-pagination--small .sugar-pager li {
214
+ height: 24px;
215
+ line-height: 24px;
216
+ min-width: 24px;
217
+ font-size: 12px;
218
+ }
219
+ .sugar-pagination button {
220
+ display: flex;
221
+ justify-content: center;
222
+ align-items: center;
223
+ background: transparent;
224
+ border: none;
225
+ cursor: pointer;
226
+ font-size: 12px;
227
+ padding: 0 6px;
228
+ min-width: 24px;
229
+ height: 24px;
230
+ line-height: 24px;
231
+ color: var(--vp-c-text-1);
232
+ }
233
+ .sugar-pagination button:disabled {
234
+ color: var(--vp-c-text-3);
235
+ cursor: not-allowed;
236
+ }
237
+ .sugar-pagination button:hover:not(:disabled) {
238
+ color: var(--vp-c-brand-2);
239
+ }
240
+ .sugar-pagination .sugar-pager {
241
+ user-select: none;
242
+ list-style: none;
243
+ display: flex;
244
+ padding: 0;
245
+ margin: 0;
246
+ }
247
+ .sugar-pagination .sugar-pager li {
248
+ padding: 0 4px;
249
+ background: transparent;
250
+ vertical-align: top;
251
+ display: inline-block;
252
+ font-size: 12px;
253
+ min-width: 24px;
254
+ height: 24px;
255
+ line-height: 24px;
256
+ cursor: pointer;
257
+ box-sizing: border-box;
258
+ text-align: center;
259
+ margin: 0 4px;
260
+ border-radius: 2px;
261
+ display: flex;
262
+ justify-content: center;
263
+ align-items: center;
264
+ }
265
+ .sugar-pagination .sugar-pager li.is-active {
266
+ color: var(--vp-c-brand-2);
267
+ cursor: default;
268
+ font-weight: normal;
269
+ }
270
+ .sugar-pagination .sugar-pager li:hover:not(.is-active):not(.more) {
271
+ color: var(--vp-c-brand-2);
272
+ }
273
+ .sugar-pagination .sugar-pager li.more {
274
+ cursor: pointer;
275
+ }
276
+ .sugar-pagination .sugar-pager li.more .icon-more {
277
+ display: none;
278
+ }
279
+ .sugar-pagination .sugar-pager li.more .icon-more-text {
280
+ display: block;
281
+ }
282
+ .sugar-pagination .sugar-pager li.more:hover {
283
+ color: var(--vp-c-brand-2);
284
+ }
285
+ .sugar-pagination .sugar-pager li.more:hover .icon-more {
286
+ display: inline-block;
287
+ }
288
+ .sugar-pagination .sugar-pager li.more:hover .icon-more-text {
289
+ display: none;
290
+ }
291
+ .sugar-pagination.is-background .btn-prev, .sugar-pagination.is-background .btn-next, .sugar-pagination.is-background .sugar-pager li {
292
+ background-color: var(--vp-c-bg-alt);
293
+ color: var(--vp-c-text-2);
294
+ margin: 0 3px;
295
+ border-radius: 2px;
296
+ font-weight: normal;
297
+ }
298
+ .sugar-pagination.is-background .btn-prev:disabled, .sugar-pagination.is-background .btn-next:disabled {
299
+ color: var(--vp-c-text-3);
300
+ background-color: var(--vp-c-bg-alt);
301
+ }
302
+ .sugar-pagination.is-background .sugar-pager li:not(.disabled).is-active {
303
+ background-color: var(--vp-c-brand-2);
304
+ color: #fff;
305
+ }
306
+ .sugar-pagination.is-background .sugar-pager li:not(.disabled):hover:not(.is-active):not(.more) {
307
+ color: var(--vp-c-brand-2);
308
+ }
309
+ .sugar-pagination__jump {
310
+ display: flex;
311
+ align-items: center;
312
+ margin-left: 24px;
313
+ font-weight: normal;
314
+ color: var(--vp-c-text-2);
315
+ }
316
+ .sugar-pagination__editor {
317
+ margin: 0 8px;
318
+ width: 50px;
319
+ }
320
+
321
+ .sugar-input {
322
+ display: inline-flex;
323
+ position: relative;
324
+ font-size: 12px;
325
+ line-height: 24px;
326
+ box-sizing: border-box;
327
+ width: 100%;
328
+ }
329
+
330
+ .sugar-input__wrapper {
331
+ display: inline-flex;
332
+ flex-grow: 1;
333
+ align-items: center;
334
+ justify-content: center;
335
+ padding: 1px 11px;
336
+ background-color: var(--vp-c-bg);
337
+ background-image: none;
338
+ border-radius: 4px;
339
+ transition: box-shadow 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
340
+ }
341
+ .sugar-input__wrapper:focus-within {
342
+ box-shadow: 0 0 0 1px var(--vp-c-brand-2) inset;
343
+ }
344
+
345
+ .sugar-input__inner {
346
+ width: 100%;
347
+ flex-grow: 1;
348
+ -webkit-appearance: none;
349
+ color: var(--vp-c-text-1);
350
+ font-size: inherit;
351
+ height: 24px;
352
+ line-height: 24px;
353
+ padding: 0;
354
+ outline: none;
355
+ border: none;
356
+ background: none;
357
+ box-sizing: border-box;
358
+ text-align: center;
359
+ /* Chrome, Safari, Edge, Opera */
360
+ /* Firefox */
361
+ }
362
+ .sugar-input__inner::-webkit-outer-spin-button, .sugar-input__inner::-webkit-inner-spin-button {
363
+ -webkit-appearance: none;
364
+ margin: 0;
365
+ }
366
+ .sugar-input__inner[type=number] {
367
+ -moz-appearance: textfield;
368
+ }
369
+ </style>
@@ -0,0 +1,144 @@
1
+ <script lang="ts" setup>
2
+ defineProps({
3
+ type: { type: String, default: 'primary' },
4
+ closable: { type: Boolean, default: false }
5
+ })
6
+
7
+ defineEmits(['close', 'click'])
8
+ </script>
9
+
10
+ <template>
11
+ <span class="blog-tag" :class="[`blog-tag--${type || 'primary'}`]" @click="$emit('click', $event)">
12
+ <slot />
13
+ <span v-if="closable" class="close" @click.stop="$emit('close', $event)">
14
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
15
+ <path
16
+ fill="currentColor"
17
+ d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"
18
+ />
19
+ </svg>
20
+ </span>
21
+ </span>
22
+ </template>
23
+
24
+ <style>
25
+ .blog-tag {
26
+ display: inline-flex;
27
+ justify-content: center;
28
+ align-items: center;
29
+ height: 24px;
30
+ padding: 0 9px;
31
+ font-size: 12px;
32
+ line-height: 1;
33
+ border-width: 1px;
34
+ border-style: solid;
35
+ border-radius: 4px;
36
+ box-sizing: border-box;
37
+ white-space: nowrap;
38
+ vertical-align: middle;
39
+ color: #fff;
40
+ }
41
+ .blog-tag > .close {
42
+ margin-left: 6px;
43
+ font-size: 12px;
44
+ cursor: pointer;
45
+ border-radius: 50%;
46
+ display: inline-flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ width: 14px;
50
+ height: 14px;
51
+ transition: all 0.3s;
52
+ }
53
+
54
+ /* Primary */
55
+ .blog-tag--primary {
56
+ background-color: #409eff;
57
+ border-color: #409eff;
58
+ }
59
+ .blog-tag--primary .close:hover {
60
+ background-color: #79bbff;
61
+ }
62
+
63
+ /* Success */
64
+ .blog-tag--success {
65
+ background-color: #67c23a;
66
+ border-color: #67c23a;
67
+ }
68
+ .blog-tag--success .close:hover {
69
+ background-color: #95d475;
70
+ }
71
+
72
+ /* Info */
73
+ .blog-tag--info {
74
+ background-color: #909399;
75
+ border-color: #909399;
76
+ }
77
+ .blog-tag--info .close:hover {
78
+ background-color: #b1b3b8;
79
+ }
80
+
81
+ /* Warning */
82
+ .blog-tag--warning {
83
+ background-color: #e6a23c;
84
+ border-color: #e6a23c;
85
+ }
86
+ .blog-tag--warning .close:hover {
87
+ background-color: #eebe77;
88
+ }
89
+
90
+ /* Danger */
91
+ .blog-tag--danger {
92
+ background-color: #f56c6c;
93
+ border-color: #f56c6c;
94
+ }
95
+ .blog-tag--danger .close:hover {
96
+ background-color: #f89898;
97
+ }
98
+
99
+ html.dark .blog-tag--primary {
100
+ background-color: #18222c;
101
+ border-color: #1d3043;
102
+ color: #409eff;
103
+ }
104
+ html.dark .blog-tag--primary .close:hover {
105
+ background-color: #409eff;
106
+ color: #fff;
107
+ }
108
+ html.dark .blog-tag--success {
109
+ background-color: #1c2518;
110
+ border-color: #25371c;
111
+ color: #67c23a;
112
+ }
113
+ html.dark .blog-tag--success .close:hover {
114
+ background-color: #95d475;
115
+ color: #fff;
116
+ }
117
+ html.dark .blog-tag--info {
118
+ background-color: #202121;
119
+ border-color: #2d2d2f;
120
+ color: #909399;
121
+ }
122
+ html.dark .blog-tag--info .close:hover {
123
+ background-color: #909399;
124
+ color: #fff;
125
+ }
126
+ html.dark .blog-tag--warning {
127
+ background-color: #292218;
128
+ border-color: #3e301c;
129
+ color: #e6a23c;
130
+ }
131
+ html.dark .blog-tag--warning .close:hover {
132
+ background-color: #e6a23c;
133
+ color: #fff;
134
+ }
135
+ html.dark .blog-tag--danger {
136
+ background-color: #2b1d1d;
137
+ border-color: #412626;
138
+ color: #f56c6c;
139
+ }
140
+ html.dark .blog-tag--danger .close:hover {
141
+ background-color: #f56c6c;
142
+ color: #fff;
143
+ }
144
+ </style>