Buefy vertical thumbnails carousel? - vue.js

When I use the b-carousel tag, it's working but the thumbnails are horizontal. How do I make them vertical?
This is the code:
<template>
<b-carousel :indicator-inside="false">
<b-carousel-item v-for="(item, i) in 6" :key="i">
<span class="image">
<img :src="getImgUrl(i)">
</span>
</b-carousel-item>
<template slot="indicators" slot-scope="props">
<span class="al image">
<img :src="getImgUrl(props.i)" :title="props.i">
</span>
</template>
</b-carousel>
</template>
<script>
export default {
methods: {
getImgUrl(value) {
return `https://picsum.photos/id/43${value}/1230/500`
}
}
}
</script>
<style>
.is-active .al img {
filter: grayscale(0%);
}
.al img {
filter: grayscale(100%);
}
</style>
OUTPUT THAT I WANT:

Note: This solution has a disadvantage in that it relies on the CSS implementation details of b-carousel, but that might be acceptable for your use case:
You could use CSS to style the b-carousel elements:
.carousel - the root container
.carousel-indicator - the thumbnail container (a flex item)
.indicator-item - each thumbnail item
Two columns
Grid Layout could be most helpful in this case, as we essentially want a 2-column grid. This is done by applying display: grid to the root container, and grid-template-columns: auto 25% to create the main-image column and the thumbnail column:
.carousel {
display: grid;
grid-template-columns: auto 25%;
align-items: center;
}
Vertical thumbnails
Flexbox applies here. The thumbnail container is already using it, but it uses the default flex-flow of row (horizontal). We could easily change that to column to make it vertical:
.carousel-indicator {
flex-direction: column;
}
Thumbnail margins
The thumbnails have a margin-right between elements, intended to provide visual space between the horizontal images. Since we're switching it to a vertical layout, we can remove the margin:
.indicator-item {
margin-right: initial !important;
}

Related

Animated tree navigation using Vue & Nuxt

I'm starting to learn a few basics with nuxt & vue.
I'm basically building a little list of elements that you can click and will expand with an image or some other content.
What I made so far
is an homepage with the list (like the first image)
and 3 other pages : /about, /projects, /contact
Here is the demo with images :
As soon as I click the first link, an image appears, and everything is moved down to the bottom. The URL is updated with the corresponding url (here, /about)
What I would like to achieve:
So far it's working fine and I can naviguate on my website.
But as the images suggests, I would like the differents elements of the menu to move with an animation to the bottom on the page transition to the different pages, it would take them (let's say) 2 seconds to go their next position in the next page.
It would look something like that : https://codepen.io/pbouigue/pen/KKVxbYa
when you click a dropdown menu like first videothe menu expends and everything is moved down.
The issue with that is that the url is not updated and considered to move to another page (in the case it should be exemple.com/first-video
<template>
<div class="container">
<transition-group name="list">
<nuxt-link to="about" key="about">First item - about</nuxt-link>
<img src="../assets/ours.png" alt="">
//these two remaining items should have an animation when they move to the bottom of the image
<nuxt-link to="projects" key="projects">Second item - projects</nuxt-link>
<nuxt-link to="contact" key="contact">Last item - contact</nuxt-link>
<transition-group>
</div>
</template>
<style >
img{
display: block;
width: 40%;
}
a{
display: block;
color: orangered;
font-family: 'Courier New', Courier, monospace;
}
</style>
and my /about :
<template>
<div class="container">
<transition-group name="list">
<nuxt-link to="about" key="about">First item - about</nuxt-link>
<nuxt-link to="projects" key="projects">Second item - projects</nuxt-link>
<nuxt-link to="contact" key="contact">Last item - contact</nuxt-link>
<transition-group>
</div>
</template>
<style >
img{
display: block;
width: 40%;
}
a{
display: block;
color: orangered;
font-family: 'Courier New', Courier, monospace;
}
</style>
Do you have any help on how to achieve that? Maybe there is an easier way to do it, but since I'm all new and learning by myself, I would have loved some clues or a little help.
I read about transition-group and this css, but somehow, I can't manage to make it work...
.list-enter-active,
.list-leave-active {
transition: all 0.5s ease;
}
.list-enter-from,
.list-leave-to {
opacity: 0;
transform: translateX(30px);
}
because actually this :https://vuejs.org/guide/built-ins/transition-group.html#move-transitions
does exactly what i would like to do : move elements down in an animation, but I would like this to happen on a page transition in order to have to url updated.
Maybe I should look for https://router.vuejs.org/guide/essentials/nested-routes.html ?

How to resize vs-popup in the context of vuejs

Im using vs-popup in order to display the contents when ever the button is clicked, but the size of vs-popup is fixed, and my contents looks clumsy, so I want someone to tell me how I can change width of the popup as per my requirement.
<vs-button class="btn" #click=" showModal=true" color="#7367F0" > Click me</vs-button>
<vs-popup class="helundo" title="How will i resize popup" :active.sync="showModal">
<div class="vx-row">
<div class="vx-col w-full md:w-1/2 mb-base">
<p> I want this content in the left</p>
</div>
<div class="vx-col w-full md:w-1/2 mb-base">
<p> I want this content in the right</p>
</div>
</div>
</vs-popup>
<script>
export default {
data () {
return {
showModal: false
}
}
}
</script>
<style>
<!-- what should I add in order to resize the popup -->
</style>
And the output I'm obtaining is sent below:
I want the popup bigger and it should be flexible such that what ever content I add must fit accordingly.
Please do help me, as I am unable to change the width of the popup, what ever I do it is same, but if I add too many contents the width increases for a extend and it becomes scrollable.
I found out the answer myself, i am posting so that it can help others. If you are using vuesax library you might find out _fixesVuesax.scss
so just place this code there:
.con-vs-popup {
z-index: 53000;
.vs-popup {
width: 200px !important; //You can change the width according to your content
height: auto;
}
.vs-popup--content {
width: auto !important;
padding: 1rem;
font-size: 1rem;
}
}

*ngIf Hide and show the div slowly and move a div slowly to right/left in angular2+

<div id="abc">
<div id="bac" ngIf="show">
<!-- Content -->
</div>
<div id="cde">cds</div>
</div>
I have a div want to add or remove from DOM slowly(show and hide) using *ngIf and likewise adding or removing of div.id ="bac" should cause div.id='cde' to move left or right slowly like it is animating.
*ngIf probably is not he best thing you are looking for, instead of this, use ngClass and define the css transitions and positions for these animations.
*ngIf fully hides/shows a node from/in DOM, it's like display: none/block which is not able to be animated through css-transitions
here is an example
<div class="animated" [ngClass]=" { 'show': show, 'hide': !show }">
content
</div>
then in the css
.animated {
display: inline-block;
width: 100%;
height: 80px;
background: gray;
transition: 1.5s linear margin-left;
}
.animated.show {
margin-left: 0;
}
.animated.hide {
margin-left: -120vw;
}
Height also can be changed, depends on which effect you expect.
Here is stackblitz with working code

Polymer Page with different app-header on home page

i'm trying to make difference between home page and other page in polymer 2.0
Home page = With big header and condensed
Other Page = just as usual app-header with small header on the top
what i try to do is using dom-if, i create dom-if with 2 kind of app-header
_isHome(page) {
return page === "view1";
}
app-header#homeHeader {
color: #fff;
height: 500px;
--app-header-background-front-layer: {
background-image: url(../images/Digital-Signage-Slider3a.jpg);
background-size: cover;
background-repeat: no-repeat;
}
;
}
app-header#defaultHeader {
color: #fff;
background-color: var(--app-primary-color);
}
<app-header-layout>
<template is="dom-if" if="[[_isHome(page)]]">
<app-header id="homeHeader" slot="header" condenses reveals effects="parallax-background" style="height: 500px">
<app-toolbar>
<div main-title>My App</div>
<paper-icon-button icon="my-icons:menu" drawer-toggle></paper-icon-button>
</app-toolbar>
</app-header>
</template>
<template is="dom-if" if="[[!_isHome(page)]]">
<app-header id="defaultHeader" slot="header" condenses reveals effects="material">
<app-toolbar>
<div main-title>My App</div>
<paper-icon-button icon="my-icons:menu" drawer-toggle></paper-icon-button>
</app-toolbar>
</app-header>
</template>
<iron-pages selected="[[page]]" attr-for-selected="name" fallback-selection="view404" role="main">
<my-view1 name="view1"></my-view1>
<my-view2 name="view2"></my-view2>
<my-view3 name="view3"></my-view3>
<my-view404 name="view404"></my-view404>
</iron-pages>
</app-header-layout>
and guess what? it worked, but with some space after it, but the space is gone after refreshed hmm..
Home Page with large image condensed header
After click on the 2nd page
After refreshed
any idea?
Revised Solution
I had another go at this because on an app I started yesterday. I think I've a simplier solution, with only one app-header and one app-toolbar.
First I replace the app-header#... styles with these:
.main-title {
color: #fff;
height: 500px;
--app-header-background-front-layer: {
background-image: url(../images/Digital-Signage-Slider3a.jpg);
background-size: cover;
background-repeat: no-repeat;
}
;
}
.condensed-title {
color: #fff;
background-color: var(--app-primary-color);
}
The header and toolbar are now
<app-header-layout id="header" has-scrolling-region>
<app-header class$=[[_getHeaderClass(page)]] slot="header" fixed effects="waterfall">
<app-toolbar>
<template is="dom-if" if=[[_isHome(page)]]>
<div main-title>My App 1</div>
</template>
<template is="dom-if" if=[[!_isHome(page)]]>
<div condensed-title>My App 2 & 3</div>
</template>
<paper-icon-button icon="my-icons:menu" drawer-toggle></paper-icon-button>
</app-toolbar>
</app-header>
...
The function called to set app-header's class is
_getHeaderClass(page) {
return (page === "view1") ? 'main-title' : 'condensed-title';
}
Note that you must still call this.$.header.notifyResize() in _routePageChanged(page).
I've put up a gist of the complete file at my-app-revised.html.
----- former solution -----
Call notifyResize() on the app-header-layout.
If you look at the polymer-starter-kit, give the app-header-layout an id, like id="header":
<app-header-layout id="header" has-scrolling-region>
Then call this.$.header.notifyResize() in _routePageChanged(page):
_routePageChanged(page) {
// If no page was found in the route data, page will be an empty stri.
// Default to 'view1' in that case.
this.page = page || 'view1';
this.$.header.notifyResize();
// Close a non-persistent drawer when the page & route are changed.
if (!this.$.drawer.persistent) {
this.$.drawer.close();
}
}

How to implement Collapsible side bar in Angular2?

I'm learning angular2 and looking to implement a collapsible sidebar, similar to https://almsaeedstudio.com/themes/AdminLTE/index2.html, in Angular 2? I tried looking up examples but couldn't find any. Can you provide examples or documentation for it?
You could use ng2-bootstrap:
https://valor-software.com/ng2-bootstrap/#/accordion
You can also check in the source code how it's implemented:
https://github.com/valor-software/ng2-bootstrap/tree/development/components/accordion
Since you want to do it with Bootstrap, you can do it with Bootstrap collapse.
http://codepen.io/zurfyx/pen/ygaGyb
The idea behind this solution is the following:
Have your collapsible content inside a specific class, we called it collapseMenu. We also need a class that will indicate whether it is hidden or not. Bootstrap already provides it for us collapse.
<li>Icon <span class="collapse collapseMenu">Home</span></li>
Next we need the toggler, the hamburger icon that is. It requires a data-toggle to indicate the class that it has to toggle on each click and a data-target to know the element(s) that has to target, collapseMenu.
<button data-toggle="collapse" data-target=".collapseMenu">Hamburger icon</button>
The CSS part is not a big deal, and you can do it in various ways. I like the CSS3 flexbox approach.
Our page (specifically .container), will be a flex with direction row.
.container {
display: flex;
flex-direction: row;
}
Then we'll set the right panel to take as much space as it can, so as when the content is toggled, it shrinks:
.main {
flex: 1;
}
Complete working version:
HTML
<div class="container">
<div class="left-panel">
<ul>
<li>Icon <span class="collapse collapseMenu">Home</span></li>
<li>Icon <span class="collapse collapseMenu">Contact</span></li>
</ul>
</div>
<div class="main">
<button data-toggle="collapse" data-target=".collapseMenu">Hamburger icon</button>
</div>
</div>
CSS
body {
margin: 0;
padding: 0;
}
ul > li {
display: block;
}
.collapse.in {
display: inline-block;
}
.container {
height: 100vh;
display: flex;
flex-direction: row;
padding: 0;
}
.left-panel {
background-color: grey;
}
.main {
background-color: black;
flex: 1;
}