TheButton global component (#425)

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-05-24 10:12:46 -08:00 committed by GitHub
parent fd1b54ae70
commit 034a21e203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 283 additions and 175 deletions

File diff suppressed because one or more lines are too long

View File

@ -78,5 +78,4 @@ export default {
:root { :root {
scrollbar-color: transparent transparent; scrollbar-color: transparent transparent;
} }
</style> </style>

View File

@ -9,9 +9,7 @@
<MealPlanCard v-model="mealPlan.planDays" /> <MealPlanCard v-model="mealPlan.planDays" />
<v-row align="center" justify="end"> <v-row align="center" justify="end">
<v-card-actions> <v-card-actions>
<v-btn color="success" text @click="update"> <TheButton update @click="update" />
{{ $t("general.update") }}
</v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
</v-card-actions> </v-card-actions>
</v-row> </v-row>

View File

@ -1,6 +1,6 @@
<template> <template>
<div @click="$emit('click')">
<v-img <v-img
@click="$emit('click')"
:height="height" :height="height"
v-if="!fallBackImage" v-if="!fallBackImage"
:src="getImage(slug)" :src="getImage(slug)"
@ -9,7 +9,7 @@
> >
<slot> </slot> <slot> </slot>
</v-img> </v-img>
<div class="icon-slot" v-else> <div class="icon-slot" v-else @click="$emit('click')">
<div> <div>
<slot> </slot> <slot> </slot>
</div> </div>
@ -17,7 +17,6 @@
{{ $globals.icons.primary }} {{ $globals.icons.primary }}
</v-icon> </v-icon>
</div> </div>
</div>
</template> </template>
<script> <script>

View File

@ -0,0 +1,158 @@
<template>
<v-btn
:color="btnAttrs.color"
:small="small"
:x-small="xSmall"
:loading="loading"
@click="$emit('click')"
:outlined="btnStyle.outlined"
:text="btnStyle.text"
>
<v-icon left>
<slot name="icon">
{{ btnAttrs.icon }}
</slot>
</v-icon>
<slot>
{{ btnAttrs.text }}
</slot>
</v-btn>
</template>
<script>
export default {
name: "theButton",
props: {
// Types
cancel: {
type: Boolean,
default: false,
},
create: {
type: Boolean,
default: false,
},
update: {
type: Boolean,
default: false,
},
edit: {
type: Boolean,
default: false,
},
delete: {
type: Boolean,
default: false,
},
// Property
loading: {
type: Boolean,
default: false,
},
// Styles
small: {
type: Boolean,
default: false,
},
xSmall: {
type: Boolean,
default: false,
},
secondary: {
type: Boolean,
default: false,
},
minor: {
type: Boolean,
default: false,
},
},
data() {
return {
buttonOptions: {
create: {
text: this.$t("general.create"),
icon: this.$globals.icons.create,
color: "success",
},
update: {
text: this.$t("general.update"),
icon: this.$globals.icons.update,
color: "success",
},
save: {
text: this.$t("general.save"),
icon: this.$globals.icons.save,
color: "success",
},
edit: {
text: this.$t("general.edit"),
icon: this.$globals.icons.edit,
color: "info",
},
delete: {
text: this.$t("general.delete"),
icon: this.$globals.icons.delete,
color: "error",
},
cancel: {
text: this.$t("general.cancel"),
icon: this.$globals.icons.close,
color: "grey",
},
},
buttonStyles: {
defaults: {
text: false,
outlined: false,
},
secondary: {
text: false,
outlined: true,
},
minor: {
outlined: false,
text: true,
},
},
};
},
computed: {
btnAttrs() {
if (this.delete) {
return this.buttonOptions.delete;
} else if (this.update) {
return this.buttonOptions.update;
} else if (this.edit) {
return this.buttonOptions.edit;
} else if (this.cancel) {
this.setMinor();
return this.buttonOptions.cancel;
} else if (this.save) {
return this.buttonOptions.save;
}
return this.buttonOptions.create;
},
btnStyle() {
if (this.secondary) {
return this.buttonStyles.secondary;
} else if (this.minor) {
return this.buttonStyles.minor;
}
return this.buttonStyles.defaults;
},
},
methods: {
setMinor() {
this.buttonStyles.defaults = this.buttonStyles.minor;
},
setSecondary() {
this.buttonStyles.defaults = this.buttonStyles.secondary;
},
},
};
</script>
<style lang="scss" scoped>
</style>

View File

@ -24,13 +24,9 @@
<v-text-field dense :label="inputLabel" v-model="itemName" :rules="[rules.required]"></v-text-field> <v-text-field dense :label="inputLabel" v-model="itemName" :rules="[rules.required]"></v-text-field>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<TheButton cancel @click="dialog = false" />
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="grey" text @click="dialog = false"> <TheButton type="submit" create :disabled="!itemName" />
{{ $t("general.cancel") }}
</v-btn>
<v-btn color="success" text type="submit" :disabled="!itemName">
{{ $t("general.create") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-form> </v-form>
</v-card> </v-card>

View File

@ -50,7 +50,7 @@
<v-speed-dial v-model="fab" :open-on-hover="absolute" :fixed="absolute" :bottom="absolute" :right="absolute"> <v-speed-dial v-model="fab" :open-on-hover="absolute" :fixed="absolute" :bottom="absolute" :right="absolute">
<template v-slot:activator> <template v-slot:activator>
<v-btn v-model="fab" :color="absolute ? 'accent' : 'white'" dark :icon="!absolute" :fab="absolute"> <v-btn v-model="fab" :color="absolute ? 'accent' : 'white'" dark :icon="!absolute" :fab="absolute">
<v-icon> {{ $globals.icons.create }} </v-icon> <v-icon> {{ $globals.icons.createAlt }} </v-icon>
</v-btn> </v-btn>
</template> </template>
<v-btn fab dark small color="primary" @click="addRecipe = true"> <v-btn fab dark small color="primary" @click="addRecipe = true">

View File

@ -127,7 +127,7 @@ export default {
return pages.map(x => ({ return pages.map(x => ({
title: x.name, title: x.name,
to: `/pages/${x.slug}`, to: `/pages/${x.slug}`,
icon: this.$globals.icons.tags, icon: this.$globals.icons.pages,
})); }));
} }
return []; return [];

View File

@ -11,6 +11,7 @@ import "typeface-roboto/index.css";
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.component("TheButton", () => import("@/components/UI/Buttons/TheButton.vue"));
Vue.prototype.$globals = globals; Vue.prototype.$globals = globals;

View File

@ -72,10 +72,7 @@
</v-card-text> </v-card-text>
<template v-slot:open="{ open }"> <template v-slot:open="{ open }">
<v-btn color="success" @click="open"> <TheButton create @click="open" />
<v-icon left> {{ $globals.icons.create }} </v-icon>
{{ $t("general.create") }}
</v-btn>
</template> </template>
</BaseDialog> </BaseDialog>
</v-card-actions> </v-card-actions>

View File

@ -105,10 +105,7 @@
{{ $t("settings.webhooks.test-webhooks") }} {{ $t("settings.webhooks.test-webhooks") }}
</v-btn> </v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="success" @click="saveGroupSettings"> <TheButton update @click="saveGroupSettings" />
<v-icon left> {{ $globals.icons.save }} </v-icon>
{{ $t("general.update") }}
</v-btn>
</v-card-actions> </v-card-actions>
</template> </template>
</StatCard> </StatCard>

View File

@ -73,10 +73,8 @@
</v-virtual-scroll> </v-virtual-scroll>
<v-divider></v-divider> <v-divider></v-divider>
<v-card-actions> <v-card-actions>
<v-spacer class="mx-2"></v-spacer> <v-spacer></v-spacer>
<v-btn class="my-1 mb-n1" color="success" @click="createTheme"> <TheButton class="mt-1 mb-n1" create @click="createTheme" />
<v-icon left> {{ $globals.icons.create }} </v-icon> {{ $t("general.create") }}
</v-btn>
</v-card-actions> </v-card-actions>
</template> </template>
</StatCard> </StatCard>

View File

@ -89,10 +89,7 @@
file-name="profile_image" file-name="profile_image"
/> />
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="success" @click="updateUser"> <TheButton update @click="updateUser" />
<v-icon left> {{ $globals.icons.save }} </v-icon>
{{ $t("general.update") }}
</v-btn>
</v-card-actions> </v-card-actions>
</template> </template>
</StatCard> </StatCard>

View File

@ -5,9 +5,7 @@
<h2 class="mt-1 mb-1 "> <h2 class="mt-1 mb-1 ">
{{ $t("settings.custom-pages") }} {{ $t("settings.custom-pages") }}
<span> <span>
<v-btn color="success" @click="newPage" small class="ml-3"> <TheButton create small class="ml-3" @click="newPage" />
{{ $t("general.create") }}
</v-btn>
</span> </span>
</h2> </h2>
<draggable class="row mt-1" v-model="customPages"> <draggable class="row mt-1" v-model="customPages">
@ -33,13 +31,9 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-btn text small color="error" @click="deletePage(item.id)"> <TheButton delete small minor @click="deletePage(item.id)" />
{{ $t("general.delete") }}
</v-btn>
<v-spacer> </v-spacer> <v-spacer> </v-spacer>
<v-btn small text color="success" @click="editPage(index)"> <TheButton edit small @click="editPage(index)" />
{{ $t("general.edit") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-col> </v-col>
@ -47,9 +41,7 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="success" @click="savePages"> <TheButton update @click="savePages" />
{{ $t("general.save") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</template> </template>

View File

@ -126,10 +126,7 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="success" @click="saveSettings" class="mr-2"> <TheButton class="mr-2" update @click="saveSettings" />
<v-icon left> {{ $globals.icons.save }} </v-icon>
{{ $t("general.save") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</template> </template>

View File

@ -36,11 +36,11 @@
</BaseDialog> </BaseDialog>
<div class="d-flex justify-center align-center pa-2 flex-wrap"> <div class="d-flex justify-center align-center pa-2 flex-wrap">
<new-category-tag-dialog ref="newDialog" :tag-dialog="isTags"> <NewCategoryTagDialog ref="newDialog" :tag-dialog="isTags">
<v-btn @click="openNewDialog" small color="success" class="mr-1 mb-1"> <v-btn @click="openNewDialog" small color="success" class="mr-1 mb-1">
{{ $t("general.create") }} {{ $t("general.create") }}
</v-btn> </v-btn>
</new-category-tag-dialog> </NewCategoryTagDialog>
<BulkAssign isTags="isTags" class="mr-1 mb-1" /> <BulkAssign isTags="isTags" class="mr-1 mb-1" />
@ -72,15 +72,12 @@
<v-row> <v-row>
<v-col cols="12" :sm="12" :md="6" :lg="4" :xl="3" v-for="item in results" :key="item.id"> <v-col cols="12" :sm="12" :md="6" :lg="4" :xl="3" v-for="item in results" :key="item.id">
<v-card> <v-card>
<v-card-actions>
<v-card-title class="py-1">{{ item.name }}</v-card-title> <v-card-title class="py-1">{{ item.name }}</v-card-title>
<v-divider class="mx-2"></v-divider>
<v-card-actions>
<TheButton minor small delete @click="deleteItem(item.slug)" />
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn small text color="info" @click="openEditDialog(item)"> <TheButton small edit @click="openEditDialog(item)" />
{{ $t("general.edit") }}
</v-btn>
<v-btn small text color="error" @click="deleteItem(item.slug)">
{{ $t("general.delete") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-col> </v-col>

View File

@ -10,12 +10,7 @@
@submit="createNotification" @submit="createNotification"
> >
<template v-slot:open="{ open }"> <template v-slot:open="{ open }">
<v-btn small color="info" @click="open"> <TheButton create small @click="open"> {{ $t("events.notification") }}</TheButton>
<v-icon left>
{{ $globals.icons.create }}
</v-icon>
{{ $t("events.notification") }}
</v-btn>
</template> </template>
<template v-slot:default> <template v-slot:default>
<v-card-text class="mt-2"> <v-card-text class="mt-2">
@ -134,14 +129,13 @@
<v-icon color="success"> {{ item.user ? "mdi-check" : "" }} </v-icon> <v-icon color="success"> {{ item.user ? "mdi-check" : "" }} </v-icon>
</td> </td>
<td> <td>
<v-btn class="mx-1" small color="error" @click="deleteNotification(item.id)"> <TheButton delete small minor @click="deleteNotification(item.id)"> </TheButton>
<v-icon> {{ $globals.icons.delete }} </v-icon> <TheButton edit small @click="testByID(item.id)">
{{ $t("general.delete") }} <template v-slot:icon>
</v-btn> mdi-test-tube
<v-btn small color="info" @click="testByID(item.id)"> </template>
<v-icon left> mdi-test-tube</v-icon>
{{ $t("general.test") }} {{ $t("general.test") }}
</v-btn> </TheButton>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -69,13 +69,9 @@
</v-list> </v-list>
<v-card-actions class="mt-n3"> <v-card-actions class="mt-n3">
<v-btn color="error lighten-2" small outlined @click="deletePlan(mealplan.uid)"> <TheButton small secondary delete @click="deletePlan(mealplan.uid)" />
{{ $t("general.delete") }}
</v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="info" small @click="editPlan(mealplan.uid)"> <TheButton small edit @click="editPlan(mealplan.uid)" />
{{ $t("general.edit") }}
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-col> </v-col>

View File

@ -5,7 +5,13 @@
</v-card> </v-card>
<NoRecipe v-else-if="loadFailed" /> <NoRecipe v-else-if="loadFailed" />
<v-card v-else-if="!loadFailed" id="myRecipe" class="d-print-none"> <v-card v-else-if="!loadFailed" id="myRecipe" class="d-print-none">
<v-img height="400" :src="getImage(recipeDetails.slug)" class="d-print-none" :key="imageKey"> <v-img
:height="hideImage ? '40' : imageHeight"
@error="hideImage = true"
:src="getImage(recipeDetails.slug)"
class="d-print-none"
:key="imageKey"
>
<RecipeTimeCard <RecipeTimeCard
:class="isMobile ? undefined : 'force-bottom'" :class="isMobile ? undefined : 'force-bottom'"
:prepTime="recipeDetails.prepTime" :prepTime="recipeDetails.prepTime"
@ -71,6 +77,7 @@ export default {
}, },
data() { data() {
return { return {
hideImage: false,
loadFailed: false, loadFailed: false,
skeleton: true, skeleton: true,
form: false, form: false,
@ -123,6 +130,9 @@ export default {
isMobile() { isMobile() {
return this.$vuetify.breakpoint.name === "xs"; return this.$vuetify.breakpoint.name === "xs";
}, },
imageHeight() {
return this.isMobile ? "200" : "400";
},
currentRecipe() { currentRecipe() {
return this.$route.params.recipe; return this.$route.params.recipe;
}, },

View File

@ -1,8 +1,7 @@
<template> <template>
<v-container> <v-container>
<v-card flat height="100%">
<v-app-bar color="transparent" flat class="mt-n1 rounded"> <v-app-bar color="transparent" flat class="mt-n1 rounded">
<v-icon large left> {{ $globals.icons.tags }}-multiple-outline </v-icon> <v-icon large left> {{ $globals.icons.pages }} </v-icon>
<v-toolbar-title class="headline"> {{ page.name }} </v-toolbar-title> <v-toolbar-title class="headline"> {{ page.name }} </v-toolbar-title>
</v-app-bar> </v-app-bar>
@ -13,13 +12,12 @@
</v-tab> </v-tab>
</v-tabs> </v-tabs>
<v-tabs-items v-model="tab"> <v-tabs-items class="transparent" v-model="tab">
<v-tab-item v-for="(item, index) in page.categories" :key="item.slug + index" :value="item.slug"> <v-tab-item v-for="(item, index) in page.categories" :key="item.slug + index" :value="item.slug">
<CardSection class="mb-5 mx-1" :recipes="item.recipes" @sort="sortRecipes($event, index)" /> <CardSection class="mb-5 mx-1" :recipes="item.recipes" @sort="sortRecipes($event, index)" />
</v-tab-item> </v-tab-item>
</v-tabs-items> </v-tabs-items>
</div> </div>
</v-card>
</v-container> </v-container>
</template> </template>

View File

@ -1,6 +1,5 @@
<template> <template>
<v-container> <v-container>
<v-card flat class="pa-3">
<v-row dense> <v-row dense>
<v-col> <v-col>
<v-text-field <v-text-field
@ -13,17 +12,11 @@
</v-text-field> </v-text-field>
</v-col> </v-col>
<v-col cols="12" md="2" sm="12"> <v-col cols="12" md="2" sm="12">
<v-text-field <v-text-field class="mt-0 pt-0" :label="$t('search.max-results')" v-model="maxResults" type="number" outlined />
class="mt-0 pt-0"
:label="$t('search.max-results')"
v-model="maxResults"
type="number"
outlined
/>
</v-col> </v-col>
</v-row> </v-row>
<v-row dense class="mt-0 flex-row align-center justify-space-around"> <v-row dense class="my-0 flex-row align-center justify-space-around">
<v-col> <v-col>
<h3 class="pl-2 text-center headline"> <h3 class="pl-2 text-center headline">
{{ $t("category.category-filter") }} {{ $t("category.category-filter") }}
@ -46,8 +39,7 @@
</v-col> </v-col>
</v-row> </v-row>
<CardSection title-icon="mdi-mag" :recipes="showRecipes" :hardLimit="maxResults" @sort="assignFuzzy" /> <CardSection class="mt-n9" title-icon="mdi-mag" :recipes="showRecipes" :hardLimit="maxResults" @sort="assignFuzzy" />
</v-card>
</v-container> </v-container>
</template> </template>

View File

@ -14,14 +14,8 @@
<v-spacer></v-spacer> <v-spacer></v-spacer>
<BaseDialog title="New List" title-icon="mdi-format-list-checks" submit-text="Create" @submit="createNewList"> <BaseDialog title="New List" title-icon="mdi-format-list-checks" submit-text="Create" @submit="createNewList">
<template v-slot:open="{ open }"> <template v-slot:open="{ open }">
<v-btn color="info" @click="open"> <TheButton create @click="open" />
<v-icon left>
{{ $globals.icons.create }}
</v-icon>
New List
</v-btn>
</template> </template>
<v-card-text> <v-card-text>
<v-text-field autofocus v-model="newList.name" label="List Name"> </v-text-field> <v-text-field autofocus v-model="newList.name" label="List Name"> </v-text-field>
</v-card-text> </v-card-text>
@ -37,12 +31,7 @@
</v-card-title> </v-card-title>
<v-divider class="mx-2"></v-divider> <v-divider class="mx-2"></v-divider>
<v-card-actions> <v-card-actions>
<v-btn text color="error" @click="deleteList(item.id)"> <TheButton delete minor @click="deleteList(item.id)" />
<v-icon left>
{{ $globals.icons.delete }}
</v-icon>
Delete
</v-btn>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn color="info" @click="list = item.id"> <v-btn color="info" @click="list = item.id">
<v-icon left> <v-icon left>
@ -63,12 +52,8 @@
{{ activeList.name }} {{ activeList.name }}
</div> </div>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn v-if="edit" color="success" @click="saveList"> <TheButton v-if="edit" update @click="saveList" />
Save <TheButton v-else edit @click="edit = true" />
</v-btn>
<v-btn v-else color="info" @click="edit = true">
Edit
</v-btn>
</v-card-title> </v-card-title>
<v-divider class="mx-2 mb-1"></v-divider> <v-divider class="mx-2 mb-1"></v-divider>
@ -277,4 +262,7 @@ export default {
</script> </script>
<style > <style >
.dense-markdown p {
margin: auto !important;
}
</style> </style>

View File

@ -2,13 +2,17 @@ const icons = {
primary: "mdi-silverware-variant", primary: "mdi-silverware-variant",
// Crud // Crud
create: "mdi-plus", createAlt: "mdi-plus",
create: "mdi-plus-circle",
delete: "mdi-delete", delete: "mdi-delete",
save: "mdi-content-save", save: "mdi-content-save",
update: "mdi-content-save-edit",
edit: "mdi-square-edit-outline", edit: "mdi-square-edit-outline",
close: "mdi-close",
// Organization // Organization
tags: "mdi-tag-multiple-outline", tags: "mdi-tag-multiple-outline",
pages: "mdi-book-outline",
// Admin // Admin
user: "mdi-account", user: "mdi-account",