fix: profile banner tabs & active status

This commit is contained in:
puriphatt 2024-08-05 11:21:14 +00:00
parent 58a99de1e2
commit c29d33f963

View file

@ -17,6 +17,7 @@ defineProps<{
useToggle?: boolean; useToggle?: boolean;
menu?: { icon: string; color: string; bgColor: string }[]; menu?: { icon: string; color: string; bgColor: string }[];
tabsList?: { name: string; label: string }[];
}>(); }>();
defineEmits<{ defineEmits<{
@ -35,12 +36,17 @@ const toggleStatus = defineModel<string>('toggleStatus', {
default: 'CREATED', default: 'CREATED',
}); });
const currentTab = defineModel<string>('currentTab');
const showOverlay = ref(false); const showOverlay = ref(false);
currentTab.value = 'name1';
</script> </script>
<template> <template>
<q-img <q-img
fit="cover" fit="cover"
class="cover rounded bordered relative-position" class="cover rounded bordered relative-position"
:style="`height: ${tabsList ? '12rem' : '10rem'}`"
:src="coverUrl || fallbackCover || 'blank-cover.png'" :src="coverUrl || fallbackCover || 'blank-cover.png'"
@error="coverUrl = ''" @error="coverUrl = ''"
> >
@ -55,20 +61,17 @@ const showOverlay = ref(false);
)`" )`"
> >
<!-- profile --> <!-- profile -->
<div class="flex items-center full-height q-pl-lg" style="z-index: 999"> <div class="flex items-center full-height q-pl-lg" style="z-index: 1">
<div <div
class="surface-1" class="surface-1"
style=" style="border-radius: 50%; border: 4px solid var(--surface-1)"
border-radius: 50%;
border: 4px solid var(--surface-1);
overflow: hidden;
"
> >
<div <!-- <div
class="avatar__status" class="avatar__status"
style="z-index: 2" style="z-index: 2"
:style="`${active ? 'background-color: hsla(var(--positive-bg) / 1)' : 'background-color: hsla(var(--text-mute) / 1)'}`" :style="`${active ? 'background-color: hsla(var(--positive-bg) / 1)' : 'background-color: hsla(var(--text-mute) / 1)'}`"
></div> ></div> -->
<q-avatar <q-avatar
size="6rem" size="6rem"
font-size="3rem" font-size="3rem"
@ -96,62 +99,112 @@ const showOverlay = ref(false);
</template> </template>
</q-img> </q-img>
<q-icon v-else :name="icon || 'mdi-account'" /> <q-icon v-else :name="icon || 'mdi-account'" />
<q-badge
<!-- <Transition name="slide-fade"> --> class="absolute-bottom-right"
<div style="
v-if="showOverlay && !readonly" border-radius: 10px;
class="absolute-bottom text-caption flex items-center justify-center upload-overlay" width: 20px;
:class="{ dark: $q.dark.isActive }" height: 20px;
@click.stop="$emit('edit')" z-index: 2;
background: var(--surface-1);
"
> >
{{ $t('editImage') }} <q-badge
</div> class="absolute-center"
<!-- </Transition> --> style="border-radius: 7px; width: 14px; height: 14px"
:style="`background: hsl(var(${active ? '--positive-bg' : '--text-mute'}))`"
></q-badge>
</q-badge>
<Transition name="slide-fade">
<div
v-if="showOverlay && !readonly"
class="absolute text-caption full-width full-height"
style="border-radius: 50% 50%; overflow: hidden"
:class="{ dark: $q.dark.isActive }"
>
<div
class="upload-overlay absolute-bottom flex items-center justify-center"
@click.stop="$emit('edit')"
>
{{ $t('editImage') }}
</div>
</div>
</Transition>
</q-avatar> </q-avatar>
</div> </div>
</div> </div>
<!-- text --> <!-- text -->
<div <div
class="absolute-bottom relative-position justify-between row text-cover" class="absolute-bottom relative-position column text-cover justify-between no-wrap"
:class="{ dark: $q.dark.isActive }" :class="{ dark: $q.dark.isActive }"
> >
<div class="column"> <div
<span class="text-bold q-pt-xs text-body1">{{ title }}</span> class="row justify-between full-height"
<span class="app-text-muted">{{ caption }}</span> style="padding-left: 150px"
>
<div class="column">
<span class="text-bold q-pt-xs text-body1">{{ title }}</span>
<span class="app-text-muted">{{ caption }}</span>
</div>
<!-- icon -->
<div class="row items-center q-pr-lg" style="z-index: 1">
<span v-if="toggleTitle" class="q-mr-md app-text-muted-2">
{{ toggleTitle }}
</span>
<q-toggle
v-if="useToggle"
id="toggle-status"
dense
size="md"
padding="none"
:model-value="toggleStatus !== 'INACTIVE'"
@click="$emit('update:toggleStatus', toggleStatus)"
/>
<q-separator
v-if="useToggle"
vertical
class="q-my-lg"
spaced="lg"
style="background: hsl(var(--text-mute))"
/>
<div class="q-gutter-x-sm">
<q-btn
v-for="(item, n) in menu"
:key="n"
flat
size="sm"
class="q-pa-xs rounded"
:icon="item.icon"
:style="`background-color: ${item.bgColor}; color: ${item.color}`"
/>
</div>
</div>
</div> </div>
<!-- icon --> <div class="row" v-if="tabsList && currentTab">
<div class="row items-center q-pr-lg" style="z-index: 1"> <div class="row q-px-sm full-width">
<span v-if="toggleTitle" class="q-mr-md app-text-muted-2"> <q-tabs
{{ toggleTitle }} inline-label
</span> mobile-arrows
<q-toggle dense
v-if="useToggle" class="app-text-muted full-width"
id="toggle-status" v-model="currentTab"
dense active-class="active-tab"
size="md" indicator-color="transparent"
padding="none" align="left"
:model-value="toggleStatus !== 'INACTIVE'" >
@click="$emit('update:toggleStatus', toggleStatus)" <q-tab
/> :id="`tab-${tab.label}`"
<q-separator v-for="tab in tabsList"
v-if="useToggle" v-bind:key="tab.name"
vertical class="content-tab text-capitalize"
class="q-my-lg" :name="tab.name"
spaced="lg" :label="$t(tab.label)"
style="background: hsl(var(--text-mute))" />
/> </q-tabs>
<div class="q-gutter-x-sm">
<q-btn
v-for="(item, n) in menu"
:key="n"
flat
size="sm"
class="q-pa-xs rounded"
:icon="item.icon"
:style="`background-color: ${item.bgColor}; color: ${item.color}`"
/>
</div> </div>
</div> </div>
</div> </div>
@ -161,7 +214,6 @@ const showOverlay = ref(false);
<style lang="scss"> <style lang="scss">
.cover { .cover {
height: 15vh;
overflow: hidden; overflow: hidden;
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
@ -169,8 +221,7 @@ const showOverlay = ref(false);
} }
.text-cover { .text-cover {
height: 7.5vh; height: 50%;
padding-left: 150px;
background: linear-gradient( background: linear-gradient(
90deg, 90deg,
rgba(255, 255, 255, 1) 35%, rgba(255, 255, 255, 1) 35%,
@ -201,7 +252,7 @@ const showOverlay = ref(false);
} }
.upload-overlay { .upload-overlay {
top: 3.5rem; top: 60%;
background-color: hsla(var(--gray-10-hsl) / 0.5); background-color: hsla(var(--gray-10-hsl) / 0.5);
color: white; color: white;