Modrinth/components/ui/Pagination.vue
venashial 4d64df37f5
Versatile auth URLs & many UI fixes (#199)
* Make project cards right-align their last element

Spaces out elements in a `.project-card` using `justify-content: space-between;`.

Fixes modrinth/knossos#170

* Automatically set URL for auth redirect

* Make login button use base url or current origin

Allows the login button to work in dev environment

* Remove Axios base URL trailing slash

* Update authUrl() on dashboard to match default

* Remove 'code' query from URL on page load
Allow non-exact paths to highlight mod & dashboard tabs

Fixes modrinth/knossos#200

* Make page 5 button visible on page 4 (pagination)

Fixes modrinth/knossos#184

* Color links on legal pages

Fixes modrinth/knossos#166

* Set max notifications to 5 and ignore duplicates

Fixes modrinth/knossos#175

* Add space above report button when no user desc

Fixes modrinth/knossos#143

* Better text spacing from edge of mobile screen

Fixes modrinth/knossos#179

* Fix slanted bars in modrinth/knossos#57

* Fix checkbox grid and role label

Fixes modrinth/knossos#191

* Move mod 'settings' button to the far right

Fixes modrinth/knossos#138

* Abbreviate minutes to min. when time is too long

Not a perfect solution imo, but works for now

Fixes modrinth/knossos#193

* Fix mobile header margins & add breakpoints

Fixes modrinth/knossos#203

* Clean up nuxt config
Silence babel warning & styleResources

* Upgrade sass-loader to 10.1.1 and remove warning

* Remove added horizontal footer padding

https://github.com/modrinth/knossos/pull/199#discussion_r629011624

* Improve mobile header fix

* Fix up minor inconsistencies in mod header

* Remove hard coded date

* Cleans up pagination to be more intuitive

* Fixes member invite input on moble

* Fix login button when searching mods

* Improved mobile mod search

Consistently sized pagination buttons

Breakpoint for sort buttons on smaller screens

* Consistent link style on text-only pages

* Better 4k support

* Slightly better mobile project-card support

Shuffles categories under mod icon when there is room

* Animate homepage typewriter effect backwards

* Tiny commit to align mod icons in mod headers

* Make processing status include 'Under Review'

This can be later updated once the backend has a separate status

* Create vercel.json

* Update domain auto detection

* Test vercel NODE_ENV

* Remove console.log for debugging hosting services

* Make mobile first + fix shrinked text circle size

* Optimize SVG

* Change media queries to be more mobile first

* Remove `|| window.location.origin`

* re-deploy vercel

* Change "Processing" message to "Under review"
2021-05-27 09:27:13 -07:00

145 lines
2.8 KiB
Vue

<template>
<div v-if="pages.length > 1" class="columns paginates">
<button
:class="{ disabled: currentPage === 1 }"
class="paginate has-icon"
aria-label="Previous Page"
@click="currentPage !== 1 ? switchPage(currentPage - 1) : null"
>
<LeftArrowIcon />
</button>
<div
v-for="(item, index) in pages"
:key="'page-' + item + '-' + index"
:class="{
'page-number': currentPage !== item,
shrink: item > 99,
}"
class="page-number-container"
>
<div v-if="item == '-'" class="has-icon">
<GapIcon />
</div>
<button
v-else
:class="{
'page-number current': currentPage === item,
shrink: item > 99,
}"
@click="currentPage !== item ? switchPage(item) : null"
>
{{ item }}
</button>
</div>
<button
:class="{
disabled: currentPage === pages[pages.length - 1],
}"
class="paginate has-icon"
aria-label="Next Page"
@click="
currentPage !== pages[pages.length - 1]
? switchPage(currentPage + 1)
: null
"
>
<RightArrowIcon />
</button>
</div>
</template>
<script>
import GapIcon from '~/assets/images/utils/gap.svg?inline'
import LeftArrowIcon from '~/assets/images/utils/left-arrow.svg?inline'
import RightArrowIcon from '~/assets/images/utils/right-arrow.svg?inline'
export default {
name: 'Pagination',
components: {
GapIcon,
LeftArrowIcon,
RightArrowIcon,
},
props: {
currentPage: {
type: Number,
default: 1,
},
pages: {
type: Array,
default() {
return []
},
},
},
methods: {
switchPage(newPage) {
this.$emit('switch-page', newPage)
},
},
}
</script>
<style scoped lang="scss">
button {
padding: 0;
margin: 0;
width: 2em;
height: 2em;
border-radius: 2em;
background: transparent;
&.page-number.current {
background: var(--color-button-bg-hover);
color: var(--color-button-text-hover);
cursor: default;
}
&.paginate.disabled {
background: none;
color: var(--color-button-text-disabled);
cursor: default;
}
&:hover {
background: var(--color-button-bg-active);
color: var(--color-button-text-active);
}
}
.has-icon {
display: flex;
align-items: center;
height: 2em;
svg {
width: 1em;
}
}
.page-number-container,
button,
.has-icon {
display: flex;
justify-content: center;
align-items: center;
height: 2em;
width: 2em;
}
.paginates {
height: 2em;
margin: 0.5rem 0;
> div {
margin: 0 0.1em;
}
font-size: 80%;
@media screen and (min-width: 350px) {
font-size: 100%;
}
}
.shrink {
font-size: 0.9rem;
height: 2.225em;
width: 2.225em;
}
</style>