| | |
| | | |
| | | import * as itemOffset from '../lib/itemOffset.js' |
| | | import {onKeyStroke} from "@vueuse/core" |
| | | import IconKeyboard from "@/components/icons/IconKeyboard.vue" |
| | | import KeyboardToggle from "@/components/KeyboardToggle.vue" |
| | | import {ref} from "vue" |
| | | |
| | | const props = defineProps({ |
| | | total: Number, |
| | |
| | | |
| | | /////// KEYBOARD //////////////////////////////////////////////////////////////// |
| | | |
| | | onKeyStroke(["ArrowLeft", "ArrowRight", "Home", "End"], (e) => { |
| | | onKeyStroke(["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"], (e) => { |
| | | let multiplier = 1 |
| | | switch (e.key) { |
| | | case "ArrowLeft": |
| | |
| | | multiplier = e.shiftKey ? 10 : 1 |
| | | goNext(multiplier) |
| | | break |
| | | case "Home": |
| | | case "ArrowUp": |
| | | goStart() |
| | | break |
| | | case "End": |
| | | case "ArrowDown": |
| | | goEnd() |
| | | break |
| | | } |
| | | }) |
| | | |
| | | /////// keyboard //////////////////////////////////////////////////////////////// |
| | | |
| | | const keyboardVisible = ref(false) |
| | | function toggleKeyboard (value) { |
| | | console.log("toggleKeyboard", value) |
| | | keyboardVisible.value = value |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | |
| | | <div class="pagination"> |
| | | <div class="pagination-buttons"> |
| | | |
| | | <input type="button" @click="goStart()" class="start" value="«"> |
| | | <input type="button" @click="goPrev()" class="prev" value="‹"> |
| | | <span class="current"> |
| | | {{ offset }} - {{ offset + limit }} |
| | | / {{ total }} |
| | | </span> |
| | | <span class="current">{{ offset }} - {{ offset + limit }} / {{ total }}</span> |
| | | <input type="button" @click="goNext()" class="next" value="›"> |
| | | <input type="button" @click="goEnd()" class="end" value="»"> |
| | | <KeyboardToggle :initial="false" @toggle="toggleKeyboard" style="color: #666" /> |
| | | </div> |
| | | <small class="pagination-info" v-show="keyboardVisible"> |
| | | <em>Keyboard control:</em> |
| | | <span class="spacer" /> |
| | | <kbd class="bigger">◃</kbd> previous page |
| | | <span class="spacer" /> |
| | | <kbd class="bigger">▹</kbd> next page |
| | | <span class="spacer" /> |
| | | <kbd>SHIFT</kbd> + <kbd class="bigger">◃</kbd> {{limit * 10}} backward |
| | | <span class="spacer" /> |
| | | <kbd>SHIFT</kbd> + <kbd class="bigger">▹</kbd> {{limit * 10}} forward |
| | | <span class="spacer" /> |
| | | <kbd class="bigger">▵</kbd> start |
| | | <span class="spacer" /> |
| | | <kbd class="bigger">▿</kbd> end |
| | | </small> |
| | | </div> |
| | | |
| | | </template> |
| | | |
| | | <style scoped lang="stylus"> |
| | | |
| | | .pagination-info |
| | | margin-top .5em; |
| | | display flex; |
| | | gap .5em |
| | | padding .33em .66em; |
| | | align-items center; |
| | | background-color #f1f1f1 |
| | | .spacer |
| | | width 2em; |
| | | height 1px |
| | | display inline-block; |
| | | //background-color black |
| | | |
| | | kbd |
| | | border 1px solid #777 |
| | | border-radius 4px |
| | | font-size 120%; |
| | | line-height 50% |
| | | min-width 1rem; |
| | | height 1rem |
| | | padding 3px; |
| | | display inline-flex; |
| | | align-items center; |
| | | justify-content center; |
| | | |
| | | kbd.bigger |
| | | font-size 220% |
| | | line-height 0 |
| | | |
| | | |
| | | .pagination |
| | | display flex; |
| | | flex-direction column |
| | | align-items center; |
| | | margin -1em 0 1em 0; |
| | | .pagination-buttons |
| | | font-size 1.33rem |
| | | display flex; |
| | | gap 1em |
| | | align-items center; |
| | | justify-content center; |
| | | margin -1em 0 1em 0; |
| | | |
| | | & > div |
| | | cursor: pointer |
| | |
| | | border none |
| | | width 1em |
| | | |
| | | |
| | | button |
| | | display inline-flex; |
| | | align-items center; |
| | | justify-content center; |
| | | border none |
| | | background-color transparent; |
| | | cursor pointer |
| | | &:hover |
| | | background-color #eee; |
| | | |
| | | |
| | | </style> |