Skip to content

Commit a932d8d

Browse files
committed
refactor: reorganize CSS properties and improve component structure for better clarity and maintainability
1 parent 3d3cb2c commit a932d8d

File tree

2 files changed

+53
-49
lines changed

2 files changed

+53
-49
lines changed
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
:root {
2-
--vc-nav-width: 30px;
3-
--vc-nav-height: 30px;
2+
--vc-nav-background: transparent;
43
--vc-nav-border-radius: 0;
54
--vc-nav-color: var(--vc-clr-primary);
65
--vc-nav-color-hover: var(--vc-clr-secondary);
7-
--vc-nav-background: transparent;
6+
--vc-nav-height: 30px;
7+
--vc-nav-width: 30px;
88
}
99

10-
.carousel__prev,
11-
.carousel__next {
12-
box-sizing: content-box;
10+
.carousel__next,
11+
.carousel__prev {
12+
align-items: center;
1313
background: var(--vc-nav-background);
14+
border: 0;
1415
border-radius: var(--vc-nav-border-radius);
15-
width: var(--vc-nav-width);
16-
height: var(--vc-nav-height);
17-
text-align: center;
18-
font-size: var(--vc-nav-height);
19-
padding: 0;
16+
box-sizing: content-box;
2017
color: var(--vc-nav-color);
18+
cursor: pointer;
2119
display: flex;
20+
font-size: var(--vc-nav-height);
21+
height: var(--vc-nav-height);
2222
justify-content: center;
23-
align-items: center;
24-
position: absolute;
25-
border: 0;
26-
cursor: pointer;
2723
margin: 0 10px;
24+
padding: 0;
25+
position: absolute;
26+
text-align: center;
2827
top: 50%;
2928
transform: translateY(-50%);
29+
width: var(--vc-nav-width);
3030
}
3131

3232
.carousel__next--disabled,
@@ -35,57 +35,57 @@
3535
opacity: 0.5;
3636
}
3737

38+
.carousel__next {
39+
right: 0;
40+
}
41+
3842
.carousel__prev {
3943
left: 0;
4044
}
4145

42-
.carousel__next {
43-
right: 0;
46+
.carousel.is-btt {
47+
.carousel__next {
48+
top: 0;
49+
}
50+
.carousel__prev {
51+
bottom: 0;
52+
}
4453
}
4554

4655
.carousel.is-rtl {
47-
.carousel__prev {
48-
left: auto;
49-
right: 0;
50-
}
5156
.carousel__next {
52-
right: auto;
5357
left: 0;
58+
right: auto;
5459
}
55-
}
56-
57-
.carousel.is-vertical {
58-
.carousel__prev,
59-
.carousel__next {
60+
.carousel__prev {
6061
left: auto;
61-
top: auto;
62-
right: 50%;
63-
transform: translate(50%);
64-
margin: 5px auto;
62+
right: 0;
6563
}
6664
}
6765

68-
.carousel.is-btt {
69-
.carousel__prev {
66+
.carousel.is-ttb {
67+
.carousel__next {
7068
bottom: 0;
7169
}
72-
.carousel__next {
70+
.carousel__prev {
7371
top: 0;
7472
}
7573
}
7674

77-
.carousel.is-ttb {
75+
.carousel.is-vertical {
76+
.carousel__next,
7877
.carousel__prev {
79-
top: 0;
80-
}
81-
.carousel__next {
82-
bottom: 0;
78+
left: auto;
79+
margin: 5px auto;
80+
right: 50%;
81+
top: auto;
82+
transform: translate(50%);
8383
}
8484
}
8585

8686
@media (hover: hover) {
87-
.carousel__prev:hover,
88-
.carousel__next:hover {
87+
.carousel__next:hover,
88+
.carousel__prev:hover {
8989
color: var(--vc-nav-color-hover);
9090
}
9191
}

src/components/Navigation/Navigation.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { inject, h, defineComponent, computed } from 'vue'
1+
import { computed, defineComponent, h, inject } from 'vue'
22

3-
import { NormalizedDir, injectCarousel } from '@/shared'
3+
import { injectCarousel, NormalizedDir } from '@/shared'
44

55
import { Icon, IconNameValue } from '../Icon'
66

@@ -18,27 +18,31 @@ export const Navigation = defineComponent<NavigationProps>({
1818

1919
const getPrevIcon = () => {
2020
const directionIcons: Record<NormalizedDir, IconNameValue> = {
21+
btt: 'arrowDown',
2122
ltr: 'arrowLeft',
2223
rtl: 'arrowRight',
2324
ttb: 'arrowUp',
24-
btt: 'arrowDown',
2525
}
2626

2727
return directionIcons[carousel.normalizedDir]
2828
}
2929
const getNextIcon = () => {
3030
const directionIcons: Record<NormalizedDir, IconNameValue> = {
31+
btt: 'arrowUp',
3132
ltr: 'arrowRight',
3233
rtl: 'arrowLeft',
3334
ttb: 'arrowDown',
34-
btt: 'arrowUp',
3535
}
3636

3737
return directionIcons[carousel.normalizedDir]
3838
}
3939

40-
const prevDisabled = computed(() => !carousel.config.wrapAround && carousel.currentSlide <= carousel.minSlide)
41-
const nextDisabled = computed(() => !carousel.config.wrapAround && carousel.currentSlide >= carousel.maxSlide)
40+
const prevDisabled = computed(
41+
() => !carousel.config.wrapAround && carousel.currentSlide <= carousel.minSlide
42+
)
43+
const nextDisabled = computed(
44+
() => !carousel.config.wrapAround && carousel.currentSlide >= carousel.maxSlide
45+
)
4246

4347
return () => {
4448
const { i18n } = carousel.config
@@ -53,7 +57,7 @@ export const Navigation = defineComponent<NavigationProps>({
5357
...attrs,
5458
class: [
5559
'carousel__prev',
56-
{'carousel__prev--disabled': prevDisabled.value},
60+
{ 'carousel__prev--disabled': prevDisabled.value },
5761
attrs.class,
5862
],
5963
},
@@ -70,7 +74,7 @@ export const Navigation = defineComponent<NavigationProps>({
7074
...attrs,
7175
class: [
7276
'carousel__next',
73-
{'carousel__next--disabled': nextDisabled.value},
77+
{ 'carousel__next--disabled': nextDisabled.value },
7478
attrs.class,
7579
],
7680
},

0 commit comments

Comments
 (0)