Nested transition modal - vue.js

i'm creating modal with vuejs and following this example but i create a separated file for modal so i can simply call my modal component anywhere i need to like this
here is my modal.vue
<template>
<div class="modal-mask" #click="close">
<div class="modal-dialog" :class="size">
<div class="modal-content">
<div class="modal-header" :class="color">
<button type="button" class="close" #click="close">×</button>
<h6 class="modal-title">{{ title }}</h6>
</div>
<div class="modal-body">
<slot></slot>
</div>
<div class="modal-footer">
<slot name="button"></slot>
</div>
</div>
</div>
</div>
</template>
<script>
export default{
props: ['title','color','size'],
methods: {
close(){
this.$emit('close');
}
}
}
</script>
<style>
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
transition: opacity .3s ease;
}
</style>
and in index.vue where i want to call it i just simply
<app-modal
:title="modalTitle"
:size="modalSize"
:color="modalColor"
v-if="modalShow"
#close="modalShow = false"
>
</app-modal>
now my question is i want to use 2 kind of transition, first is in my index.vue page
<transition name="modal">
<app-modal
:title="modalTitle"
:size="modalSize"
:color="modalColor"
v-if="modalShow"
#close="modalShow = false"
>
</app-modal>
</transition>
and the second one is in my modal.vue like this
<template>
<div class="modal-mask" #click="close">
<transition name="modal-inside">
<div class="modal-dialog" :class="size">
<div class="modal-content">
<div class="modal-header" :class="color">
<button type="button" class="close" #click="close">×</button>
<h6 class="modal-title">{{ title }}</h6>
</div>
<div class="modal-body">
<slot></slot>
</div>
<div class="modal-footer">
<slot name="button"></slot>
</div>
</div>
</div>
</transition>
</div>
</template>
why i want it like that well simply because in there is modal-mask class that warp entire modal and that css class is add some dark/shade background so user can focus on the modal.... exactly like bootstrap modal fade effect and then after that i want everything inside div modal-dialog to show/transition after modal-mask is already finished its transition
so it will just first darken background and then show modal... they move separately one after another.. not at the same time
or to be more easy to imagine it i want to generate exactly like bootstrap modal

Related

Transition not working for slots in vue 3

I was trying to add transition to a slot like this
<template>
<transition name="committee">
<div class="card">
<slot></slot>
</div>
</transition>
</template>
Added CSS classes like this
.committee-enter-from{
opacity: 0;
transform: translateX(-3rem);
}
.committee-enter-active{
transition: all 1s ease-in;
}
.committee-enter-to{
opacity: 1;
transform: translateX(0) ;
}
The parent template looks like this
<section class="section">
<app-committee>
<div class="content">
<div class="imgText">
<div class="imgBx">
<img src="#">
</div>
<h3>Samanta Doe<br><span>Manager</span></h3>
</div>
<ul class="sci">
<li><a href="#">
</a></li>
<li><a href="#">
</a></li>
</ul>
</div>
</app-committee>
</section>
The transition is not working.
What may be the mistake i am making.
The transition should work with conditional rendering v-if="someCondition" and if you want the transition to run at the first rendering you've to add appear prop, in the case you could use the availability of $slots.default as condition :
<transition name="committee" appear>
<div class="card" v-if="$slots.default">
<slot></slot>
</div>
</transition>

Add Vertical Lines inside Cards

I want to make such a card with a bootstrap meaning I want to divide it into three parts regardless of what the card contains of data and icons
But I was not able to divide it into three parts, how can I do that?
And I was able to display the card in this way:
How can i solve this problem?
Card.vue:
<template>
<div>
<div class="card bg-light mb-3 mr-50" style="max-width: 25rem; height: 10rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h5 class="card-title">Light card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
<div class="card text-white bg-primary mb-3" style="max-width: 18rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h5 class="card-title">Primary card title</h5>
<p class="card-text">Some quick example text to build on the card title and make</p>
</div>
</div>
</div>
</template>
<script>
</script>
<style>
</style>
Is this what your looking for ? You can use bootstrap grid for this, Checkout the docs
.row{
background-color: #efefef;
}
.col{
background-color: white;
margin: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="card">
<div class="container-fluid">
<div class="row">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div>
</div>

Make the space between the columns small inside the card

I have this shape and want to approximate the distance between each column, meaning I want to approximate the distance between each blue piece, how can I do that_?
Card.vue:
<template>
<div>
<div class="card d-inline-flex" style="width: 40rem; height:7rem; ">
<div class="row background">
<div class="col">
<div class="p-5 bg-info rounded-left ">Flex item 1</div>
</div>
<div class="col">
<div class="p-5 bg-info rounded-0 ">Flex item 1</div>
</div>
<div class="col">
<div class="p-5 bg-info rounded-right">Flex item 1</div>
</div>
</div>
</div>
</div>
</template>
<script></script>
<style>
.background {
background-color: #dcdcdc;
}
.d {
margin-left: 4px;
}
</style>
The space is there because bootstrap has a padding-left and padding-right of 15px for the class col pre-defined. So to get the space that you want, just add a custom class to your div and mess around with padding-left and padding-right. But don't forget to use "!important" as you want to override the style defined by Bootstrap. Here is an Example :-
<template>
<div>
<div class="card d-inline-flex" style="width: 40rem; height:7rem; ">
<div class="row background">
<div class="col a">
<div class="p-5 bg-info rounded-left ">Flex item 1</div>
</div>
<div class="col a">
<div class="p-5 bg-info rounded-0 ">Flex item 1</div>
</div>
<div class="col a">
<div class="p-5 bg-info rounded-right">Flex item 1</div>
</div>
</div>
</div>
</div>
</template>
<script></script>
<style>
.background {
background-color: #dcdcdc;
}
.d {
margin-left: 4px;
}
.a {
padding-left:0 !important!;
padding-right:0 !important!;
}
</style>
Here i used a custom class called a, just mess around with padding-left to get the space you need.

How to render a modal that is inside a component from another component in vueJs and Bootstrap

I have a modal inside a Vue component. Now, from another component i want to show that modal(component) when an event happens(click in a button).
This is the code of the component(modal)
This is the component where i want to get the modal
Code of the component with the modal
<template>
<div class="modal fade" id="exampleModal" tabindex="" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modificar Registro Documento</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="false">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button data-dismiss="modal" (click)="modificarRegistro()" type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" scoped>
export default {
name : "Modal"
}
</script>
<style lang="sass" scoped>
</style>
This is the code of the component where i want to get the modal
<template>
<div id="contenedor">
<div id="padre">
<div id="barra">
<Modal/>
<div v-if="producto === 'bebidas'" class="tabcontent">
<div>
<button v-on:click="modal()" data-toggle="modal" data-target="#exampleModal">
<h6>Inka Kola</h6>
<img src="../../assets/incakolaPersonal.jpg" />
</button>
</div>
<div>
<button>
<h6>Coca Kola</h6>
<img src="../../assets/cocaKolaPersona.png" />
</button>
</div>
<div>
<button>
<h6>Sprite</h6>
<img src="../../assets/sprite.webp" />
</button>
</div>
<div>
<button>
<h6>Cielo</h6>
<img src="../../assets/cieloPersonal.webp" />
</button>
</div>
<div>
<button>
<h6>San Mateo</h6>
<img src="../../assets/sanmateoPersonal.webp" />
</button>
</div>
<div>
<button>
<h6>Ruskalla</h6>
<img src="../../assets/ruskalla.webp" />
</button>
</div>
<div>
<button>
<h6>Ron</h6>
<img src="../../assets/ron.webp" />
</button>
</div>
<div>
<button>
<h6>Cristal</h6>
<img src="../../assets/cristal.jpg" />
</button>
</div>
</div>
<div v-if="producto === 'carnes'" class="tabcontent">
<div>
<button>
<h6>Pollo</h6>
<img src="../../assets/pollo.jpg" />
</button>
</div>
<div>
<button>
<h6>Carne</h6>
<img src="../../assets/carne.jpg" />
</button>
</div>
<div>
<button>
<h6>Cerdo</h6>
<img src="../../assets/cerdo.jpg" />
</button>
</div>
</div>
<div v-if="producto === 'tuberculos'" class="tabcontent">
<div>
<button>
<h6>Papa</h6>
<img src="../../assets/papa.jpg" />
</button>
</div>
<div>
<button>
<h6>Yuca</h6>
<img src="../../assets/yuca.jpg" />
</button>
</div>
<div>
<button>
<h6>Olluco</h6>
<img src="../../assets/olluco.webp" />
</button>
</div>
<div>
<button>
<h6>Jengibre</h6>
<img src="../../assets/jengibre.jpg" />
</button>
</div>
</div>
</div>
</div>
</template>
<style lang="sass" scoped>
#contenedor
display: flex
justify-content: center
#padre
width: 100%
display: flex
flex-direction: column
justify-content: center
#barra
margin-top: 40px
display: flex
button
border-radius: 0px
.tabcontent
background-color: #999999
display: flex
flex-wrap: wrap
justify-content: space-around
width: 100%
height: 100%
div
margin: 20px
flex-grow: 1
button
border: 0px
img
width: 100px
height: 120px
</style>
<script>
import Modal from "./Modal";
export default {
name: "Barra",
data: function () {
return {
producto: "bebidas",
modalEstado : false
};
},
methods: {
mostrar: function (a) {
this.producto = a;
},
modal(){
this.modalEstado=true;
console.log(this.modalEstado);
}
},
};
</script>

Cannot bottom align image in jumbotron

I'm trying to bottom align an img in a jumbotron, but cannot figure it out.
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center">
<img src="http://via.placeholder.com/200x200">
</div>
</div>
</div>
</div>
I tried adding the following to the CSS
.vertical-bottom {
display: flex;
align-items: bottom;
}
And then added the additional class to the DIV containing the img
<div class="col-lg-4 text-center vertical-bottom">
This didn't work, why is it so hard to vertically align things in bootstrap?
Here a kind of code:
Bootply
Css:
The media query is set to 1200 because I see you're using col-lg-xx
#media screen and (min-width:1200px) {
.flex_container img{
object-fit: contain;
object-position: 100% 100%;
}
.flex_container {
display: flex;
}
}
Html:
<div class="jumbotron">
<div class="container">
<div class="row flex_container">
<div class="col-lg-8">
<h1>Hello, world!</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="col-lg-4 text-center flex_container">
<img src="http://via.placeholder.com/200x200" style="">
</div>
</div>
</div>
</div>