AmPagination.vue
251 lines
| 1 | <template> |
| 2 | <el-pagination |
| 3 | v-model:current-page="currentPage" |
| 4 | class="am-pagination" |
| 5 | :small="props.small" |
| 6 | :background="props.background" |
| 7 | :page-size="props.pageSize" |
| 8 | :default-page-size="props.defaultPageSize" |
| 9 | :total="props.total" |
| 10 | :page-count="props.pageCount" |
| 11 | :pager-count="props.pagerCount" |
| 12 | :default-current-page="props.defaultCurrentPage" |
| 13 | :layout="props.layout" |
| 14 | :page-sizes="props.pageSizes" |
| 15 | :prev-text="props.prevText" |
| 16 | :prev-icon="props.prevIcon" |
| 17 | :next-text="props.nextText" |
| 18 | :next-icon="props.nextIcon" |
| 19 | :disabled="props.disabled" |
| 20 | :hide-on-single-page="props.hideOnSinglePage" |
| 21 | :popper-class="props.popperClass" |
| 22 | :style="{ ...cssVars }" |
| 23 | @size-change="(val) => emits('size-change', val)" |
| 24 | @current-change="(val) => emits('current-change', val)" |
| 25 | @prev-click="(val) => emits('prev-click', val)" |
| 26 | @next-click="(val) => emits('next-click', val)" |
| 27 | /> |
| 28 | </template> |
| 29 | |
| 30 | <script setup> |
| 31 | import { ref, inject, computed } from 'vue' |
| 32 | import { useColorTransparency } from '../../../assets/js/common/colorManipulation' |
| 33 | import IconArrowLeft from '../icons/IconArrowLeft.vue' |
| 34 | import IconArrowRight from '../icons/IconArrowRight.vue' |
| 35 | |
| 36 | // * Component Props |
| 37 | const props = defineProps({ |
| 38 | small: { |
| 39 | type: Boolean, |
| 40 | default: false, |
| 41 | }, |
| 42 | background: { |
| 43 | type: Boolean, |
| 44 | default: false, |
| 45 | }, |
| 46 | currentPage: { |
| 47 | type: Number, |
| 48 | }, |
| 49 | pageSize: { |
| 50 | type: Number, |
| 51 | default: 10, |
| 52 | }, |
| 53 | defaultPageSize: { |
| 54 | type: Number, |
| 55 | }, |
| 56 | total: { |
| 57 | type: Number, |
| 58 | }, |
| 59 | pageCount: { |
| 60 | type: Number, |
| 61 | }, |
| 62 | pagerCount: { |
| 63 | type: Number, |
| 64 | default: 7, |
| 65 | }, |
| 66 | defaultCurrentPage: { |
| 67 | type: Number, |
| 68 | }, |
| 69 | layout: { |
| 70 | type: String, |
| 71 | default: 'prev, pager, next, jumper, ->, total, slot', |
| 72 | }, |
| 73 | pageSizes: { |
| 74 | type: Array, |
| 75 | default: () => [10, 20, 30, 40, 50, 100], |
| 76 | }, |
| 77 | popperClass: { |
| 78 | type: String, |
| 79 | }, |
| 80 | prevText: { |
| 81 | type: String, |
| 82 | }, |
| 83 | prevIcon: { |
| 84 | type: [String, Object, Function], |
| 85 | default: () => IconArrowLeft, |
| 86 | }, |
| 87 | nextText: { |
| 88 | type: String, |
| 89 | default: '', |
| 90 | }, |
| 91 | nextIcon: { |
| 92 | type: [String, Object, Function], |
| 93 | default: () => IconArrowRight, |
| 94 | }, |
| 95 | disabled: { |
| 96 | type: Boolean, |
| 97 | default: false, |
| 98 | }, |
| 99 | hideOnSinglePage: { |
| 100 | type: Boolean, |
| 101 | }, |
| 102 | }) |
| 103 | |
| 104 | // * Component Emits |
| 105 | const emits = defineEmits([ |
| 106 | 'size-change', |
| 107 | 'current-change', |
| 108 | 'prev-click', |
| 109 | 'next-click', |
| 110 | 'update:current-page', |
| 111 | ]) |
| 112 | |
| 113 | let currentPage = computed({ |
| 114 | get: () => { |
| 115 | return props.currentPage |
| 116 | }, |
| 117 | set: (val) => { |
| 118 | emits('update:current-page', val) |
| 119 | }, |
| 120 | }) |
| 121 | |
| 122 | // * Font Vars |
| 123 | let amFonts = inject( |
| 124 | 'amFonts', |
| 125 | ref({ |
| 126 | fontFamily: 'Amelia Roboto, sans-serif', |
| 127 | fontUrl: '', |
| 128 | customFontFamily: '', |
| 129 | fontFormat: '', |
| 130 | customFontSelected: false, |
| 131 | }), |
| 132 | ) |
| 133 | |
| 134 | // * Color Vars |
| 135 | let amColors = inject( |
| 136 | 'amColors', |
| 137 | ref({ |
| 138 | colorPrimary: '#1246D6', |
| 139 | colorMainBgr: '#FFFFFF', |
| 140 | colorMainText: '#1A2C37', |
| 141 | }), |
| 142 | ) |
| 143 | |
| 144 | // * CSS Variables |
| 145 | let cssVars = computed(() => { |
| 146 | return { |
| 147 | '--am-c-pagination-bgr': amColors.value.colorMainBgr, |
| 148 | '--am-c-pagination-text': amColors.value.colorMainText, |
| 149 | '--am-c-pagination-text-op60': useColorTransparency(amColors.value.colorMainText, 0.6), |
| 150 | '--am-c-pagination-border': amColors.value.colorMainBgr, |
| 151 | '--am-c-pagination-active': amColors.value.colorPrimary, |
| 152 | '--am-rad-pagination': '6px', |
| 153 | '--am-font-family': amFonts.value.fontFamily, |
| 154 | } |
| 155 | }) |
| 156 | </script> |
| 157 | |
| 158 | <style lang="scss"> |
| 159 | @mixin am-pagination-block { |
| 160 | .am-pagination { |
| 161 | // -c- color |
| 162 | // -rad- border radius |
| 163 | // -fs- font size |
| 164 | // -bgr background |
| 165 | |
| 166 | display: flex; |
| 167 | align-items: center; |
| 168 | justify-content: center; |
| 169 | |
| 170 | * { |
| 171 | box-sizing: border-box; |
| 172 | font-family: var(--am-font-family), sans-serif; |
| 173 | } |
| 174 | |
| 175 | .el-pager { |
| 176 | display: flex; |
| 177 | align-items: center; |
| 178 | justify-content: center; |
| 179 | |
| 180 | .number { |
| 181 | width: 28px; |
| 182 | min-width: 28px; |
| 183 | height: 28px; |
| 184 | font-size: 14px; |
| 185 | font-weight: 500; |
| 186 | line-height: 26px; |
| 187 | color: var(--am-c-pagination-text); |
| 188 | background: var(--am-c-pagination-bgr); |
| 189 | border: 2px solid var(--am-c-pagination-border); |
| 190 | border-radius: var(--am-rad-pagination); |
| 191 | margin: 2px; |
| 192 | |
| 193 | &.is-active { |
| 194 | --am-c-pagination-bgr: var(--am-c-primary); |
| 195 | --am-c-pagination-border: var(--am-c-primary); |
| 196 | --am-c-pagination-text: var(--am-c-card-bgr, var(--am-c-main-bgr)); |
| 197 | } |
| 198 | |
| 199 | &:hover { |
| 200 | --am-c-pagination-border: var(--am-c-primary); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | .btn-quickprev, |
| 205 | .btn-quicknext { |
| 206 | display: inline-flex; |
| 207 | align-items: center; |
| 208 | justify-content: center; |
| 209 | |
| 210 | &.el-icon { |
| 211 | color: var(--am-c-pagination-text); |
| 212 | background-color: transparent; |
| 213 | |
| 214 | &:hover { |
| 215 | --am-c-pagination-text: var(--am-c-primary); |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | .btn-next, |
| 222 | .btn-prev { |
| 223 | color: var(--am-c-pagination-text); |
| 224 | background-color: var(--am-c-pagination-bgr); |
| 225 | |
| 226 | .el-icon { |
| 227 | display: flex; |
| 228 | } |
| 229 | |
| 230 | &:not(:disabled):hover { |
| 231 | --am-c-pagination-text: var(--am-c-primary); |
| 232 | } |
| 233 | |
| 234 | &:disabled { |
| 235 | --am-c-pagination-text: var(--am-c-pagination-text-op60); |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // public |
| 242 | .amelia-v2-booking #amelia-container { |
| 243 | @include am-pagination-block; |
| 244 | } |
| 245 | |
| 246 | // admin |
| 247 | #amelia-app-backend-new { |
| 248 | @include am-pagination-block; |
| 249 | } |
| 250 | </style> |
| 251 |