Added sliding effect to the items

This commit is contained in:
NejcZdovc
2016-10-17 14:35:29 +02:00
committed by József Farkas
parent 51c33cec3c
commit 721e676eb8
7 changed files with 82 additions and 19 deletions

View File

@@ -1,5 +1,10 @@
@import '../../../main-app/global-styles'; @import '../../../main-app/global-styles';
:host {
display: block;
width: 100%;
}
.action--editor { .action--editor {
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
@@ -67,6 +72,7 @@
&-container { &-container {
background: #f5f5f5; background: #f5f5f5;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
padding: 1rem 1.5rem; padding: 1rem 1.5rem;
} }
} }

View File

@@ -1,5 +1,5 @@
<div class="list-group-item action--item" [class.is-editing]="editing"> <div class="list-group-item action--item" [class.is-editing]="editing">
<span *ngIf="moveable" class="glyphicon glyphicon-option-vertical action--movable" aria-hidden="true"></span> <span *ngIf="movable" class="glyphicon glyphicon-option-vertical action--movable" aria-hidden="true"></span>
<div class="action--item--wrap" [class.pointer]="!editing && editable" (click)="editAction()"> <div class="action--item--wrap" [class.pointer]="!editing && editable" (click)="editAction()">
<icon [name]="iconName"></icon> <icon [name]="iconName"></icon>
<div class="action--title">{{ title }}</div> <div class="action--title">{{ title }}</div>
@@ -7,11 +7,11 @@
</div> </div>
<icon *ngIf="deletable" name="trash" (click)="deleteAction()"></icon> <icon *ngIf="deletable" name="trash" (click)="deleteAction()"></icon>
</div> </div>
<div class="list-group-item macro-action-editor__container" *ngIf="editable && editing"> <div class="list-group-item macro-action-editor__container"
<macro-action-editor [@toggler]="((editable && editing) || newItem) ? 'active' : 'inactive'">
#macroActionEditor <macro-action-editor
*ngIf="editable && editing"
[macroAction]="macroAction" [macroAction]="macroAction"
(cancel)="cancelEdit()" (cancel)="cancelEdit()"
(save)="saveEditedAction($event)"></macro-action-editor> (save)="saveEditedAction($event)">
</macro-action-editor>
</div> </div>

View File

@@ -1,6 +1,9 @@
@import '../../../main-app/global-styles'; @import '../../../main-app/global-styles';
:host { :host {
overflow: hidden;
display: block;
&.macro-item:first-of-type { &.macro-item:first-of-type {
.list-group-item { .list-group-item {
border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;
@@ -70,10 +73,14 @@
} }
} }
.list-group-item {
margin-bottom: 0;
}
.macro-action-editor__container { .macro-action-editor__container {
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
border-radius: 0; border-radius: 0;
border-left: 0; border: none;
border-right: 0; overflow: hidden;
} }

View File

@@ -1,4 +1,17 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import {
Component,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
SimpleChanges,
animate,
state,
style,
transition,
trigger
} from '@angular/core';
import { KeyModifiers } from '../../../config-serializer/config-items/KeyModifiers'; import { KeyModifiers } from '../../../config-serializer/config-items/KeyModifiers';
import { import {
@@ -14,17 +27,27 @@ import {
import { MapperService } from '../../../services/mapper.service'; import { MapperService } from '../../../services/mapper.service';
@Component({ @Component({
animations: [
trigger('toggler', [
state('inactive', style({
height: '0px'
})),
state('active', style({
height: '*'
})),
transition('inactive <=> active', animate('500ms ease-out'))
])
],
selector: 'macro-item', selector: 'macro-item',
template: require('./macro-item.component.html'), template: require('./macro-item.component.html'),
styles: [require('./macro-item.component.scss')], styles: [require('./macro-item.component.scss')],
host: { 'class': 'macro-item' } host: { 'class': 'macro-item' }
}) })
export class MacroItemComponent implements OnInit, OnChanges { export class MacroItemComponent implements OnInit, OnChanges {
@Input() macroAction: MacroAction; @Input() macroAction: MacroAction;
@Input() editable: boolean; @Input() editable: boolean;
@Input() deletable: boolean; @Input() deletable: boolean;
@Input() moveable: boolean; @Input() movable: boolean;
@Output() save = new EventEmitter<MacroAction>(); @Output() save = new EventEmitter<MacroAction>();
@Output() cancel = new EventEmitter<void>(); @Output() cancel = new EventEmitter<void>();
@@ -34,6 +57,7 @@ export class MacroItemComponent implements OnInit, OnChanges {
private title: string; private title: string;
private iconName: string; private iconName: string;
private editing: boolean; private editing: boolean;
private newItem: boolean = false;
constructor(private mapper: MapperService) { } constructor(private mapper: MapperService) { }
@@ -41,6 +65,7 @@ export class MacroItemComponent implements OnInit, OnChanges {
this.updateView(); this.updateView();
if (!this.macroAction) { if (!this.macroAction) {
this.editing = true; this.editing = true;
this.newItem = true;
} }
} }

View File

@@ -7,7 +7,7 @@
[macroAction]="macroAction" [macroAction]="macroAction"
[editable]="true" [editable]="true"
[deletable]="true" [deletable]="true"
[moveable]="true" [movable]="true"
(save)="saveAction($event, macroActionIndex)" (save)="saveAction($event, macroActionIndex)"
(edit)="editAction(macroActionIndex)" (edit)="editAction(macroActionIndex)"
(cancel)="cancelAction()" (cancel)="cancelAction()"
@@ -15,15 +15,15 @@
[attr.data-index]="macroActionIndex" [attr.data-index]="macroActionIndex"
></macro-item> ></macro-item>
<macro-item *ngIf="showNew" [macroAction]="newMacro" <macro-item [@toggler]="showNew ? 'active' : 'inactive'" [macroAction]="newMacro"
[editable]="true" [editable]="true"
[deletable]="false" [deletable]="false"
[moveable]="false" [movable]="false"
(save)="addNewAction($event)" (save)="addNewAction($event)"
(cancel)="hideNewAction()" (cancel)="hideNewAction()"
></macro-item> ></macro-item>
</div> </div>
<div class="list-group add-new__action-container" *ngIf="!showNew"> <div class="list-group add-new__action-container" [@toggler]="(!showNew) ? 'active' : 'inactive'">
<div class="list-group-item action--item add-new__action-item no-reorder clearfix"> <div class="list-group-item action--item add-new__action-item no-reorder clearfix">
<a class="add-new__action-item--link" (click)="showNewAction()"> <a class="add-new__action-item--link" (click)="showNewAction()">
<i class="fa fa-plus"></i> Add new macro action <i class="fa fa-plus"></i> Add new macro action

View File

@@ -49,6 +49,10 @@ h1 {
} }
} }
.list-group {
overflow: auto;
}
.macro__name { .macro__name {
border-bottom: 2px dotted #999; border-bottom: 2px dotted #999;
padding: 0 0.5rem; padding: 0 0.5rem;
@@ -77,9 +81,8 @@ h1 {
} }
.macro-actions-container { .macro-actions-container {
overflow: auto;
margin-bottom: 0; margin-bottom: 0;
border-radius: 4px 4px 0 0; border-radius: 4px;
border: 1px solid #ddd; border: 1px solid #ddd;
border-bottom: 0; border-bottom: 0;
} }
@@ -98,7 +101,8 @@ h1 {
} }
.add-new__action-container { .add-new__action-container {
border-top: 1px solid #ddd; overflow: hidden;
flex-shrink: 0;
} }
.add-new__action-item { .add-new__action-item {

View File

@@ -1,4 +1,14 @@
import { Component, OnDestroy, QueryList, ViewChildren } from '@angular/core'; import {
Component,
OnDestroy,
QueryList,
ViewChildren,
animate,
state,
style,
transition,
trigger
} from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import '@ngrx/core/add/operator/select'; import '@ngrx/core/add/operator/select';
@@ -18,6 +28,17 @@ import { MacroActions } from '../../store/actions';
import { getMacro } from '../../store/reducers/macro'; import { getMacro } from '../../store/reducers/macro';
@Component({ @Component({
animations: [
trigger('toggler', [
state('inactive', style({
height: '0px'
})),
state('active', style({
height: '*'
})),
transition('inactive <=> active', animate('500ms ease-out'))
])
],
selector: 'macro', selector: 'macro',
template: require('./macro.component.html'), template: require('./macro.component.html'),
styles: [require('./macro.component.scss')], styles: [require('./macro.component.scss')],