Skip to content

Commit 750e8cc

Browse files
authored
Merge pull request #475 from ismail9k/416-add-a-convenient-option-for-styling-pagination
416 add a convenient option for styling pagination
2 parents badf3d0 + aa126cb commit 750e8cc

File tree

6 files changed

+120
-56
lines changed

6 files changed

+120
-56
lines changed

docs/components/navigation.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,46 @@ You can customize the navigation buttons using slots:
6868
| `--vc-nav-height` | `30px` | Navigation button height |
6969
| `--vc-nav-width` | `30px` | Navigation button width |
7070

71+
### Customization Examples
72+
73+
There are two ways to customize the navigation appearance:
74+
75+
#### 1. Using CSS Custom Properties
76+
77+
```css
78+
.carousel {
79+
--vc-nav-background: rgba(0, 0, 0, 0.3);
80+
--vc-nav-color: white;
81+
--vc-nav-color-hover: #e5e5e5;
82+
--vc-nav-border-radius: 50%;
83+
--vc-nav-width: 40px;
84+
--vc-nav-height: 40px;
85+
}
86+
```
87+
88+
#### 2. Direct CSS Override
89+
90+
```css
91+
.carousel__next,
92+
.carousel__prev {
93+
background: rgba(0, 0, 0, 0.3);
94+
border-radius: 50%;
95+
width: 40px;
96+
height: 40px;
97+
color: white;
98+
}
99+
100+
.carousel__next:hover,
101+
.carousel__prev:hover {
102+
color: #e5e5e5;
103+
}
104+
105+
.carousel__next--disabled,
106+
.carousel__prev--disabled {
107+
opacity: 0.3;
108+
}
109+
```
110+
71111
## Accessibility
72112

73113
- Buttons include descriptive ARIA labels

docs/components/pagination.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,43 @@ import { Pagination as CarouselPagination } from 'vue3-carousel'
3838
| `--vc-pgn-active-color` | `var(--vc-clr-primary)` | Active pagination button color |
3939
| `--vc-pgn-background-color` | `var(--vc-clr-secondary)` | Pagination button background color |
4040
| `--vc-pgn-border-radius` | `0` | Pagination button border radius |
41+
| `--vc-pgn-gap` | `6px` | Gap between pagination buttons |
4142
| `--vc-pgn-height` | `4px` | Pagination button height |
42-
| `--vc-pgn-margin` | `6px 5px` | Pagination button margin |
43+
| `--vc-png-bottom` | `10px` | Bottom spacing for pagination |
44+
| `--vc-png-left` | `auto` | Left spacing for vertical mode |
45+
| `--vc-png-right` | `10px` | Right spacing for vertical mode |
4346
| `--vc-pgn-width` | `16px` | Pagination button width |
4447

48+
### Customization Examples
49+
50+
There are two ways to customize the pagination appearance:
51+
52+
#### 1. Using CSS Custom Properties
53+
54+
```css
55+
.carousel {
56+
--vc-pgn-background-color: white;
57+
--vc-pgn-active-color: red;
58+
--vc-pgn-border-radius: 5px;
59+
--vc-pgn-height: 5px;
60+
--vc-pgn-width: 5px;
61+
}
62+
```
63+
64+
#### 2. Direct CSS Override
65+
66+
```css
67+
.carousel__pagination-button {
68+
height: 5px;
69+
width: 5px;
70+
border-radius: 5px;
71+
background-color: white;
72+
}
73+
.carousel__pagination-button--active {
74+
background-color: red;
75+
}
76+
```
77+
4578
## Accessibility
4679

4780
- Pagination buttons are properly labeled for screen readers

src/components/Carousel/Carousel.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
gap: var(--vc-slide-gap);
2121
height: 100%;
2222
list-style: none;
23-
margin: 0 !important;
24-
padding: 0 !important;
23+
margin: 0;
24+
padding: 0;
2525
position: relative;
2626
transition: transform ease-out;
2727
transition-duration: var(--vc-transition-duration);
@@ -45,6 +45,10 @@
4545
width: 1px;
4646
}
4747

48+
.carousel.is-rtl {
49+
direction: rtl;
50+
}
51+
4852
.carousel.is-ttb .carousel__track {
4953
flex-direction: column;
5054
}
@@ -70,12 +74,12 @@
7074

7175
.carousel.is-effect-fade .carousel__slide {
7276
grid-area: 1 / 1;
73-
height: 100% !important;
77+
height: 100%;
7478
opacity: 0;
7579
pointer-events: none;
7680
transition: opacity ease-in-out;
7781
transition-duration: var(--vc-transition-duration);
78-
width: 100% !important;
82+
width: 100%;
7983
}
8084

8185
.carousel.is-effect-fade .carousel__slide--active {

src/components/Icon/Icon.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
:root {
2-
--vc-icn-width: 1.2em;
2+
--vc-icn-width: 100%;
33
}
44

55
.carousel__icon {

src/components/Navigation/Navigation.css

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@
1313
background: var(--vc-nav-background);
1414
border: 0;
1515
border-radius: var(--vc-nav-border-radius);
16-
box-sizing: content-box;
1716
color: var(--vc-nav-color);
1817
cursor: pointer;
1918
display: flex;
2019
font-size: var(--vc-nav-height);
2120
height: var(--vc-nav-height);
2221
justify-content: center;
23-
margin: 0 10px;
2422
padding: 0;
2523
position: absolute;
26-
text-align: center;
27-
top: 50%;
24+
inset-block-start: 50%;
2825
transform: translateY(-50%);
2926
width: var(--vc-nav-width);
3027
}
@@ -36,50 +33,37 @@
3633
}
3734

3835
.carousel__next {
39-
right: 0;
36+
inset-inline-end: 0;
4037
}
4138

4239
.carousel__prev {
43-
left: 0;
40+
inset-inline-start: 0;
4441
}
4542

46-
.carousel.is-btt {
47-
.carousel__next {
48-
top: 0;
49-
}
43+
.carousel.is-vertical {
44+
.carousel__next,
5045
.carousel__prev {
51-
bottom: 0;
46+
inset-inline: auto 50%;
47+
inset-block-start: auto;
48+
transform: translateX(50%);
5249
}
53-
}
5450

55-
.carousel.is-rtl {
56-
.carousel__next {
57-
left: 0;
58-
right: auto;
51+
&.is-ttb {
52+
.carousel__next {
53+
inset-block-end: 0;
54+
}
55+
.carousel__prev {
56+
inset-block-start: 0;
57+
}
5958
}
60-
.carousel__prev {
61-
left: auto;
62-
right: 0;
63-
}
64-
}
6559

66-
.carousel.is-ttb {
67-
.carousel__next {
68-
bottom: 0;
69-
}
70-
.carousel__prev {
71-
top: 0;
72-
}
73-
}
74-
75-
.carousel.is-vertical {
76-
.carousel__next,
77-
.carousel__prev {
78-
left: auto;
79-
margin: 5px auto;
80-
right: 50%;
81-
top: auto;
82-
transform: translate(50%);
60+
&.is-btt {
61+
.carousel__next {
62+
inset-block-start: 0;
63+
}
64+
.carousel__prev {
65+
inset-block-end: 0;
66+
}
8367
}
8468
}
8569

src/components/Pagination/Pagination.css

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,37 @@
22
--vc-pgn-active-color: var(--vc-clr-primary);
33
--vc-pgn-background-color: var(--vc-clr-secondary);
44
--vc-pgn-border-radius: 0;
5+
--vc-pgn-gap: 6px;
56
--vc-pgn-height: 4px;
6-
--vc-pgn-margin: 6px 5px;
7+
--vc-png-bottom: 10px;
8+
--vc-png-left: auto;
9+
--vc-png-right: 10px;
710
--vc-pgn-width: 16px;
811
}
912

1013
.carousel__pagination {
11-
bottom: 5px;
14+
bottom: var(--vc-png-bottom);
1215
display: flex;
16+
gap: var(--vc-pgn-gap);
1317
justify-content: center;
1418
left: 50%;
15-
line-height: 0;
16-
list-style: none !important;
17-
margin: 0 !important;
18-
padding: 0 !important;
19+
list-style: none;
20+
margin: 0;
21+
padding: 0;
1922
position: absolute;
2023
transform: translateX(-50%);
2124
}
2225

2326
.carousel__pagination-button {
24-
border: 0;
25-
cursor: pointer;
26-
margin: var(--vc-pgn-margin);
2727
background-color: var(--vc-pgn-background-color);
28+
border: 0;
2829
border-radius: var(--vc-pgn-border-radius);
30+
cursor: pointer;
2931
display: block;
3032
height: var(--vc-pgn-height);
31-
width: var(--vc-pgn-width);
33+
margin: 0;
3234
padding: 0;
35+
width: var(--vc-pgn-width);
3336
}
3437

3538
.carousel__pagination-button--active {
@@ -46,8 +49,8 @@
4649
.carousel__pagination {
4750
bottom: 50%;
4851
flex-direction: column;
49-
left: auto;
50-
right: 5px;
52+
left: var(--vc-png-left);
53+
right: var(--vc-png-right);
5154
transform: translateY(50%);
5255
}
5356

0 commit comments

Comments
 (0)