haw i can adapt dhtmlxGantt display screen with my component? - css

i use dhtmlxGantt because i need gantt diagram in my project but i have a desplay problem . i use vuejs component that's why i put the code of dhtmlxGantt in my component but the display isn't clear
this is my code :
//Gantt component
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-body">
<div id="gantt_here">
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
created(){
gantt.init("gantt_here");
},
mounted() {
console.log('Component mounted.')
}
}
</script>
<style scoped>
body{
margin: 10px ;
}
</style>
and i call this two file
<script src="https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js"></script>
<link href="https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.css" rel="stylesheet">
please i need help

VueJS is very complicated when it comes to javascript components external to the components, what I can advise you in this case is to do the internal import of the component's library and try to use it, as I never used this component, so I don't know if it uses jQuery, but there are ways to use jQuery in VueJS.
An example of how you would use it would be installing the library using the command npm install --save #types/dhtmlxgantt, and importing it into your component.
<script>
import gantt from '#types/dhtmlxgantt'
export default {
...
created() {
gantt.init("gantt_here");
}
}
</script>

Related

Why my css styling does not work in Vue.js?

I'm new in web development and vue.js. I've tried in many ways to style my code however, it didn't work. Here is my vue.js code example. Please let me know how to style it. I am providing my code implementation here. I created a figure, figcaption, and image markup which acts as a description for my profile and I want to add css to it
<!DOCTYPE HTML>
<html>
<head>
<title>v-if If Statements</title>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
.special {background:yellow; border: 1px dotted #fe0000; padding:30px; display:block; text-align:center;}
.important {font-weight:bold; font-size:30px;}
</style>
</head>
<body>
<div id="app">
<figure>
<img v-if="profile.pic" :src="profile.pic">
<div v-if="profile.fname && profile.lname">
Profile: {{profile.fname}} {{profile.lname}}
</div>
<div v-else>
No First or Last name found.
</div>
<figcaption>
<div v-if="profile.desc">
Desc: {{profile.desc}}
</div>
<div v-else>
No description found.
</div>
<div v-if="profile.bio">
Bio: {{profile.bio}}
</div>
<div v-else>
No bio found.
</div>
</figcaption>
</figure>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
profile: {
fname: "Chris",
lname: "Picasso",
desc: "Student",
bio: "Web developer",
pic: "https://i.pinimg.com/custom_covers/222x/85498161615209203_1636332751.jpg"
}
}
});
</script>
Where have you been applied the css? I can't see anything.
You have to add classes in elements like this. You may also can do this programmatically. But I don't know Vue. So please look into the docs.
<div v-if="profile.fname && profile.lname" class="important" >
Profile: {{profile.fname}} {{profile.lname}}
</div>

I would like to know how to style bs5-lightbox

I hope someone can help a numpty :)
I am using Boostrap 5 and this Lightbox library https://trvswgnr.github.io/bs5-lightbox/
It uses data-toggle="lightbox" to initiate it and is working perfectly.
<a href="http://fpoimg.com/200x200?text=Forth" data-toggle="lightbox" data-gallery="gallery" >
<img src="http://fpoimg.com/200x200?text=Forth"></a>
I would like to apply some css styling eg. lightbox background-color, padding etc but I have no idea where to start.
I used to use the ekko-lightbox for BS4 which had its own CSS but I can't find one for this.
As I can see, bs5-lightbox library doesn't have it's own stylings, and using BS5 markups and stylings.
So you can apply BS5 stylings and HTML you want.
You can start by browsing .lightbox-carousel (CSS class selector) on your page and create custom styling.
Based on this class you can customize it's child nodes.
img {
width: 200px;
}
/* this is how you can add stylings to wrapper, f.e. */
.lightbox-carousel.carousel {
padding: 1rem;
background: #ffffff7a;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script type="module">
import * as Lightbox from 'https://cdn.jsdelivr.net/npm/bs5-lightbox#1.7.8/dist/index.bundle.min.js';
document.querySelectorAll('.my-lightbox-toggle').forEach((el) => el.addEventListener('click', (e) => {
e.preventDefault();
const lightbox = new Lightbox(el);
lightbox.show();
}));
</script>
<a href="https://unsplash.it/1200/768.jpg?image=251" data-toggle="lightbox">
<img src="https://unsplash.it/600.jpg?image=251" class="img-fluid my-lightbox-toggle">
</a>

Angular 7 sticky footer with bootstrap4

I'm learning angular7 and I would create a sticky footer. I've tried a lot of solutions.
I tried :
https://getbootstrap.com/docs/4.3/examples/sticky-footer-navbar/
some solution in stackoverflow
some solution found via google search (like this)
No one works for me. I don't understand why, and I need help.
I have this code after removing all I've tried:
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MenuComponent } from './menu/menu.component';
import { FooterComponent } from './footer/footer.component';
#NgModule({
declarations: [
AppComponent,
MenuComponent,
FooterComponent,
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
index.html (just the body)
<!doctype html>
<html lang="en">
<head>
...
</head>
<body class="d-flex flex-column h-100">
<app-root></app-root>
</body>
</html>
app.component.html
<app-menu></app-menu>
<main class="container">
<router-outlet></router-outlet>
</main>
<div class="footer mt-auto py-3">
<app-footer></app-footer>
</div>
footer.component.html
<footer>
© 2019 - Zackna
</footer>
Edit: I update my codes with #avcajaraville answer that I have already tried but removed ^-^. And there is
my result, as you can see my footer is not sticky to the bottom of the page.
Is a bootstrap native solution exists? My footer does not have a definitive height. What do I need to do to achieve my goal?
Thanks to #avcajaraville for the answer.
Unfortunately, I missed the class h-100 when I tried it and I don't see i:/
In the meantime, I found a solution.
I added this CSS to my app-root component:
app-root {
height: 100vh;
display: flex;
flex-direction: column;
}
and a flex-grow: 1; to my container class.
According to your code samples, you are not adding the classes you need.
You can fix that by mimicking the same structure as in the example you provided:
index.html
<!doctype html>
<html lang="h-100">
<head>
...
</head>
<body class="d-flex flex-column h-100">
<app-root></app-root>
</body>
</html>
app.component.html
<app-menu></app-menu>
<main class="container">
<h1>title</h1>
<router-outlet></router-outlet>
</main>
<div class="footer mt-auto py-3">
<app-footer></app-footer>
</div>
I think this would give you the expected behavior.
In general, when working with a CSS framework, you need to use the classes specified in your html. Otherwise, no CSS can be applied.
EDIT
I added the needed class on the html tag in your index.html file & refactor app.component.html
Another way to do this if you want to just use the bootstrap utility classes and not write custom css using app-root's component css or custom css via :host
In your index.html do this,
<html class="h-100">
<head>....omitted</html>
<body class="h-100">
<app-root class="d-flex flex-column h-100"></app-root>
</body>
</html>
to recap, if you're following the sticky footer example from Bootstrap4 website using Angular then you need to put the utility class on app-root not the body and make sure just height of body element is set to 100% using h-100 (also need h-100 on html element as well!!)
This will always calculate the total height set the min-height for the content div for me the 202px was perfect.This will push the footer at the bottom.
.main-content {
min-height: calc(100vh - 202px);
}
<main>
<div class="main-content"></div>
<app-footer class="footer"></app-footer>
</main>

Meteor Flow Router Dynamic Template

I've been working on my on meteor app. Now it will be great if my maincontent on the mainpage is dynamic. I got this code:
main.html
<head>
<title>Taskmanager</title>
</head>
<body>
{{> navBar}}
{{> mainlayout}}
</body>
mainlayout.html
<template name="mainlayout">
<main>
{{> Template.dynamic template=main}}
</main>
</template>
routes.js
FlowRouter.route('/', {
name: 'home',
action: function() {
BlazeLayout.render('mainlayout', {main: 'noteOverview'});
}
});
noteoverview.html
<template name="noteOverview">
<div class="container">
<h3>Latest Tasks</h3>
</div>
</template>
When i open the page, the mainlayout doesn't load the noteoverview.html in. Do i miss something? Thanx for any help!
SOLVED:
I forgot to add the package: kadira:blaze-layout....stupid fault
I see that you have a navbar on your template.
Maybe the <h3>Latest Tasks</h3> on your notesOverview template is hiding behind the navbar.
Try adding
body{
margin-top:80px;
}
to your app's stylesheet.

TypeError: Swiper is not a constructor

I'm trying to get Swiper to work but it always throw me an error "Swiper is not a constructor"
I'm using http://idangero.us/swiper/get-started/#.WMsuihJ96MI as the Swiper library and installed this library as a meteor package.
client/body.js
Template.slider.onRendered(function(){
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'vertical',
loop: true,
// If we need pagination
pagination: '.swiper-pagination',
// Navigation arrows
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
// And if we need scrollbar
scrollbar: '.swiper-scrollbar',
});
});
client/body.html
<body>
<h1>Test</h1>
{{> slider }}
</body>
<template name="slider">
<!-- Slider main container -->
<div class="swiper-container">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- If we need scrollbar -->
<div class="swiper-scrollbar"></div>
</div>
</template>
#mutdmour You should try Swiper.default(element,options)
Make sure to console you Swiper instance and check if, It's really a constructor or it's an object which has it's constructor in it's property. Sorry if I give a wrong info. Because my english is very weak and this is my first reply to a Forum.
In my case i fixed it by changing
import {Swiper, SwiperOptions} from "swiper";
to
import Swiper, {SwiperOptions} from "swiper";

Resources