Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
extract TopBar.vue from ProductItem.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Aug 14, 2023
1 parent cbc828c commit 53d5b4c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 45 deletions.
48 changes: 3 additions & 45 deletions src/views/product/item/ProductItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,7 @@
style="block-size: 100%; position: relative; padding-bottom: 96px"
>
<div style="max-width: 960px; margin: auto">
<div class="top-bar">
<v-tooltip v-if="node && node.type_" location="top">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
variant="plain"
icon
:to="{
name: 'ProductList',
params: { productTypeName: node.type_.name },
}"
>
<v-icon icon="mdi-arrow-left"></v-icon>
</v-btn>
</template>
<span>Back to the list</span>
</v-tooltip>
<v-tooltip location="top">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
:disabled="loading"
variant="plain"
icon
@click="refresh()"
>
<v-icon icon="mdi-refresh"></v-icon>
</v-btn>
</template>
<span>Refresh</span>
</v-tooltip>
<v-spacer></v-spacer>
</div>
<top-bar :node="node" :disabled="loading" @refresh="refresh()"></top-bar>
<div>
<div v-if="loading">
<v-progress-circular
Expand Down Expand Up @@ -73,11 +41,11 @@ import { ref, computed, withDefaults, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useProductByTypeIdAndNameQuery } from "@/generated/graphql";
import { useQueryState } from "@/utils/query-state";
import TopBar from "./TopBar.vue";
import ProductItemCard from "@/components/product/item-card/ProductItemCard.vue";
import { useQueryState } from "@/utils/query-state";
// Use any for productItemCard because Component causes an error for unknown reason.
interface Props {
productTypeId: number;
Expand Down Expand Up @@ -141,13 +109,3 @@ function onTypeChanged(event: string) {
const queryState = useQueryState(query, { isNull: () => node.value === null });
const { loading, loaded, notFound, error, refresh, devtoolState } = queryState;
</script>

<style scoped>
.top-bar {
display: flex;
min-block-size: 56px;
justify-content: flex-start;
align-items: center;
padding: 0 1rem;
}
</style>
62 changes: 62 additions & 0 deletions src/views/product/item/TopBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div class="top-bar">
<v-tooltip v-if="node && node.type_" location="top">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
variant="plain"
icon
:to="{
name: 'ProductList',
params: { productTypeName: node.type_.name },
}"
>
<v-icon icon="mdi-arrow-left"></v-icon>
</v-btn>
</template>
<span>Back to the list</span>
</v-tooltip>
<v-tooltip location="top">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
:disabled="disabled"
variant="plain"
icon
@click="emit('refresh')"
>
<v-icon icon="mdi-refresh"></v-icon>
</v-btn>
</template>
<span>Refresh</span>
</v-tooltip>
</div>
</template>

<script setup lang="ts">
import { ProductQuery } from "@/generated/graphql";
type Product = ProductQuery["product"];
interface Props {
node: Product | undefined;
disabled?: boolean;
}
interface Emits {
(event: "refresh"): void;
}
const prop = defineProps<Props>();
const emit = defineEmits<Emits>();
</script>

<style scoped>
.top-bar {
display: flex;
min-block-size: 56px;
justify-content: flex-start;
align-items: center;
padding: 0 1rem;
}
</style>

0 comments on commit 53d5b4c

Please sign in to comment.