Zippy UI enhancement

This commit is contained in:
Roman Hotsiy 2016-06-29 18:02:29 +03:00
parent 0b0f28cd4a
commit 44e52febc6
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 50 additions and 30 deletions

View File

@ -1,11 +1,13 @@
<div class="zippy zippy-{{type}}" [ngClass]="{'zippy-empty': empty}">
<div class="zippy-title" (click)="toggle()">
<span class="zippy-indicator">{{ visible ? '&#9662;' : '&#9656;' }}</span>
<div class="zippy zippy-{{type}}" [ngClass]="{'zippy-empty': empty, 'zippy-hidden': !visible}">
<div *ngIf='!headless' class="zippy-title" (click)="toggle()">
<span class="zippy-indicator">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve">
<polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "/>
</svg>
</span>
{{title}}
</div>
<div class="zippy-content" @openClose="visible ? 'expanded' : 'collapsed'">
<div class="zippy-content-wrap">
<div class="zippy-content">
<ng-content></ng-content>
</div>
</div>
</div>

View File

@ -38,19 +38,42 @@ $zippy-redirect-bg-color: rgba($zippy-redirect-color, .08);
background-color: $zippy-info-bg-color;
}
}
.zippy-indicator svg {
height: 1.2em;
vertical-align: middle;
transition: all 0.3s ease;
transform: rotateZ(-180deg);
}
.zippy-hidden > .zippy-title svg {
transform: rotateZ(0);
}
.zippy-title polygon {
.zippy-success > & {
fill: $zippy-success-color;
}
.zippy-error > & {
fill: $zippy-error-color;
}
.zippy-redirect > & {
fill: $zippy-redirect-color;
}
.zippy-info > & {
fill: $zippy-info-color;
}
}
span.zippy-indicator {
width: 1em;
font-size: 1.2em;
margin-right: 0.2em;
position: relative;
top: 0;
text-align: center;
display: inline-block;
}
.zippy-content {
overflow: hidden;
}
.zippy-content-wrap {
padding: 15px 0;
}
@ -60,15 +83,21 @@ span.zippy-indicator {
}
.zippy-indicator {
svg {
display: none;
}
&:before {
content: "";
font-weight: bold;
}
}
.zippy-content {
display: none;
}
}
.zippy-hidden {
.zippy-hidden > .zippy-content {
overflow: hidden;
visibility: hidden;
height: 0;

View File

@ -1,31 +1,20 @@
'use strict';
import { Component, EventEmitter, Output, Input,
trigger, state, animate, transition, style } from '@angular/core';
import { Component, EventEmitter, Output, Input } from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
@Component({
selector: 'zippy',
templateUrl: './zippy.html',
styleUrls: ['./zippy.css'],
directives: [CORE_DIRECTIVES],
animations: [
trigger('openClose', [
state('collapsed, void',
style({ height: '0px' })),
state('expanded',
style({ height: '*' })),
transition('collapsed <=> expanded', [
animate(200)
])
])
],
directives: [CORE_DIRECTIVES]
})
export class Zippy {
@Input() type = 'general';
@Input() visible = false;
@Input() empty = false;
@Input() title;
@Input() headless: boolean = false;
@Output() open = new EventEmitter();
@Output() close = new EventEmitter();
toggle() {