-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from LukaBRa/task-8
Implemented router and pagination
- Loading branch information
Showing
19 changed files
with
412 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: test-on-push | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: npm install | ||
run: | | ||
npm install --force | ||
- name: npm run build | ||
run: | | ||
npm run build | ||
- name: npm run test:unit | ||
run: | | ||
npm run test:unit |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup lang="ts"> | ||
import { useRouter, useRoute, type LocationQueryValue } from 'vue-router'; | ||
import { computed } from 'vue'; | ||
const router = useRouter(); | ||
const route = useRoute(); | ||
const props = defineProps<{ | ||
pageNumber: { | ||
n: number | ||
} | ||
}>(); | ||
const togglePage = (page: number) => { | ||
if(route && route.name == "homepage"){ | ||
router.push(`/?page=${page}`); | ||
} | ||
if(route && route.name == "moviepage"){ | ||
router.push({ path: route.fullPath, query: { page } }); | ||
} | ||
} | ||
const activePage = computed(() => { | ||
if(route && !route.query.page && props.pageNumber.n == 1){ | ||
return true | ||
} | ||
return parseInt(route && route.query.page as string) == props.pageNumber.n; | ||
}); | ||
</script> | ||
|
||
<template> | ||
|
||
<button id="page-number-button" @click="togglePage(pageNumber.n)" :class="{ active: activePage }">{{ pageNumber.n }}</button> | ||
|
||
</template> | ||
|
||
<style scoped> | ||
button { | ||
font-size: 1.1rem; | ||
padding: 5px 10px; | ||
background: transparent; | ||
color: #FFFFFF; | ||
border: none; | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
button.active { | ||
background-color: #F65261; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
import PageNumber from './PageNumber.vue'; | ||
import useMoviesStore from '@/store/moviesStore'; | ||
import { computed } from 'vue'; | ||
const moviesStore = useMoviesStore(); | ||
const pagesNumber = computed(() => { | ||
return Math.ceil(moviesStore.moviesCount / 20); | ||
}); | ||
</script> | ||
|
||
<template> | ||
|
||
<div class="pagination"> | ||
<PageNumber v-for="n in pagesNumber" :pageNumber={n} /> | ||
</div> | ||
|
||
</template> | ||
|
||
<style scoped> | ||
.pagination { | ||
margin-top: 30px; | ||
margin-inline: auto; | ||
width: max-content; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.