@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.
- package/node.d.ts +2 -4
- package/node.js +206 -156
- package/node.mjs +205 -154
- package/package.json +10 -15
- package/src/components/Alert.vue +269 -0
- package/src/components/Avatar.vue +65 -0
- package/src/components/BlogAlert.vue +8 -8
- package/src/components/BlogApp.vue +5 -8
- package/src/components/BlogArticleAnalyze.vue +99 -66
- package/src/components/BlogAuthor.vue +13 -15
- package/src/components/BlogBackToTop.vue +21 -24
- package/src/components/BlogButtonAfterArticle.vue +12 -15
- package/src/components/BlogCommentWrapper.vue +34 -41
- package/src/components/BlogDocCover.vue +1 -1
- package/src/components/BlogFooter.vue +26 -32
- package/src/components/BlogFriendLink.vue +91 -73
- package/src/components/BlogHomeBanner.vue +25 -31
- package/src/components/BlogHomeHeaderAvatar.vue +16 -23
- package/src/components/BlogHomeInfo.vue +2 -4
- package/src/components/BlogHomeOverview.vue +12 -15
- package/src/components/BlogHomeTags.vue +22 -31
- package/src/components/BlogHotArticle.vue +69 -80
- package/src/components/BlogImagePreview.vue +3 -3
- package/src/components/BlogItem.vue +14 -23
- package/src/components/BlogList.vue +15 -19
- package/src/components/BlogRecommendArticle.vue +56 -72
- package/src/components/BlogSidebar.vue +1 -1
- package/src/components/Button.vue +150 -0
- package/src/components/Carousel.vue +249 -0
- package/src/components/CarouselItem.vue +139 -0
- package/src/components/CommentArtalk.vue +1 -1
- package/src/components/Image.vue +33 -0
- package/src/components/ImageViewer.vue +407 -0
- package/src/components/Pagination.vue +369 -0
- package/src/components/Tag.vue +144 -0
- package/src/components/UserWorks.vue +132 -175
- package/src/composables/config/blog.ts +6 -1
- package/src/composables/config/index.ts +2 -2
- package/src/index.ts +12 -19
- package/src/node.ts +0 -3
- package/src/styles/el-base.css +340 -0
- package/src/styles/{index.scss → index.css} +56 -91
- package/src/utils/client/index.ts +17 -0
- package/src/utils/node/mdPlugins.ts +1 -1
- package/src/utils/node/theme.ts +5 -2
- package/src/utils/node/vitePlugins.ts +51 -18
- package/src/styles/scss/algolia.scss +0 -231
- package/src/styles/scss/global.scss +0 -156
- package/src/styles/scss/highlight.scss +0 -12
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed, onMounted, ref } from 'vue'
|
|
3
3
|
import { useRoute, useRouter, withBase } from 'vitepress'
|
|
4
|
-
import { ElButton } from 'element-plus'
|
|
5
4
|
import { wrapperCleanUrls } from '../utils/client'
|
|
6
5
|
import { useArticles, useCleanUrls, useFormatShowDate, useRecommendConfig, useShowRecommend } from '../composables/config/blog'
|
|
7
6
|
import { recommendSVG } from '../constants/svg'
|
|
8
7
|
import type { Theme } from '../composables/config/index'
|
|
8
|
+
import Button from './Button.vue'
|
|
9
9
|
|
|
10
10
|
const formatShowDate = useFormatShowDate()
|
|
11
11
|
|
|
@@ -162,9 +162,9 @@ function handleLinkClick(link: string) {
|
|
|
162
162
|
<!-- 头部 -->
|
|
163
163
|
<div class="card-header">
|
|
164
164
|
<span v-if="title" class="title" v-html="title" />
|
|
165
|
-
<
|
|
165
|
+
<Button v-if="showChangeBtn" size="small" type="primary" text @click="changePage">
|
|
166
166
|
{{ nextText }}
|
|
167
|
-
</
|
|
167
|
+
</Button>
|
|
168
168
|
</div>
|
|
169
169
|
<!-- 文章列表 -->
|
|
170
170
|
<ol
|
|
@@ -206,7 +206,7 @@ function handleLinkClick(link: string) {
|
|
|
206
206
|
</div>
|
|
207
207
|
</template>
|
|
208
208
|
|
|
209
|
-
<style
|
|
209
|
+
<style scoped>
|
|
210
210
|
.card {
|
|
211
211
|
position: relative;
|
|
212
212
|
margin: 0 auto 10px;
|
|
@@ -219,17 +219,17 @@ function handleLinkClick(link: string) {
|
|
|
219
219
|
transition: all 0.3s;
|
|
220
220
|
background-color: rgba(var(--bg-gradient));
|
|
221
221
|
display: flex;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
222
|
+
}
|
|
223
|
+
.card:hover {
|
|
224
|
+
box-shadow: var(--box-shadow-hover);
|
|
226
225
|
}
|
|
227
226
|
|
|
228
227
|
.recommend {
|
|
229
228
|
flex-direction: column;
|
|
230
229
|
padding: 0px;
|
|
231
230
|
}
|
|
232
|
-
|
|
231
|
+
|
|
232
|
+
.recommend.card {
|
|
233
233
|
padding: 10px;
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -240,63 +240,48 @@ function handleLinkClick(link: string) {
|
|
|
240
240
|
margin: 0;
|
|
241
241
|
padding: 0 10px 0 0px;
|
|
242
242
|
width: 100%;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// .title:hover::after {
|
|
286
|
-
// content: "";
|
|
287
|
-
// position: absolute;
|
|
288
|
-
// left: 0;
|
|
289
|
-
// right: 0;
|
|
290
|
-
// height: 0;
|
|
291
|
-
// bottom: -3px;
|
|
292
|
-
// border-bottom: 1px solid #b1b3b8;
|
|
293
|
-
// }
|
|
294
|
-
|
|
295
|
-
.suffix {
|
|
296
|
-
font-size: 12px;
|
|
297
|
-
color: var(--vp-c-text-2);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
243
|
+
}
|
|
244
|
+
.recommend-container.hide-num > li {
|
|
245
|
+
padding: 5px 0;
|
|
246
|
+
}
|
|
247
|
+
.recommend-container li {
|
|
248
|
+
display: flex;
|
|
249
|
+
}
|
|
250
|
+
.recommend-container li .num {
|
|
251
|
+
display: block;
|
|
252
|
+
font-size: 14px;
|
|
253
|
+
color: var(--description-font-color);
|
|
254
|
+
font-weight: 600;
|
|
255
|
+
margin: 6px 8px 10px 0;
|
|
256
|
+
width: 22px;
|
|
257
|
+
height: 18px;
|
|
258
|
+
line-height: 18px;
|
|
259
|
+
text-align: center;
|
|
260
|
+
}
|
|
261
|
+
.recommend-container li .des {
|
|
262
|
+
overflow: hidden;
|
|
263
|
+
text-overflow: ellipsis;
|
|
264
|
+
white-space: nowrap;
|
|
265
|
+
display: flex;
|
|
266
|
+
flex-direction: column;
|
|
267
|
+
justify-content: center;
|
|
268
|
+
}
|
|
269
|
+
.recommend-container li .title {
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
color: var(--vp-c-text-1);
|
|
272
|
+
word-break: break-all;
|
|
273
|
+
white-space: break-spaces;
|
|
274
|
+
font-weight: 500;
|
|
275
|
+
position: relative;
|
|
276
|
+
cursor: pointer;
|
|
277
|
+
transition: color 0.25s;
|
|
278
|
+
}
|
|
279
|
+
.recommend-container li .title.current, .recommend-container li .title:hover {
|
|
280
|
+
color: var(--vp-c-brand-1);
|
|
281
|
+
}
|
|
282
|
+
.recommend-container li .suffix {
|
|
283
|
+
font-size: 12px;
|
|
284
|
+
color: var(--vp-c-text-2);
|
|
300
285
|
}
|
|
301
286
|
|
|
302
287
|
.card-header {
|
|
@@ -305,12 +290,11 @@ function handleLinkClick(link: string) {
|
|
|
305
290
|
justify-content: space-between;
|
|
306
291
|
align-items: center;
|
|
307
292
|
margin-bottom: 10px;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
293
|
+
}
|
|
294
|
+
.card-header .title {
|
|
295
|
+
font-size: 14px;
|
|
296
|
+
display: flex;
|
|
297
|
+
align-items: center;
|
|
314
298
|
}
|
|
315
299
|
|
|
316
300
|
.empty-text {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
type: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: 'default',
|
|
8
|
+
validator: (val: string) => ['default', 'primary', 'success', 'warning', 'danger', 'info'].includes(val),
|
|
9
|
+
},
|
|
10
|
+
size: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'default',
|
|
13
|
+
validator: (val: string) => ['large', 'default', 'small'].includes(val),
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false,
|
|
18
|
+
},
|
|
19
|
+
round: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false,
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits(['click'])
|
|
30
|
+
|
|
31
|
+
function handleClick(evt: MouseEvent) {
|
|
32
|
+
if (props.disabled)
|
|
33
|
+
return
|
|
34
|
+
emit('click', evt)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const classes = computed(() => {
|
|
38
|
+
return [
|
|
39
|
+
'sugar-button',
|
|
40
|
+
`sugar-button--${props.type}`,
|
|
41
|
+
`sugar-button--${props.size}`,
|
|
42
|
+
{
|
|
43
|
+
'is-text': props.text,
|
|
44
|
+
'is-round': props.round,
|
|
45
|
+
'is-disabled': props.disabled,
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
})
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<button :class="classes" :disabled="disabled" @click="handleClick">
|
|
53
|
+
<slot />
|
|
54
|
+
</button>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<style scoped>
|
|
58
|
+
.sugar-button {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
align-items: center;
|
|
62
|
+
line-height: 1;
|
|
63
|
+
height: 32px;
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
color: var(--vp-c-text-1);
|
|
67
|
+
text-align: center;
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
outline: none;
|
|
70
|
+
transition: 0.1s;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
user-select: none;
|
|
73
|
+
vertical-align: middle;
|
|
74
|
+
-webkit-appearance: none;
|
|
75
|
+
background-color: var(--vp-c-bg);
|
|
76
|
+
border: 1px solid var(--vp-c-divider);
|
|
77
|
+
border-radius: 4px;
|
|
78
|
+
padding: 8px 15px;
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
/* Types */
|
|
81
|
+
/* Sizes */
|
|
82
|
+
}
|
|
83
|
+
.sugar-button:hover {
|
|
84
|
+
color: var(--vp-c-brand-1);
|
|
85
|
+
border-color: var(--vp-c-brand-2);
|
|
86
|
+
background-color: var(--vp-c-bg-alt);
|
|
87
|
+
}
|
|
88
|
+
.sugar-button:active {
|
|
89
|
+
color: var(--vp-c-brand-3);
|
|
90
|
+
border-color: var(--vp-c-brand-3);
|
|
91
|
+
}
|
|
92
|
+
.sugar-button.is-disabled {
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
opacity: 0.5;
|
|
95
|
+
}
|
|
96
|
+
.sugar-button--primary {
|
|
97
|
+
color: #fff;
|
|
98
|
+
background-color: var(--vp-c-brand-1);
|
|
99
|
+
border-color: var(--vp-c-brand-1);
|
|
100
|
+
}
|
|
101
|
+
.sugar-button--primary:hover {
|
|
102
|
+
background-color: var(--vp-c-brand-2);
|
|
103
|
+
border-color: var(--vp-c-brand-2);
|
|
104
|
+
color: #fff;
|
|
105
|
+
}
|
|
106
|
+
.sugar-button--primary:active {
|
|
107
|
+
background-color: var(--vp-c-brand-3);
|
|
108
|
+
border-color: var(--vp-c-brand-3);
|
|
109
|
+
color: #fff;
|
|
110
|
+
}
|
|
111
|
+
.sugar-button--primary.is-text {
|
|
112
|
+
color: var(--vp-c-brand-1);
|
|
113
|
+
background-color: transparent;
|
|
114
|
+
border-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
.sugar-button--primary.is-text:hover {
|
|
117
|
+
background-color: var(--vp-c-bg-alt);
|
|
118
|
+
color: var(--vp-c-brand-2);
|
|
119
|
+
}
|
|
120
|
+
.sugar-button--primary.is-text:active {
|
|
121
|
+
color: var(--vp-c-brand-3);
|
|
122
|
+
}
|
|
123
|
+
.sugar-button--danger {
|
|
124
|
+
color: #fff;
|
|
125
|
+
background-color: var(--vp-c-danger-2);
|
|
126
|
+
border-color: var(--vp-c-danger-2);
|
|
127
|
+
}
|
|
128
|
+
.sugar-button--danger:hover {
|
|
129
|
+
background-color: var(--vp-c-danger-3);
|
|
130
|
+
border-color: var(--vp-c-danger-3);
|
|
131
|
+
color: #fff;
|
|
132
|
+
}
|
|
133
|
+
.sugar-button--danger:active {
|
|
134
|
+
background-color: var(--vp-c-danger-3);
|
|
135
|
+
border-color: var(--vp-c-danger-3);
|
|
136
|
+
color: #fff;
|
|
137
|
+
}
|
|
138
|
+
.sugar-button--small {
|
|
139
|
+
height: 24px;
|
|
140
|
+
padding: 5px 11px;
|
|
141
|
+
font-size: 12px;
|
|
142
|
+
border-radius: 3px;
|
|
143
|
+
}
|
|
144
|
+
.sugar-button--large {
|
|
145
|
+
height: 40px;
|
|
146
|
+
padding: 12px 19px;
|
|
147
|
+
font-size: 16px;
|
|
148
|
+
border-radius: 4px;
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
height: { type: String, default: '300px' },
|
|
6
|
+
initialIndex: { type: Number, default: 0 },
|
|
7
|
+
trigger: { type: String, default: 'hover' },
|
|
8
|
+
autoplay: { type: Boolean, default: true },
|
|
9
|
+
interval: { type: Number, default: 3000 },
|
|
10
|
+
indicatorPosition: { type: String, default: '' },
|
|
11
|
+
arrow: { type: String, default: 'hover' },
|
|
12
|
+
type: { type: String, default: '' },
|
|
13
|
+
loop: { type: Boolean, default: true },
|
|
14
|
+
direction: { type: String, default: 'horizontal' },
|
|
15
|
+
pauseOnHover: { type: Boolean, default: true },
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const activeIndex = ref(props.initialIndex)
|
|
19
|
+
const items = ref<any[]>([])
|
|
20
|
+
const timer = ref<any>(null)
|
|
21
|
+
|
|
22
|
+
function addItem(item: any) {
|
|
23
|
+
items.value.push(item)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function removeItem(uid: number) {
|
|
27
|
+
const index = items.value.findIndex(item => item.uid === uid)
|
|
28
|
+
if (index > -1)
|
|
29
|
+
items.value.splice(index, 1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
provide('carousel', {
|
|
33
|
+
addItem,
|
|
34
|
+
removeItem,
|
|
35
|
+
activeIndex,
|
|
36
|
+
items,
|
|
37
|
+
type: computed(() => props.type),
|
|
38
|
+
direction: computed(() => props.direction),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
function startTimer() {
|
|
42
|
+
if (typeof window === 'undefined')
|
|
43
|
+
return
|
|
44
|
+
if (props.interval <= 0 || !props.autoplay || timer.value)
|
|
45
|
+
return
|
|
46
|
+
timer.value = setInterval(playSlides, props.interval)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function pauseTimer() {
|
|
50
|
+
if (timer.value) {
|
|
51
|
+
clearInterval(timer.value)
|
|
52
|
+
timer.value = null
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function playSlides() {
|
|
57
|
+
if (activeIndex.value < items.value.length - 1) {
|
|
58
|
+
activeIndex.value++
|
|
59
|
+
}
|
|
60
|
+
else if (props.loop) {
|
|
61
|
+
activeIndex.value = 0
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function setActiveItem(index: number) {
|
|
66
|
+
activeIndex.value = index
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function prev() {
|
|
70
|
+
setActiveItem(activeIndex.value > 0 ? activeIndex.value - 1 : items.value.length - 1)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function next() {
|
|
74
|
+
setActiveItem(activeIndex.value < items.value.length - 1 ? activeIndex.value + 1 : 0)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function handleIndicatorClick(index: number) {
|
|
78
|
+
activeIndex.value = index
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const hover = ref(false)
|
|
82
|
+
|
|
83
|
+
function handleMouseEnter() {
|
|
84
|
+
hover.value = true
|
|
85
|
+
if (props.pauseOnHover)
|
|
86
|
+
pauseTimer()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function handleMouseLeave() {
|
|
90
|
+
hover.value = false
|
|
91
|
+
if (props.pauseOnHover)
|
|
92
|
+
startTimer()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
watch(() => props.autoplay, (val) => {
|
|
96
|
+
val ? startTimer() : pauseTimer()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
onMounted(() => {
|
|
100
|
+
startTimer()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
onUnmounted(() => {
|
|
104
|
+
pauseTimer()
|
|
105
|
+
})
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<template>
|
|
109
|
+
<div
|
|
110
|
+
class="sugar-carousel"
|
|
111
|
+
:class="{ 'sugar-carousel--card': type === 'card' }"
|
|
112
|
+
@mouseenter="handleMouseEnter"
|
|
113
|
+
@mouseleave="handleMouseLeave"
|
|
114
|
+
>
|
|
115
|
+
<div class="sugar-carousel__container" :style="{ height }">
|
|
116
|
+
<slot />
|
|
117
|
+
<transition name="carousel-arrow-left">
|
|
118
|
+
<button
|
|
119
|
+
v-if="arrow !== 'never' && items.length > 1"
|
|
120
|
+
v-show="(arrow === 'always' || hover) && (loop || activeIndex > 0)"
|
|
121
|
+
type="button"
|
|
122
|
+
class="sugar-carousel__arrow sugar-carousel__arrow--left"
|
|
123
|
+
@click.stop="prev"
|
|
124
|
+
>
|
|
125
|
+
<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>
|
|
126
|
+
</button>
|
|
127
|
+
</transition>
|
|
128
|
+
<transition name="carousel-arrow-right">
|
|
129
|
+
<button
|
|
130
|
+
v-if="arrow !== 'never' && items.length > 1"
|
|
131
|
+
v-show="(arrow === 'always' || hover) && (loop || activeIndex < items.length - 1)"
|
|
132
|
+
type="button"
|
|
133
|
+
class="sugar-carousel__arrow sugar-carousel__arrow--right"
|
|
134
|
+
@click.stop="next"
|
|
135
|
+
>
|
|
136
|
+
<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>
|
|
137
|
+
</button>
|
|
138
|
+
</transition>
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<ul v-if="indicatorPosition !== 'none' && items.length > 1" class="sugar-carousel__indicators">
|
|
142
|
+
<li
|
|
143
|
+
v-for="(item, index) in items"
|
|
144
|
+
:key="index"
|
|
145
|
+
class="sugar-carousel__indicator"
|
|
146
|
+
:class="{ 'is-active': index === activeIndex }"
|
|
147
|
+
@mouseenter="trigger === 'hover' && setActiveItem(index)"
|
|
148
|
+
@click.stop="handleIndicatorClick(index)"
|
|
149
|
+
>
|
|
150
|
+
<button class="sugar-carousel__button" />
|
|
151
|
+
</li>
|
|
152
|
+
</ul>
|
|
153
|
+
</div>
|
|
154
|
+
</template>
|
|
155
|
+
|
|
156
|
+
<style scoped>
|
|
157
|
+
.sugar-carousel {
|
|
158
|
+
position: relative;
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
}
|
|
161
|
+
.sugar-carousel:hover .sugar-carousel__arrow {
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.sugar-carousel__container {
|
|
166
|
+
position: relative;
|
|
167
|
+
height: 300px;
|
|
168
|
+
overflow: hidden;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.sugar-carousel__indicators {
|
|
172
|
+
position: absolute;
|
|
173
|
+
list-style: none;
|
|
174
|
+
bottom: 0;
|
|
175
|
+
left: 50%;
|
|
176
|
+
transform: translateX(-50%);
|
|
177
|
+
margin: 0;
|
|
178
|
+
padding: 0;
|
|
179
|
+
z-index: 20;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.sugar-carousel__indicator {
|
|
183
|
+
display: inline-block;
|
|
184
|
+
background-color: transparent;
|
|
185
|
+
padding: 12px 4px;
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
}
|
|
188
|
+
.sugar-carousel__indicator.is-active button {
|
|
189
|
+
opacity: 1;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.sugar-carousel__button {
|
|
193
|
+
display: block;
|
|
194
|
+
opacity: 0.48;
|
|
195
|
+
width: 30px;
|
|
196
|
+
height: 2px;
|
|
197
|
+
background-color: #d3dce6;
|
|
198
|
+
border: none;
|
|
199
|
+
outline: none;
|
|
200
|
+
padding: 0;
|
|
201
|
+
margin: 0;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
transition: 0.3s;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.sugar-carousel__arrow {
|
|
207
|
+
border: none;
|
|
208
|
+
outline: none;
|
|
209
|
+
padding: 0;
|
|
210
|
+
margin: 0;
|
|
211
|
+
height: 36px;
|
|
212
|
+
width: 36px;
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
transition: 0.3s;
|
|
215
|
+
border-radius: 50%;
|
|
216
|
+
background-color: rgba(31, 45, 61, 0.11);
|
|
217
|
+
color: #fff;
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: 50%;
|
|
220
|
+
z-index: 20;
|
|
221
|
+
transform: translateY(-50%);
|
|
222
|
+
text-align: center;
|
|
223
|
+
font-size: 12px;
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
align-items: center;
|
|
227
|
+
}
|
|
228
|
+
.sugar-carousel__arrow:hover {
|
|
229
|
+
background-color: rgba(31, 45, 61, 0.23);
|
|
230
|
+
}
|
|
231
|
+
.sugar-carousel__arrow--left {
|
|
232
|
+
left: 16px;
|
|
233
|
+
}
|
|
234
|
+
.sugar-carousel__arrow--right {
|
|
235
|
+
right: 16px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.carousel-arrow-left-enter-from,
|
|
239
|
+
.carousel-arrow-left-leave-to {
|
|
240
|
+
opacity: 0;
|
|
241
|
+
transform: translateY(-50%) translateX(-10px);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.carousel-arrow-right-enter-from,
|
|
245
|
+
.carousel-arrow-right-leave-to {
|
|
246
|
+
opacity: 0;
|
|
247
|
+
transform: translateY(-50%) translateX(10px);
|
|
248
|
+
}
|
|
249
|
+
</style>
|