Vuetify Fullscreen property not creating an element with height:100% - vue.js

I am still very new to the Vue.js and Vuetify frameworks. I am currently trying to create a front page element with a css property of height:100% in Vuetify, but for some reason I am unable to fill the page with the first row element.
As seen below, I am using the "fullscreen" Vuetify property in the v-row element.
Thanks!
<template>
<div class="home">
<v-row class="grey fullscreen" align="center" justify="space-around">
<v-col xs=12 md=5>
<h1 class="main-title">Clever and<br> Practical Designs<span class="redDot">.</span></h1>
<h3 class="sub-title">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quo exercitationem repellat, officia consequuntur obcaecati voluptate cum voluptas placeat dolores temporibus vel ex saepe reprehenderit porro asperiores cumque distinctio accusantium optio.</h3>
<v-row>
<v-btn href="" class="button white--text pa-4">
View our Products
</v-btn>
</v-row>
</v-col>
<v-col xs=12 md=5>
<v-img contain class="homeimg" max-width="500px" src="../assets/Large_product.png"></v-img>
</v-col>
</v-row>
</div>
</template>

I found a solution:
Adding a style element in the App.vue file to get the fullscreen class to function properly :
<template>
<v-app>
<Navbar />
<v-content>
<router-view></router-view>
</v-content>
</v-app>
</template>
<script>
import Navbar from '#/components/Navbar'
export default {
name: 'App',
components: { Navbar },
data: () => ({
//
}),
};
</script>
<style lang="scss">
.fullscreen {
width: 100%;
height: 100vh;
}
</style>

Related

Veutify v-card doesn't align properly when controlling it's width within a timeline component

Using an example from their official website, I'm attempting to control the width of a v-card that is being used within a timeline component. When I added max-width="400px" to the the v-card component the timeline items that render on the left side no longer align within the center as such.
<div id="app">
<v-app id="inspire">
<v-timeline
align-top
:dense="$vuetify.breakpoint.smAndDown"
>
<v-timeline-item
v-for="(item, i) in items"
:key="i"
:color="item.color"
:icon="item.icon"
fill-dot
>
<v-card
:color="item.color"
dark
max-width="400px"
>
<v-card-title class="text-h6">
Lorem Ipsum Dolor
</v-card-title>
<v-card-text class="white text--primary">
<p>Lorem ipsum dolor sit amet, no nam oblique veritus. Commune scaevola imperdiet nec ut, sed euismod convenire principes at. Est et nobis iisque percipit, an vim zril disputando voluptatibus, vix an salutandi sententiae.</p>
<v-btn
:color="item.color"
class="mx-0"
outlined
>
Button
</v-btn>
</v-card-text>
</v-card>
</v-timeline-item>
</v-timeline>
</v-app>
</div>

Modifying the html style of children component in parent component in Vue 2

I am doing an npm timeline Vue component. But I am facing problems.
parent component A:
<script>
export default Vue.extend({
name: "aComponent",
})
</script>
<template>
<div class="events-content">
<ol>
<slot name="eventsContent"></slot>
</ol>
</div>
</template>
children component B:
<aComponent>
<template v-slot:eventsContent>
<li class="selected" ref="event-1">
<p>
orem ipsum dolor sit amet, consectetur adipisicing elit. Illum
praesentium officia, fugit recusandae ipsa, quia velit nulla
adipisci? Con
</p>
</li>
<li>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum
praesentium officia, fugit recusandae ipsa, quia velit nulla
adipisci? Con
</p>
</li>
</template>
</aComponent>
Now I want to modify the style of li of Children component B in the method of parent component A. That is why I tried to use ref="event-1" to access in parent component A, but it doesn't work. I don't want to add too much code in children component B, because it is going to be npm package. So how can I modify each li style from children component B in parent component A
The parent component can style the slotted children with its own <style> block:
<!-- ParentComponent.vue -->
<template>
<aComponent>
<template v-slot:eventsContent>
<li class="selected">
⋮
</li>
<li>
⋮
</li>
</template>
</aComponent>
</template>
<style>
li {
color: #444;
}
.selected {
font-weight: bold;
color: blue;
}
</style>
demo

Stacking V-Card children overlaps and misaligns

I'm trying to stack a v-card-title on top of a v-card-subtitle and then v-card-text and the text is overlapping. Don't these elements vertically stack by default?:
<v-main>
<v-container fluid style="padding:0px">
<v-row no-gutters>
<v-col :cols="12" :md="6">
<v-card
height='100%'
style="position: relative"
elevation="0">
<v-card-title
class="header">
lorem ipsum dolor
</v-card-title>
<v-card-subtitle class="subHeader">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor
</v-card-subtitle>
<v-card-text class="subText">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum
dolor lorem ipsum dolor dolor lorem ipsum dolor dolor lorem ipsum
dolor
</v-card-text>
</v-card>
</v-col>
<v-col :cols="12" :md="6">
<v-img :src="{myImage}"></v-img>
</v-col>
</v-row>
{...about 4 more rows identical to above...}
</v-container>
</v-main>
and here are my styles:
.header{
font-family: 'Cormorant Garamond', serif;
font-size: 85px;
}
.subHeader{
font-family: 'Montserrat', sans-serif;
font-size: 28px;
}
.subText{
font-family: 'Montserrat', sans-serif;
font-size: 15px;
letter-spacing: 1.5px;
color:#333;
}
and then if I try to vertically + horizontally center everything using this on the v-card, everything then lines up horizontally:
class="d-flex align-center justify-center"
What am I just not getting here?
Using d-flex turns your card into a flexbox container transforming direct children elements. What you're seeing is the default behavior of flex children. They display in a row because by default the flex-direction property is set to row. Read more at MDN Web Docs.
Anyway, you don't need to use d-flex in this case. Vuetify provides a helper class fill-height that will center the contents of the v-container. From the docs:
fill-height applies height: 100% to an element. When applied to v-container it will also align-items: center.
For example:
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
<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#6.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<div id="app">
<v-app>
<v-main>
<v-container fluid fill-height style="padding:0px">
<v-row no-gutters justify=center>
<v-col cols="6">
<v-card class="" elevation="2" >
<v-card-title class="header">
lorem ipsum dolor
</v-card-title>
<v-card-subtitle class="subHeader">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor
</v-card-subtitle>
<v-card-text class="subText">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor lorem ipsum dolor dolor lorem ipsum dolor dolor lorem ipsum dolor
</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</v-main>
</v-app>
</div>
<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>

how to change selected text in v-textarea Vue.js?

I want a function to be called when a button is clicked to change the selected text that is in a v-container, how can I do that?
I will be glad to any information
<template>
<div class="text">
<v-btn
#click="editText"
>
</v-btn>
<v-textarea
v-model="text"
></v-textarea>
</div>
</template>
<script>
export default {
name: "ArticleForm",
data() {
return {
text: 'some text',
}
},
methods: {
editText() {
... how?
}
}
}
</script>
<style scoped>
</style>
You can use window.getSelection for the selected text. Here is the demo
SFC:
<template>
<v-app>
<v-content>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore facere
aspernatur explicabo voluptatibus? Non temporibus, dicta illum
perferendis error voluptatum. Rerum officiis debitis voluptas earum
nulla consequatur necessitatibus tenetur eius.
</div>
<v-btn class="my-5" #click="editText">Edit</v-btn>
<v-textarea v-model="text"></v-textarea>
</v-content>
</v-app>
</template>
<script>
export default {
name: "App",
data() {
return {
text: "",
};
},
methods: {
editText() {
if (window.getSelection) this.text = window.getSelection().toString();
},
},
};
</script>

Vue 2.0 Component - could not render all <div>s within a template

I am composing a modal component as I learn VueJS. The modal component basically consists of two major elements: the actual box containing all contents and an overlay.
Now the problem I am stuck in is the overlay element is not rendered at all. But if I moved the overlay from the component template to parent scope, everything would be alright.
Here is the code of parent scope:
<my-modal v-show="show" v-on:hide="show = false"></my-modal>
<!-- Overlay will be rendered properly if I put overlay here. -->
<!-- <div class="my-modal-overlay" v-show="show" #click="show = false"></div> -->
And the code of component template:
<template id="tpl-my-modal">
<transition name="modal-fade" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
<div class="my-modal-box">
<div class="my-modal-content">
<div class="my-modal-header"><h1>Title</h1></div>
<div class="my-modal-body">Body</div>
<div class="my-modal-footer"><button class="btn btn-danger" #click="$emit('hide')">Close</button></div>
</div>
</div>
<!-- Overlay is not rendered at all if I put it here. -->
<div class="my-modal-overlay" #click="show = false"></div>
</transition>
</template>
The Javascript:
Vue.component('my-modal', {
template: '#tpl-my-modal'
})
Two screenshots. The grey layer is the overlay element which covers all the viewport.
Could anyone shed some light upon the problem? Thank you!
Update:
Here come the snippets. Feel free to comment/comment out line 11 / line 26 in HTML to see the difference.
Update:
It turns out that a Vue Component can have no more than one root element, and <transition> tag can only have a single element, which means what I did before was wrong.
Thus I tweaked the code a bit, and now in the console Vue does not complain any more. And both modal box and overlay are rendered.
<template id="tpl-my-modal">
<div>
<transition name="modal-fade" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
<div class="my-modal-box">
<div class="my-modal-content">
<div class="my-modal-header">
<h1>{{ program.title }}</h1></div>
<div class="my-modal-body"> {{ program.intro }}</div>
<div class="my-modal-footer">
<button class="btn btn-danger" #click="$emit('hide')">Close</button>
</div>
</div>
</div>
</transition>
<div class="my-modal-overlay" #click="show = false"></div>
</div>
</template>
But one problem is unsolved: all transitions are gone. Here are the snippets. What is the problem?
For the transition problem, you should put the transition tag right after the root div of your template like this..
<template id="tpl-my-modal">
<transition name="modal-fade" enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
<div>
//the rest of your code..
because v-show will be applied to the root div when you use it to the component my-modal
<my-modal v-show="show" v-on:hide="show = false" v-bind:program="activeProgram"></my-modal>
check this fiddle https://jsfiddle.net/cihkem/0rmt28y2/
Vue.component('my-modal', {
template: '#tpl-my-modal',
props: ['program', 'show']
})
new Vue({
el: '#app',
data: {
show: false,
activeProgram: {},
programs: [{
title: 'Westworld',
intro: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eligendi cum incidunt ipsum impedit nostrum, repellendus illum, officia labore neque ea quam ad maiores corporis deserunt quos odio distinctio similique in.'
}, {
title: 'Game of Thrones',
intro: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet perspiciatis eos aperiam, veritatis, voluptate eius similique saepe libero consectetur suscipit dolorem molestiae animi nostrum voluptatem quidem sapiente? Fugit, hic, fugiat!'
}, {
title: 'X Files',
intro: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit nobis, nisi ex exercitationem magnam nemo repudiandae dolor maxime odio reprehenderit animi ducimus a consequatur, saepe suscipit dolorem ratione tempore perferendis.'
}]
},
methods: {
showDetails: function(program) {
this.show = true;
this.activeProgram = program;
}
}
})
.my-modal-overlay {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1040;
background-color: #000;
opacity: .3;
}
.my-modal-box {
opacity: 1;
position: relative;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
}
.my-modal-content {
background-color: #fff;
position: relative;
height: auto;
width: 600px;
margin: 30px auto;
padding: 10px;
z-index: 1050;
}
.my-modal-header {
text-align: center;
}
.my-modal-body,
.my-modal-footer {
padding: 10px 0;
}
.my-modal-header,
.my-modal-body {
border-bottom: 1px solid #d0d0d0;
}
.my-modal-footer {
text-align: right;
}
.program-list-item {
padding: 3px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<body>
<div class="container">
<div id="app">
<ol>
<li v-for="program in programs" class="program-list-item">
{{ program.title}}
<button class="btn btn-primary btn-sm" #click="showDetails(program)">Details</button>
</li>
</ol>
<my-modal :show="show" v-on:hide="show = false" v-bind:program="activeProgram"></my-modal>
<!-- <div class="my-modal-overlay" v-show="show" #click="show = false"></div> -->
</div>
</div>
<template id="tpl-my-modal">
<div>
<transition enter-active-class="animated zoomIn" leave-active-class="animated zoomOut">
<div v-show="show" class="my-modal-box" key="modal">
<div class="my-modal-content">
<div class="my-modal-header">
<h1>{{ program.title }}</h1></div>
<div class="my-modal-body"> {{ program.intro }}</div>
<div class="my-modal-footer">
<button class="btn btn-danger" #click="$emit('hide')">Close</button>
</div>
</div>
</div>
</transition>
<div v-show="show" class="my-modal-overlay" #click="show = false" key="overlay"></div>
</div>
</template>
</body>
Is it what you need?