How to shift v-flex elements away from one another in Vuetify? - vue.js

in my vuejs application, I have a file called ProductDetails.vue. For the template, I used Vuetify to create a grid system where the product's image will be at the left, and the product's content to the right. However, I have encountered two problems. Firstly, how do i shift the images and content away from one another so that there is space. Secondly, how to shift the button to the right most of the product's content. Below is my code, a screenshot of my current design and a screenshot of my desired design.
https://codepen.io/Issaki/pen/qwRWgZ
Update #1: I am still trying to solve this issue, is there anyone that can help me?
<template>
<div>
<v-container>
<v-layout row wrap>
<v-flex xs12 sm6 md5 lg5>
<v-img
class="white--text"
height="350px"
src="https://cdn.vuetifyjs.com/images/cards/docks.jpg"
/>
</v-flex>
<v-flex xs12 sm6 md7 lg7>
<p class="subheading font-weight-light grey--text text--darken-1 mb-1">Samsung</p>
<p class="display-1 font-weight-light">OnePlus 3</p>
<p
class="subheading"
>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class="headline font-weight-medium">$329</p>
<p class="muted">Inclusive of all taxes. Free home delivery.</p>
<v-btn color="yellow">
<v-icon left>shopping_cart</v-icon>Add to Cart
</v-btn>
</v-flex>
</v-layout>
</v-container>
</div>
</template>

You can add space between the two v-flex if you simply add some padding to one of them. So by adding class="pl-3" which translates to padding-left-3 to the second v-flex you can add some space. You can learn more about spacing helpers.
For the button just wrap it in:
<v-layout align-end justify-end>
<v-btn color="yellow" >
<v-icon left>shopping_cart</v-icon>Add to Cart
</v-btn>
</v-layout>
You can learn more about it here.
Update: A better way to add spacing though would be to add grild-list-* to your container. In that case it will add some spacing to all your elements in the container so you dont need the added padding anymore. You can see the updated Codepen below and read more here.
I have forked and edited your Codepen.
Hope it helps :)

Related

How stay on the same tab after page refresh with Vuetify Vuejs

I couple tabs on my page and I'm trying to stay on the same tab after refreshing the page but I'm not sure how to approach this. Right now if I'm on TAB-2 and I refresh the page, it will take me back to the first tab.
<v-tabs vertical>
<v-tab>
<v-icon left>mdi-account</v-icon>
TAB-1
</v-tab>
<v-tab>
<v-icon left>mdi-lock</v-icon>
TAB-2
</v-tab>
v-tab-item>
<v-card flat>
<v-card-text>
<p>
TAB-1 Sed aliquam ultrices mauris. Donec posuere vulputate arcu. Morbi ac felis. Etiam feugiat lorem non metus. Sed a libero.
</p>
</v-card-text>
</v-card>
</v-tab-item>
<v-tab-item>
<v-card flat>
<v-card-text>
<p>
TAB -2 Morbi nec metus. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis .
</p>
</v-card-text>
</v-card>
</v-tab-item>
</v-tabs
use sessionStorage to save v-model value of <tabs> temporarily
such as this
created(){
this.model = sessionStorage.getItem('key');
},
methods:{
handleChange(index){
sessionStorage.setItem('key', index);
}
}

How to programatically bounce v-dialog

I'm using v-dialog from vuetify. When I set it to persistent, there is a bounce effect when the user clicks outside the dialog. I would like to manually create that effect when some random button is clicked. How is that possible?
Dialog has a method called animateClick, you can call the same.
CODEPEN
<v-dialog ref="dialog" v-model="dialog" width="400px">
<v-card >
<v-card-title
class="headline grey lighten-2"
primary-title
>
Privacy Policy
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
</v-card-text>
<v-divider></v-divider>
<v-card-action>
<v-btn #click="doAnimation">Animate Me</v-btn>
</v-card-action>
</v-card>
</v-dialog>
....
....
<script>
export default{
...
methods: {
methods:{
doAnimation(){
this.$refs.dialog.animateClick()
}
}
}
}
</script>

vuetify: manually play persistent dialog refuse to close animation

When you click outside a persistent dialog, it will play a animation and dialog will not close, I would like to play this animation when form validation fail and dialog refuse to close
I cannot find any information at vuetify doc, would like to have some pointer to find this out, I am new to java framework and have no idea how I can drag into the source to find out any hint on this.
UPDATED
Dialog has a method called animateClick, you can call the same.
CODEPEN
<div id="app">
<v-app id="inspire">
<v-container fill-height>
<v-row>
<v-col align=center>
<v-btn color="primary" #click="dialog = true">Open</v-btn>
<v-col>
</v-row>
</v-container>
<v-dialog ref="dialog" v-model="dialog" width="400px">
<v-card >
<v-card-title
class="headline grey lighten-2"
primary-title
>
Privacy Policy
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
</v-card-text>
<v-divider></v-divider>
<v-card-action>
<v-btn #click="doAnimation">Animate Me</v-btn>
</v-card-action>
</v-card>
</v-dialog>
</v-app>
</div>
<script>
export default{
...
methods: {
methods:{
doAnimation(){
this.$refs.dialog.animateClick()
}
}
}
}
</script>

Align text in card to the bottom right of the image

I'm trying to use the flex properties in the Vuetify's grid system to align the text to the bottom right of the image but only the justify is working for me, align is doing nothing for me, I tried to use align-end in the v-flex and in the v-layout but neither is working. On top of that, if I add a v-flex the justify that used to work for the v-layout stops working. It's the first day I use Vuetify so I'm a bit lost and overwhelmed with the large number of properties and components it has so I would like some help here:
<v-card>
<v-img src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-container>
<v-layout justify-end>
<span class="headline white--text">Lorem, ipsum dolor.</span>
</v-layout>
</v-container>
</v-img>
<v-card-title>
<h2>Lorem, ipsum dolor.</h2>
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn color="info" text>Action</v-btn>
</v-card-actions>
</v-card>
a) flexbox only works on a parent-child basis. You have a few properties aimed at the flex container (the parent) and a few usable on the flex items (the children). Obviously, any flex item can also be a flex container for its own children. For a more in-depth coverage of how flexbox works I recommend this read.
b) whenever something doesn't seem to work right, regardless of the UI framework/library you use, have a look at their examples. Find one that's close to what you're after and simply copy-paste the markup and then start playing.
In your case, you don't need <v-container>, <v-layout> or any of those complications inside <v-img>.
It's way simpler:
<v-card>
<v-img>
<v-card-title />
</v-img>
<v-card-text />
<v-card-actions />
</v-card>
Here's a working example:
Vue.config.productionTip = false;
Vue.config.devtools = false;
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
#app {
margin: 20px 0;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/#mdi/font#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue#2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.js"></script>
<div id="app">
<v-app>
<v-card class="mx-auto" max-width="400">
<v-img class="white--text align-end"
src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-card-title class="justify-end">Lorem, ipsum dolor.</v-card-title>
</v-img>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit
alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn large color="primary">Action</v-btn>
</v-card-actions>
</v-card>
</v-app>
</div>
In order to make the title bottom right aligned I used:
.align-end on <v-img> // bottom align
.justify-end on <v-card-title> // align right
Note: justify-end class aligns element contents to the right with two conditions: the item has to be a flex container (a.k.a: have display: flex
- true in the case of <v-card-title>s) and has to have flex-direction: row (which is the implicit/default value).
If it's not a flex container, you have to use text-right class (or, in plain CSS: text-align: right).
Based on flex-direction value (row|row-reverse|column|column-reverse) any of the following would align to the right, accordingly: justify-end|justify-start|align-end|align-start.
So, rather than trying to remember: "justify-end aligns to the right" (which is only true in 1 out of 4 possible cases), visualize flexbox as having a direction. What's left/right of that direction is controlled by align-*. What's front/back on that direction is controlled by justify-*.
You dont need to use v-container or v-layout in this case, just need to add align-end class on your v-img and justify-end class on the image title.
<!-- your sample code -->
<v-card>
<v-img class="align-end" src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-card-title class="justify-end">Lorem, ipsum dolor.</v-card-title>
</v-img>
<v-card-title>
<h2>Lorem, ipsum dolor.</h2>
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn color="info" text>Action</v-btn>
</v-card-actions>
</v-card>
You can always get example from Vuetify official documentation.

Where I can edit footer of modal vue coreui?

I get some code like in the below from coreui vue template,
<b-modal title="Modal title" class="modal-success" v-model="successModal" #ok="successModal = false" ok-variant="success">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</b-modal>`
And the result is like in the below:
https://i.stack.imgur.com/8qPLJ.png
the question:
How I can edit the two buttons (cancel and OK) in the footer of that modal?
I know.
this is to use a slot,
you can put the slot for footer like in the below code
<div slot="modal-footer" class="w-100">
<p class="float-left">Modal Footer Content</p>
<b-btn size="sm" class="float-right" variant="primary" #click="show=false">
Close
</b-btn>
</div>
For anyone that's stumbling upon this question, here's is another answer.
<CModal title="Delete scraper?" :show.sync="dangerModal" color="danger">
By deleting this scraper, you will delete all the jobs and results that
are related to this scraper.<br><br>
<span class="font-weight-bold">Are you sure you would want to delete this scraper?</span>
<div slot="footer" class="w-100">
<CButton style="border-radius: .2rem; color: white;" color="danger" class="ml-1 mr-1 float-right" #click="dangerModal = true">
<i class="fas fa-trash"></i>
</CButton>
<CButton style="border-radius: .2rem; color: white;" color="danger" class="ml-1 mr-1 float-right" #click="dangerModal = true">
<i class="fas fa-trash"></i>
</CButton>
</div>
</CModal>
By adding a div element with the slot name.
OR
You can do this, which is way cleaner and easier:
<CModal title="Delete scraper?" :show.sync="dangerModal" color="danger">
By deleting this scraper, you will delete all the jobs and results that
are related to this scraper.<br><br>
<span class="font-weight-bold">Are you sure you would want to delete this scraper?</span>
<template #footer>
<CButton #click="dangerModal = false" color="danger">Discard</CButton>
<CButton #click="dangerModal = false" color="success">Accept</CButton>
</template>
</CModal>
Just use template element with the hashtag of the slot you want to use. In this case, I did #footer, to change the footer of the modal.
The slot names are listed in the official CoreUI Vue documentation here.
Remove button through hide-footer, add the button the way you want it.
on the button we use the float-right class to direct the buttons to the right.
Example:
<template>
<div>
<b-button #click="showModal">
Open Modal
</b-button>
<b-modal ref="myModalRef" hide-footer title="Using Component Methods">
<div class="d-block text-center">
<h3>Alteration</h3>
</div>
<b-btn class="float-right" #click="hideModal">Test</b-btn>
</b-modal>
</div>
</template>
<script>
export default {
methods: {
showModal () {
this.$refs.myModalRef.show()
},
hideModal () {
this.$refs.myModalRef.hide()
}
}
}
</script>