I have a Vue2 project and I am using Vuetify. I am trying to make filters that hide some games when certain filter is turned off.
Everything is working as it should until I try to make it a separate component.
I am trying to make these filters work as a child component.
Parent component
<game-providers
:allGamesSum="allGamesSum"
:vendorList="vendorList"
v-model="model"
#set-provider-filter="setProviderFilter"
#set-all-provider-filter="setAllProviderFilter"
></game-providers>
V-model data
model: {
allPset: 0,
vendorFilter: [],
},
Child component
<v-sheet elevation="1" height="100%" outlined rounded width="100%">
<h3 style="margin: 10px">Game providers</h3>
<v-btn-toggle
:value="value.allPset"
block
#change="$emit('set-all-provider-filter')"
style="display: block"
>
<v-btn block dark style="margin-top: 10px">
All providers
<v-spacer />
<v-chip>{{ allGamesSum }}</v-chip>
</v-btn>
</v-btn-toggle>
<v-btn-toggle
:value="value.vendorFilter"
#change="$emit('set-provider-filter')"
block
multiple
style="display: block"
>
<v-btn
v-for="(item, i) in vendorList"
:key="i"
:value="item.name"
height="30px"
block
dark
style="margin-top: 1px"
><img style="background-color: transparent" :src="item.src" />
<v-spacer />
<v-chip small>{{ item.gameSum }}</v-chip>
</v-btn>
</v-btn-toggle>
</v-sheet>
Props
props: ['value', 'vendorList', 'allGamesSum'],
I have two functions that I emit that should work on #change as shown in the first paragraph. I have no idea what I need to do more to make it work as a separate component.
v-btn-toggle has change event and value property.
Every help is appreciated.
Thank you.
do not use #chenge in v-btn you need use #click
this is the answer:
Child component
<v-sheet elevation="1" height="100%" outlined rounded width="100%">
<h3 style="margin: 10px">Game providers</h3>
<v-btn-toggle
:value="value.allPset"
block
#click="$emit('set-all-provider-filter')"
style="display: block"
>
<v-btn block dark style="margin-top: 10px">
All providers
<v-spacer />
<v-chip>{{ vallGamesSum }}</v-chip>
</v-btn>
</v-btn-toggle>
<v-btn-toggle
:value="value.vendorFilter"
#click="$emit('set-provider-filter')"
block
multiple
style="display: block"
>
<v-btn
v-for="(item, i) in vendorList"
:key="i"
:value="item.name"
height="30px"
block
dark
style="margin-top: 1px"
><img style="background-color: transparent" :src="item.src" />
<v-spacer />
<v-chip small>{{ item.gameSum }}</v-chip>
</v-btn>
</v-btn-toggle>
Related
I want to implement the below carousel in vuetify3? How can I do that?
Use the Grid component inside of the Carousel.
<v-carousel
cycle
height="400"
hide-delimiter-background
show-arrows="hover"
>
<v-carousel-item
v-for="(color, i) in colors"
:key="color"
>
<v-sheet
:color="color"
height="100%"
tile
>
<v-row
style="height:100%;"
align="center"
justify="center"
>
<v-col v-for="(i, index) in 2" :key="index">
<div class="text-h2 d-flex align-center justify-center">Column</div>
</v-col>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
Docs: https://next.vuetifyjs.com/en/components/grids/
Example: https://codepen.io/alexpetergill/pen/oNMoQae
Is there anyway that we can fix the v-tabs? So far I tried using inside v-tab fixed-tabs but that is not working and it would really be great if anyone could help me with it.
<v-card width="40%" class="mb-2">
<v-toolbar flat>
<font-awesome-icon #click="cancel" :icon="['far', 'arrow-left']"></font-awesome-icon>
<v-toolbar-title class="ml-2">Show Summary</v-toolbar-title>
<v-spacer />
<bn-toolbar-btn type="text" label="Cancel" icon="times" color="secondary" #click="cancel"></bn-toolbar-btn>
<bn-toolbar-btn
type="outlined"
right
label="Save"
#click="submit"
></bn-toolbar-btn>
</v-toolbar>
<v-divider></v-divider>
<v-tabs v-model="activeTab" class="mb-n2" background-color="transparent">
<v-tab ref="summaryTab1" #click="activeTab = 'tab1'" href="#tab1"> Summary Tab 1</v-tab>
<v-tab ref="summaryTab2" #click="activeTab = 'tab2'" href="#tab2"> Summary Tab 2 </v-tab>
</v-tabs>
<v-card-text>
<v-tabs-items touchless v-model="activeTab" style="background-color: transparent;">
<v-tab-item key="tab1" value="tab1">
...
</v-tab-item>
<v-tab-item key="tab2 value="tab2">...
</v-tab-item>
</v-tabs-items>
</v-card-text>
</v-card>
I tried using CSS as mentioned below. I created a class called activeTabs and passed it in v-tabs.
.activeTabs {
position: sticky;
top: 0;
z-index: 999;
}
I have a card like this:
<v-card :to="groupRoute" class="group-card mx-auto" color="#26c6da" dark max-width="400">
<v-card-title>
<span class="text-h6 font-weight-light d-flex" style="width: 100%">
<span class="name">{{ group.name }}</span>
<span class="flex-grow-1" />
<span class="creation">{{ creation }}</span>
</span>
</v-card-title>
<v-card-text class="text-h6 font-weight-bold">"{{ group.description }}"</v-card-text>
<v-card-actions>
<v-icon class="mr-1">mdi-account</v-icon>
<span class="partecipants subheading mr-2">
<span class="partecipants">{{ group.partecipants.length }}</span>
<span class="mx-1">/</span>
<span class="maxPartecipants">{{ group.maxPartecipants }}</span>
</span>
<v-row align="center" justify="end">
<v-btn class="blue--text text--darken-3" text icon #click="edit">
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn color="red" class="mr-2" icon #click="delete">
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-row>
</v-card-actions>
</v-card>
Note that the only important parts are: :to="groupRoute" and the <v-card-actions> with the two buttons.
The problem here is that the fact that the card has to, overwrites the click methods on the buttons, so even if I click the button and not the whole card, I am redirected to the groupRoute.
Change #click to #click.prevent to trigger preventDefault of the event
I have the following v-item-group where a user can select a pre-defined amount or type himself a custom amount.
Here's the design of the v-item-group. However, I can't figure out how to get the value from Custom Amount. The property this.item is undefined. I thought I need to create another v-model but perhaps there is a simple and straignt-forward solution.
<v-item-group v-model="item">
<v-container>
<v-row>
<v-item v-for="n in amounts" :key="n" v-slot="{ active, toggle }">
<v-card
:color="active ? 'deep-purple accent-3' : 'grey'"
class="d-flex align-center rounded-circle mr-3"
dark
height="64"
width="64"
#click="toggle"
>
<v-scroll-y-transition>
<div v-if="active" class="h3 flex-grow-1 text-center">
{{ n }}
</div>
<div v-else class=" h5 flex-grow-1 text-center">
{{ n }}
</div>
</v-scroll-y-transition>
</v-card>
</v-item>
<v-item v-slot="{ toggle }" key="5">
<v-text-field
label="Custom Amount"
hide-details="auto"
#click="toggle"
></v-text-field>
</v-item>
</v-row>
</v-container>
</v-item-group>
Declare a local data property, and use v-model on v-text-field:
<v-text-field v-model="customAmount">
export default {
data() {
return {
customAmount: '2000'
}
}
}
The function that processes the user's selection could then get the custom value simply by this.customAmount.
demo
Is there a way of detecting when a delimiter on a v-carousel is clicked?
Something like this should work
<button #click="handleClick">...</button>
See event handling docs.
EDIT
assuming you're using the carousel component from vuetify, you could also use their events.
<template>
<v-carousel v-model="model" #change="handleChange">
<v-carousel-item
v-for="(color, i) in colors"
:key="color"
>
<v-sheet
:color="color"
height="100%"
tile
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<div class="display-3">
Slide {{ i + 1 }}
</div>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
</template>