Understanding the Stucture of a Vue Project (vuetify) - vue.js

I'm new to Vue and Vuetify, I'm just trying to figure out the structure I should have when writing my code. I'm starting to get a bit confused with the differences between v-layout and v-flex.
Here is my current structure: I'm trying to position the flex xs8 (with the room type) next to the flex xs2 (with paragraph 'test').
<v-container ma-6 grid-list-xl>
<v-layout>
<v-flex md8 xs12>
<!-- My spaces -->
<v-layout v-for="space in spaces" v-if="space.id === selected" :key="space.id" row wrap>
<!-- The rooms -->
<v-flex v-for="room in space.rooms" :key="room.id" xs12 md6>
<!-- A room -->
<v-card class="card-round">
<!-- Image -->
<v-carousel>
<v-carousel-item v-for="image in room.images" :src="image.src" :key="image.id"></v-carousel-item>
</v-carousel>
<!-- Information -->
<v-layout row wrap>
<v-card-text primary-title>
<v-flex xs8>
<p> {{ room.type }} </p>
<h3 class="headline"> {{ room.name }} </h3>
</v-flex>
<v-flex xs2>
<p>test</p>
</v-flex>
</v-card-text>
</v-layout>
</v-card>
</v-flex>
</v-layout>
</v-flex>
<v-flex hidden-md-and-down>
<p>temp sidebar</p>
</v-flex>
</v-layout>
</v-container>

If you want any elements to be displayed side by side (inline), put them inside v-layout
<v-layout>
<v-flex xs8>
<p> {{ room.type }} </p>
<h3 class="headline"> {{ room.name }} </h3>
</v-flex>
<v-flex xs2>
<p>test</p>
</v-flex>
</v-layout>

The <v-layout> tag component just represent the flex box (basically, a div with a display: flex; CSS rule).
The <v-flex> tags components that you put inside the <v-layout> tag are the elements of your flexbox (the ones that you can customize the "grow/shrink behavior" with the flex CSS rule)
That's it.

Related

Vuetify Flex Layout - is not filling the height

I have tried loads of different options with the following code, however, I can't get this to fill the remaining height. (The second layout should fill the remaining height) what am I doing wrong here?
<template>
<div class="earnIndex">
<v-container fluid fill-height>
<v-layout row wrap>
<v-flex
v-for="(offer, index) in offers"
:key="index"
xs2
class="pa-1"
>
<SiteButton
:site-name="offer.siteName"
/>
</v-flex>
</v-layout>
<v-layout column fill-height>
<v-flex grow>
<v-card>
<p>
test
</p>
</v-card>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
EDIT:
So here is my new code:
<template>
<v-layout column wrap>
<v-flex>
<v-layout row wrap class="red">
<v-flex
v-for="(offer, index) in offers"
:key="index"
class="pa-1"
xs2
>
<SiteButton
:site-name="offer.siteName"
/>
</v-flex>
</v-layout>
</v-flex>
<v-flex grow align-content-start>
<v-card height="100%">
<p>
test
</p>
</v-card>
</v-flex>
</v-layout>
</template>
This creates the following:
I would like the card with "test" to start straight after the links at the top, and then fill the rest of the height.
Thank you in advanced for your help!
Regards,
Josh
Try using column fill-height on the right side, and then grow on the v-flex...
<v-container fluid fill-height>
<v-layout row wrap>
<v-flex v-for="(offer, index) in offers" :key="index" xs2 class="pa-1">
<v-btn>{{ offer.siteName }}</v-btn>
</v-flex>
</v-layout>
<v-layout column fill-height>
<v-flex grow>
<v-card class="fill-height">
<p> test </p>
</v-card>
</v-flex>
</v-layout>
</v-container>
https://codeply.com/p/bwE5ifP4Pe
You don't need as much markup in your scenario and can cut this down to just a few lines.
I just filled in some numbers instead of your custom component in the v-for.
This will stretch the lower card to the maximum amount right after your for loop. The v-row and v-col is the way to go now in 2.0 (https://vuetifyjs.com/en/components/grids/).
<div class="d-flex fill-height" style="flex-direction:column">
<v-row class="blue">
<v-col cols="2" v-for="i in 15" :key="i" class="pa-1">
<v-btn>{{ i }}</v-btn>
</v-col>
</v-row>
<div class="fill-height" style="background-color: salmon">Down</div>
</div>
Codesandbox example

How to make the card fixed for entire container?

I have a problem with the code shown below. I want it to be fixed, therefore filling the height and the width, eliminating the scrollbar if possible.
Here is code sample:
<template>
<div class="mt-10 pt-10">
<v-container fluid ma-0 pa-0 fill-height>
<v-layout row wrap class="ma-0 pa-0">
<v-flex class="xl6 md6 sm6 xs12 pa-0" absolute fixed>
<v-card height="900" class="ma-0 pa-0" id="rounded-card">
<v-img
src="img.jpg"
height="100%"/>
</v-card>
</v-flex>
<v-flex class="xl6 md6 sm6 xs12 pa-0" absolute fixed>
<v-card class="ma-0 pa-0 elevation-5" height="900">
<item_att/>
<v-divider/>
<item_pro/>
</v-card>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
I want my website to have similar layout to this page: https://nephos.cssninja.io/product.html
Here's my sample page: https://thestackoverflow.netlify.com/single

How to add text above the delimiters of a carousel using Vuetify?

I am using Vue/Vuetify and need to add text to carousel slides for descriptions. I think placing the text above the delimiters and below the image is the best place for it. I'd rather not overlay the text on the image. Vuetify documentation doesn't give any examples for this. How can this be done?
You can make own carousel design inside of v-carousel-item tags, using vuetify elements to place text where you want. Example on cedepen
<div id="app">
<v-app id="inspire">
<v-container fluid>
<v-layout row wrap justify-center>
<v-flex xs6>
<v-carousel hide-delimiters>
<v-carousel-item
v-for="(item,i) in items"
:key="i"
>
<v-img
:src="item.src"
class="fill-height"
>
<v-container
fill-height
fluid
pa-0 ma-0
>
<v-layout fill-height align-end>
<v-flex xs12>
<v-card color="red" class="pa-2" >
<span class="headline white--text" v-text="item.src"> </span>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-img>
</v-carousel-item>
</v-carousel>
</v-flex>
</v-layout>
</v-container>
</v-app>
</div>
Updated
<div id="app">
<v-app id="inspire">
<v-container fluid>
<v-layout row wrap justify-center>
<v-flex xs6>
<v-carousel>
<v-carousel-item
v-for="(item,i) in items"
:key="i"
:src="item.src"
>
<v-container
fill-height
fluid
pa-0 ma-0 pb-3
>
<v-layout fill-height align-end pb-4 mb-4>
<v-flex xs12>
<v-card color="red" class="pa-2">
<span class="headline white--text" v-text="item.src"> </span>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-carousel-item>
</v-carousel>
</v-flex>
</v-layout>
</v-container>
</v-app>
</div>

Vuetify V-flex full only half of card

My v-flex it is not respecting my orders and only half of element it was rendered. see the print:
Print from my view
Here is my script:
<v-card-title primary-title>
<div>
<p class="subheading grey--text">My title</p>
<h3 class="headline my-4">my sub title</h3>
<div>
<v-container fluid>
<v-card flat v-for="ticket in tickets" :key="ticket.id">
<v-layout row wrap :class="`pa-2 ticket ${ticket.status.id}`">
<v-flex xs3>
<div class="caption grey--text">#ID</div>
<div>{{ticket.id}}</div>
</v-flex>
<v-flex xs3>
<div class="caption grey--text">Assunto</div>
<div>{{ticket.subject}}</div>
</v-flex>
<v-flex xs3>
<div class="caption grey--text">Criado em</div>
<div>{{ticket.created_on}}</div>
</v-flex>
<v-flex xs3>
<div class="right">
<v-chip
small
:class="`${ticket.status.id} white--text caption my-2`"
>{{ticket.status.name}}</v-chip>
</div>
</v-flex>
</v-layout>
</v-card>
</v-container>
</div>
</div>
</v-card-title>
Someone has any ideas?
Tks.
You can add a full width flex box above the v-card on line 7:
<v-flex xs12>
<v-card flat v-for="ticket in tickets" :key="ticket.id">
...
EDIT: My mistake... after taking another look you can change the div on line 2 to a v-flex, which will give you the results like in this codepen: https://codepen.io/retrograde/pen/ZNYJRq?editors=0001 Note that I removed the code added by my original answer.

v-for in vue update all object in array although the key has been determined

this my code :
<v-container grid-list-md fluid-fix>
<div v-for="(data ,c) in chapter.data" :key="c" class="my-3" style="border: 1px solid;">
<v-layout row wrap px-3>
<v-flex xs12 sm1>
<v-text-field v-model="data.num" label="Chapter"></v-text-field>
</v-flex>
<v-flex xs12 sm3>
<v-text-field v-model="data.name" label="name"></v-text-field>
</v-flex>
<v-flex xs12 sm8 d-flex>
<v-text-field v-model="data.description" label="short info" style="width: 100%;"></v-text-field>
<div>
<v-btn class="d-inline-flex servers--btn" color="success" #click="addServer(c)">add server</v-btn>
</div>
</v-flex>
</v-layout>
<v-container grid-list-md fluid-fix>
<v-layout wrap v-for="(server ,s) in data.servers" :key="s">
<v-flex sm12>
<div class="d-inline-flex">
<v-autocomplete
:items="data.serverlist"
v-model="server.server_id"
#input="serverChange(data)"
label="Server"
></v-autocomplete>
</div>
<div class="d-inline-flex text-xs-right pr-1">
<v-btn color="orange" class="white--text servers--btn" #click="demo_edit(c,s,server.links)">demo and Edit</v-btn>
</div>
<div class="d-inline-flex text-xs-right pr-1" style="float: right;">
<v-btn color="red" class="white--text servers--btn" #click="delSvOnChap(c,s)">Delete Server</v-btn>
</div>
</v-flex>
<v-flex sm12>
<v-textarea
v-model="server.links"
label="box image"
></v-textarea>
</v-flex>
</v-layout>
</v-container>
serverChange(data){
data.serverlist.forEach(obj => {
if(_.find(data.servers,{server_id: obj.value})){
obj.disabled = true
}else{
obj.disabled = false
}
});
},
serverChange is in methods
i want update disabled in the key has been determined , but it's update all object in array
when I log serverChange function i just see one object return and that's what I'm looking forward to but when i set disabled for this object , vue update all object in array
I need a solution for this problem .