Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
feat: empty space click
Browse files Browse the repository at this point in the history
  • Loading branch information
artemnih committed Oct 6, 2021
1 parent a7f599c commit 5740535
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Directive, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { XNode } from './types';
import { ExplorerService } from '../services/explorer.service';
import { HelperService } from '../services/helper.service';
import { XNode } from '../../common/types';
import { ExplorerService } from '../../services/explorer.service';
import { HelperService } from '../../services/helper.service';

@Directive()
export class BaseView implements OnDestroy {
Expand Down Expand Up @@ -51,6 +51,10 @@ export class BaseView implements OnDestroy {
return this.selection.indexOf(item) !== -1;
}

emptySpaceClick(): void {
this.explorerService.selectNodes([]);
}

ngOnDestroy() {
this.subs.unsubscribe();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ interface Breadcrumb {
})
export class BreadcrumbsComponent implements OnDestroy {
public breadcrumbs: Breadcrumb[] = [];

private sub = new Subscription();

constructor(private explorerService: ExplorerService, private helperService: HelperService) {
this.sub.add(this.explorerService.breadcrumbs.subscribe(n => this.buildBreadcrumbs(n)));
}

private buildBreadcrumbs(nodes: XNode[]) {

// TODO: configurable home node name
this.breadcrumbs = nodes.map(n => ({ name: this.helperService.getName(n.data) || 'Files', node: n }));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<div class="nxe-icons-container">
<div class="nxe-icons-wrapper" *ngFor="let item of items" (dblclick)="open($event, item)" (click)="select($event, item)">
<div class="nxe-icons-wrapper-inner" [ngClass]="{'nxe-icon-selected':isSelected(item)}">
<div class="nxe-icon">
<i [className]="icons[item.type]"></i>
<div class="nxe-icons">
<div class="nxe-icons-backpad" (click)="emptySpaceClick()"></div>
<div class="nxe-icons-container">
<div class="nxe-icons-wrapper" *ngFor="let item of items" (dblclick)="open($event, item)" (click)="select($event, item)">
<div class="nxe-icons-wrapper-inner" [ngClass]="{'nxe-icon-selected':isSelected(item)}">
<div class="nxe-icon">
<i [className]="icons[item.type]"></i>
</div>
<div class="nxe-icon-text">{{ getDisplayName(item.data) }}</div>
</div>
<div class="nxe-icon-text">{{ getDisplayName(item.data) }}</div>
</div>
</div>
</div>
103 changes: 59 additions & 44 deletions projects/ngx-explorer/src/lib/components/icons/icons.component.scss
Original file line number Diff line number Diff line change
@@ -1,64 +1,79 @@
// TODO: var colors

.nxe-icons-container {
display: flex;
flex-wrap: wrap;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
.nxe-icons {
width: 100%;
height: 100%;
position: relative;

.nxe-icons-wrapper {
margin: 10px 10px 0px 10px;
height: 110px;
width: 80px;
display: inline-block;
flex-grow: 0;

.nxe-icons-wrapper-inner {
border: 1px solid transparent;
padding-bottom: 5px;
text-align: center;
border-radius: 5px;
.nxe-icons-backpad {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

&:hover {
cursor: pointer;
}
.nxe-icons-container {
display: flex;
flex-wrap: wrap;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */

.nxe-icon {
margin-top: 5px;
.nxe-icons-wrapper {
margin: 10px 10px 0px 10px;
height: 110px;
width: 80px;
display: inline-block;
flex-grow: 0;
z-index: 1;

i {
font-size: 50px;
color: #999;
font-weight: 500;
.nxe-icons-wrapper-inner {
border: 1px solid transparent;
padding-bottom: 5px;
text-align: center;
border-radius: 5px;

&.fa {
-webkit-text-stroke: 2px white;
}
&:hover {
cursor: pointer;
}
}

&.nxe-icon-selected {
background-color: #f1f9ff;
border: 1px solid #94cfff;

.nxe-icon {
margin-top: 5px;

i {
font-size: 50px;
color: #999;
font-weight: 500;

&.fa {
-webkit-text-stroke: 2px #f1f9ff;
-webkit-text-stroke: 2px white;
}
}
}

&.nxe-icon-selected {
background-color: #f1f9ff;
border: 1px solid #94cfff;

.nxe-icon {
i {
&.fa {
-webkit-text-stroke: 2px #f1f9ff;
}
}
}
}
}
}

.nxe-icon-text {
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
.nxe-icon-text {
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { BaseView } from '../../common/base-view';
import { NodeType } from '../../common/types';
import { ExplorerService } from '../../services/explorer.service';
import { HelperService } from '../../services/helper.service';
import { BaseView } from '../base-view/base-view.directive';

@Component({
selector: 'nxe-icons',
Expand All @@ -20,5 +20,6 @@ export class IconsComponent extends BaseView {
constructor(explorerService: ExplorerService, helperService: HelperService) {
super(explorerService, helperService);
}

}

2 changes: 1 addition & 1 deletion projects/ngx-explorer/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from './lib/components/icons/icons.component';
export * from './lib/components/explorer/explorer.component';
export * from './lib/components/menu-bar/menu-bar.component';
export * from './lib/components/breadcrumbs/breadcrumbs.component';
export * from './lib/common/base-view';
export * from './lib/components/base-view/base-view.directive';

0 comments on commit 5740535

Please sign in to comment.