separate book form icons in a new component
This commit is contained in:
@@ -15,9 +15,7 @@ import {
|
|||||||
import { useTemplateRef, nextTick } from 'vue'
|
import { useTemplateRef, nextTick } from 'vue'
|
||||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router'
|
import { useRouter, onBeforeRouteUpdate } from 'vue-router'
|
||||||
import { VRating } from 'vuetify/components/VRating'
|
import { VRating } from 'vuetify/components/VRating'
|
||||||
import BigIcon from './BigIcon.vue'
|
import BookFormIcons from './BookFormIcons.vue'
|
||||||
import BookDateWidget from './BookDateWidget.vue'
|
|
||||||
import DateWidget from './DateWidget.vue'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -92,12 +90,6 @@ function onEndReadDateChange(d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStartReadExpanded() {
|
|
||||||
let isStartReadDateSet = data.value.startReadDate ? true : false
|
|
||||||
let isReadUnset = !data.value.read ? true : false
|
|
||||||
return isStartReadDateSet && isReadUnset
|
|
||||||
}
|
|
||||||
|
|
||||||
function goToAuthor() {
|
function goToAuthor() {
|
||||||
router.push('/author/' + data.value.authorId)
|
router.push('/author/' + data.value.authorId)
|
||||||
}
|
}
|
||||||
@@ -131,90 +123,15 @@ function goToAuthor() {
|
|||||||
<div class="my-5" v-if="data.openlibraryid">OLID: {{ data.openlibraryid }}</div>
|
<div class="my-5" v-if="data.openlibraryid">OLID: {{ data.openlibraryid }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="iconscontainer" :class="data.read ? 'remove-border-bottom' : ''">
|
<BookFormIcons
|
||||||
<div
|
v-bind="data"
|
||||||
class="bigiconcontainer"
|
@on-want-read-icon-click="onWantReadIconClick"
|
||||||
:class="
|
@on-start-read-icon-click="onStartReadIconClick"
|
||||||
data.wantread ? 'has-text-dark has-background-text border-radius-wantread-fill' : ''
|
@on-read-icon-click="onReadIconClick"
|
||||||
"
|
@on-start-read-date-change="onStartReadDateChange"
|
||||||
>
|
@on-end-read-date-change="onEndReadDateChange"
|
||||||
<BigIcon
|
|
||||||
icon="BIconEye"
|
|
||||||
:legend="$t('bookform.wantread')"
|
|
||||||
:isSet="data.wantread"
|
|
||||||
@click="onWantReadIconClick"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
class="bigiconcontainer is-hidden-desktop"
|
|
||||||
:class="isStartReadExpanded() ? 'has-text-dark has-background-text' : ''"
|
|
||||||
>
|
|
||||||
<BigIcon
|
|
||||||
icon="BIconBook"
|
|
||||||
:legend="$t('bookform.wantread')"
|
|
||||||
:is-set="isStartReadExpanded()"
|
|
||||||
:is-readonly="data.read"
|
|
||||||
@click="data.read ? null : onStartReadIconClick()"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="bigiconcontainer is-hidden-desktop"
|
|
||||||
:class="data.read ? 'has-text-dark has-background-text border-radius-right-fill' : ''"
|
|
||||||
>
|
|
||||||
<BigIcon
|
|
||||||
icon="BIconCheckCircle"
|
|
||||||
:legend="$t('bookform.read')"
|
|
||||||
:isSet="data.read"
|
|
||||||
@click="onReadIconClick"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<BookDateWidget
|
|
||||||
class="is-hidden-mobile"
|
|
||||||
icon="BIconBook"
|
|
||||||
:legend="$t('bookform.startread')"
|
|
||||||
:start-read-date="data.startReadDate"
|
|
||||||
:is-expanded="isStartReadExpanded()"
|
|
||||||
:is-readonly="data.read"
|
|
||||||
@onStartDateChange="onStartReadDateChange"
|
|
||||||
@onIconClick="onStartReadIconClick"
|
|
||||||
/>
|
|
||||||
<BookDateWidget
|
|
||||||
class="is-hidden-mobile"
|
|
||||||
icon="BIconCheckCircle"
|
|
||||||
:legend="$t('bookform.read')"
|
|
||||||
:start-read-date="data.startReadDate"
|
|
||||||
use-end-date
|
|
||||||
last-widget
|
|
||||||
:endReadDate="data.endReadDate"
|
|
||||||
:isExpanded="data.read"
|
|
||||||
@onStartDateChange="onStartReadDateChange"
|
|
||||||
@onEndDateChange="onEndReadDateChange"
|
|
||||||
@onIconClick="onReadIconClick"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div ref="mobiledates" class="mobile-dates pt-3 is-hidden-desktop">
|
|
||||||
<div class="mobiledate">
|
|
||||||
<DateWidget
|
|
||||||
v-if="isStartReadExpanded() || data.read"
|
|
||||||
dateinputid="startread"
|
|
||||||
dateinputlabel="bookdatewidget.started"
|
|
||||||
:initdate="data.startReadDate"
|
|
||||||
is-horizontal
|
|
||||||
@onDateChange="(d) => onStartReadDateChange(d)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="mobiledate pt-2">
|
|
||||||
<DateWidget
|
|
||||||
v-if="data.read"
|
|
||||||
dateinputid="endread"
|
|
||||||
dateinputlabel="bookdatewidget.finished"
|
|
||||||
:initdate="data.endReadDate"
|
|
||||||
is-horizontal
|
|
||||||
@onDateChange="(d) => onEndReadDateChange(d)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -232,38 +149,10 @@ img {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconscontainer {
|
|
||||||
border: solid;
|
|
||||||
border-radius: 50px;
|
|
||||||
width: 250px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mobile-dates {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mobiledate {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
.left-panel {
|
.left-panel {
|
||||||
margin-left: 3rem;
|
margin-left: 3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-radius-wantread-fill {
|
|
||||||
border-radius: 45px 45px 0px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.remove-border-bottom {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bigiconcontainer {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
@media (max-width: 1024px) {
|
||||||
@@ -273,27 +162,10 @@ img {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bigiconcontainer {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-radius-wantread-fill {
|
|
||||||
border-radius: 38px 0px 0px 38px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconscontainer {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-radius-right-fill {
|
|
||||||
border-radius: 0px 38px 38px 0px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
161
front/src/BookFormIcons.vue
Normal file
161
front/src/BookFormIcons.vue
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
<script setup>
|
||||||
|
import BigIcon from './BigIcon.vue'
|
||||||
|
import BookDateWidget from './BookDateWidget.vue'
|
||||||
|
import DateWidget from './DateWidget.vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
wantread: Boolean,
|
||||||
|
startReadDate: String,
|
||||||
|
endReadDate: String,
|
||||||
|
read: Boolean,
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
'onWantReadIconClick',
|
||||||
|
'onStartReadIconClick',
|
||||||
|
'onReadIconClick',
|
||||||
|
'onStartReadDateChange',
|
||||||
|
'onEndReadDateChange',
|
||||||
|
])
|
||||||
|
|
||||||
|
function isStartReadExpanded() {
|
||||||
|
let isStartReadDateSet = props.startReadDate ? true : false
|
||||||
|
let isReadUnset = !props.read ? true : false
|
||||||
|
return isStartReadDateSet && isReadUnset
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="iconscontainer" :class="props.read ? 'remove-border-bottom' : ''">
|
||||||
|
<div
|
||||||
|
class="bigiconcontainer"
|
||||||
|
:class="props.wantread ? 'has-text-dark has-background-text border-radius-wantread-fill' : ''"
|
||||||
|
>
|
||||||
|
<BigIcon
|
||||||
|
icon="BIconEye"
|
||||||
|
:legend="$t('bookform.wantread')"
|
||||||
|
:isSet="props.wantread"
|
||||||
|
@click="$emit('onWantReadIconClick')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="bigiconcontainer is-hidden-desktop"
|
||||||
|
:class="isStartReadExpanded() ? 'has-text-dark has-background-text' : ''"
|
||||||
|
>
|
||||||
|
<BigIcon
|
||||||
|
icon="BIconBook"
|
||||||
|
:legend="$t('bookform.wantread')"
|
||||||
|
:is-set="isStartReadExpanded()"
|
||||||
|
:is-readonly="props.read"
|
||||||
|
@click="props.read ? null : $emit('onStartReadIconClick')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="bigiconcontainer is-hidden-desktop"
|
||||||
|
:class="props.read ? 'has-text-dark has-background-text border-radius-right-fill' : ''"
|
||||||
|
>
|
||||||
|
<BigIcon
|
||||||
|
icon="BIconCheckCircle"
|
||||||
|
:legend="$t('bookform.read')"
|
||||||
|
:isSet="props.read"
|
||||||
|
@click="$emit('onReadIconClick')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<BookDateWidget
|
||||||
|
class="is-hidden-mobile"
|
||||||
|
icon="BIconBook"
|
||||||
|
:legend="$t('bookform.startread')"
|
||||||
|
:start-read-date="props.startReadDate"
|
||||||
|
:is-expanded="isStartReadExpanded()"
|
||||||
|
:is-readonly="props.read"
|
||||||
|
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
||||||
|
@onIconClick="$emit('onStartReadIconClick')"
|
||||||
|
/>
|
||||||
|
<BookDateWidget
|
||||||
|
class="is-hidden-mobile"
|
||||||
|
icon="BIconCheckCircle"
|
||||||
|
:legend="$t('bookform.read')"
|
||||||
|
:start-read-date="props.startReadDate"
|
||||||
|
use-end-date
|
||||||
|
last-widget
|
||||||
|
:endReadDate="props.endReadDate"
|
||||||
|
:isExpanded="props.read"
|
||||||
|
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
||||||
|
@onEndDateChange="(d) => $emit('onEndReadDateChange', d)"
|
||||||
|
@onIconClick="$emit('onReadIconClick')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ref="mobiledates" class="mobile-dates pt-3 is-hidden-desktop">
|
||||||
|
<div class="mobiledate">
|
||||||
|
<DateWidget
|
||||||
|
v-if="isStartReadExpanded() || props.read"
|
||||||
|
dateinputid="startread"
|
||||||
|
dateinputlabel="bookdatewidget.started"
|
||||||
|
:initdate="props.startReadDate"
|
||||||
|
is-horizontal
|
||||||
|
@onDateChange="(d) => $emit('onStartReadDateChange', d)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="mobiledate pt-2">
|
||||||
|
<DateWidget
|
||||||
|
v-if="props.read"
|
||||||
|
dateinputid="endread"
|
||||||
|
dateinputlabel="bookdatewidget.finished"
|
||||||
|
:initdate="props.endReadDate"
|
||||||
|
is-horizontal
|
||||||
|
@onDateChange="(d) => $emit('onEndReadDateChange', d)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.iconscontainer {
|
||||||
|
border: solid;
|
||||||
|
border-radius: 50px;
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-dates {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobiledate {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.border-radius-wantread-fill {
|
||||||
|
border-radius: 45px 45px 0px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-border-bottom {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigiconcontainer {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.border-radius-wantread-fill {
|
||||||
|
border-radius: 38px 0px 0px 38px;
|
||||||
|
}
|
||||||
|
.bigiconcontainer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconscontainer {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-radius-right-fill {
|
||||||
|
border-radius: 0px 38px 38px 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user