Aligning vue components with icons and without icons - vuejs2

I am designing a form with drop downs. I put an icon near start time. Start time and end time are on the same line for large screen and on 2 separate lines for a mobile device. However, the components are not lining up properly. For mobile, I want end time drop down, duration, and save button to each be on their own line and to be under (and flush with) the start time drop down, not under the start time icon.
For large screen, I want duration and save button to be aligned with start time drop down, not the icon.
Any help is appreciated. code and screenshots below.
App.vue:
<template>
<div id="app">
<v-app id="inspire">
<Header/>
<v-content>
<v-container fluid>
<router-view></router-view>
</v-container>
</v-content>
</v-app>
</div>
</template>
Session.vue:
<template>
<div id = 'newSession'>
<v-layout align-center justify-center >
<v-flex xs18 sm10 md8>
<div>
<fieldset>
<legend align="left">Add New Session</legend>
<v-alert
:value="invalidStartTimeorEndTime"
type="warning"
>
Start Time or End Time is invalid.
</v-alert>
<form #submit.prevent="submit">
<v-layout row align-baseline>
<!--menu allows the date-picker to show and not show -->
<v-menu
ref="menu2"
:close-on-content-click="false"
v-model="menu2"
:nudge-right="40"
:return-value.sync="date"
lazy
transition="scale-transition"
offset-y
full-width
min-width="290px"
>
<v-text-field
slot="activator"
v-model="date"
label="Session Date"
prepend-icon="event"
box
readonly
></v-text-field>
<v-date-picker v-model="date" #input="$refs.menu2.save(date)" ></v-date-picker>
</v-menu>
<label color="indigo" background-color= "indigo" text-color="white"> {{getWeekendDate}} </label> <!-- colors x working -->
</v-layout>
<v-layout v-bind="binding">
<!-- <v-layout row> -->
<!-- <v-icon>access_time</v-icon> -->
<v-select
:items="times"
v-model="start_time"
label="Start Time"
prepend-icon="access_time"
box
placeholder="Start Time"
></v-select>
<v-select
:items="times"
:value="getEndTime"
label="End Time"
box
placeholder="End Time"
#change="changeEndTime"
></v-select>
</v-layout>
<v-layout column align-left >
<div class="flex">
<label>{{getDuration}}</label>
<v-btn color="indigo" type ="submit" dark>Save</v-btn>
</div>
</v-layout>
</form>
</fieldset>
</div>
</v-flex>
</v-layout>
</div>
</template>

Related

Grid system not working as expected in a Vuetify v-footer

I am trying to get all of my links in three columns in my footer with the copyright line below that. However, my copyright line is showing up in a phantom fourth column and it overlaps the third column if the screen width gets too small. If I use the same layout in my content section, I get the three columns.
Here is my footer component:
<template>
<div>
<v-footer color="primary lighten-1" padless>
<v-row justify="center">
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
</v-col>
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Data Sources
</v-btn>
</div>
</v-col>
<v-col cols=4>
<div class="my-1">
<v-btn color="white" text rounded>
Browse Maps
</v-btn>
</div>
</v-col>
</v-row>
<v-row>
<v-col cols="12">
<p class="text-center grey--text text--lighten-2">Copyright 2020, </p>
</v-col>
</v-row>
</v-footer>
</div>
<template>
On a possibly related note, why do I have to wrap each button in a div with a my-? class to get the buttons to stack vertically.
Edit:
I am using Vuetify v2.2.11.
Here is a screenshot of what it is doing:
Here is what I want:
My buttons that are within the same column are showing up side/side unless I either wrap them in the my-? classed div or there is not enough room in the column to display them side/side. I would like them stacked on top of each other in every screen size. And of course I only want the three columns for my buttons
A v-row only works as expected if wrapped in a v-container.
Add a <v-container fluid> around your v-rows and it should work just fine. Fluid is described as "Removes viewport maximum-width size breakpoints", thus removing the horizontal padding.
The whole thing would look like this in the end:
<template>
<div>
<v-footer color="primary lighten-1" padless>
<v-container fluid>
<v-row class="text-center">
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
<div class="my-1">
<v-btn color="white" text rounded>
Contact Us
</v-btn>
</div>
</v-col>
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Data Sources
</v-btn>
</div>
</v-col>
<v-col cols="4">
<div class="my-1">
<v-btn color="white" text rounded>
Browse Maps
</v-btn>
</div>
</v-col>
</v-row>
<v-row>
<v-col cols="12">
<p class="text-center grey--text text--lighten-2">
Copyright 2020,
</p>
</v-col>
</v-row>
</v-container>
</v-footer>
</div>
</template>

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 can I call a method if select date in the datepicker vuetify?

My codepen like this : https://codepen.io/positivethinking639/pen/mddejJN
my code like this :
<div id="app">
<v-app>
<v-content>
<v-container>
<v-dialog
ref="dialogTest"
v-model="modalTest"
:return-value.sync="dateTest"
persistent
>
<template v-slot:activator="{ on }">
<v-btn color="success" dark v-on="on">call date</v-btn>
</template>
<div class="text-center title">Select a Date & Time</div>
<v-row justify="center">
<v-date-picker v-model="dateTest" scrollable :allowed-dates="allowedDates">
<div class="flex-grow-1"></div>
<v-btn text color="primary" #click="modalTest = false">Cancel</v-btn>
<v-btn text color="primary" #click="saveData">OK</v-btn>
</v-date-picker>
<v-slide-y-transition>
<v-col cols=2 v-show="dateTest !== null">
<template v-for="allowedTime in allowedTimes">
<v-btn
#click="setTime(allowedTime)"
class="my-2"
:outlined="allowedTime !== time"
block
x-large
color="primary"
>{{ allowedTime }}</v-btn>
</template>
</v-col>
</v-slide-y-transition>
</row>
</v-dialog>
{{dateTest}}
</v-container>
</v-content>
</v-app>
</div>
If I click button "call date", it will call datepicker. If I select a date, I want it call a method
How can i do it?
You can use #change="myMethod" or #click:date="myMethod" on v-date-picker.
Read vuetify date-picker documentation (events section) for more information.

I cant vertically align items in center #vuetify

i've been looking for 3 hours and cant find solution for my problem, dont know what am i doing wrong
All i want is to vertically align these 3 v-flex elements
<template>
<div class="home">
<v-container fluid class="pa-0">
<v-img :src="require('#/assets/images/background.jpg')" max-height="100%">
<v-layout align-center column>
<v-flex class="mb-2">
<span class="primary--text text-uppercase display-3 font-weight-thin">List</span>
<span class="white--text text-uppercase display-3 font-weight-thin">Series</span>
</v-flex>
<v-flex class="mb-4">
<h4 class="subheading grey--text">Follow the series you've been watching or are still watching!</h4>
</v-flex>
<v-flex>
<v-btn color="primary" depressed flat outline to="/add">
go to add
</v-btn>
</v-flex>
</v-layout>
</v-img>
</v-container>
</div>
</template>
One solution would be to move the image out of the container. Then use style="height: 100%;" align-center d-flex on container to make it fill image area and display contents vertically in the middle. Also you might want to consider image max-height="100vh" to prevent scrolling on smaller screens.
new Vue({
el: '#app'
})
<link href="https://cdn.jsdelivr.net/npm/vuetify#1.2.2/dist/vuetify.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify#1.2.2/dist/vuetify.min.js"></script>
<div id="app">
<template>
<div class="home">
<v-img src="https://images.unsplash.com/photo-1562696482-77619dec0ae7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1351&q=80" max-height="100%">
<v-container style="height: 100%;" align-center d-flex fluid class="pa-0">
<v-layout align-center column>
<v-flex class="mb-2">
<span class="primary--text text-uppercase display-3 font-weight-thin">List</span>
<span class="white--text text-uppercase display-3 font-weight-thin">Series</span>
</v-flex>
<v-flex class="mb-4">
<h4 class="subheading grey--text">Follow the series you've been watching or are still watching!</h4>
</v-flex>
<v-flex>
<v-btn color="primary" depressed flat outline to="/add">
go to add
</v-btn>
</v-flex>
</v-layout>
</v-img>
</v-container>
</div>
</template>
</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.