Skip to content

Commit

Permalink
feat: added Button to switch layout
Browse files Browse the repository at this point in the history
  • Loading branch information
domiSchenk committed Oct 2, 2021
1 parent 926ebff commit 485ae2d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
</cds-form-group>

<div cds-layout="horizontal gap:sm align-items:bottom align:right m-t:xs m-r:sm">

<cds-icon-button *ngIf="viewMode === 'tree';else TreeView" (click)="changeToListView()"
size="sm" action="flat" cds-layout="m-l:xs m-r:auto" aria-label="change to listview"
[loadingState]="isLoading">
<cds-icon shape="view-list" size="14"></cds-icon>
</cds-icon-button>

<ng-template #TreeView>
<cds-icon-button (click)="changeToTreeView()" size="sm" action="flat"
cds-layout="m-l:xs m-r:auto" aria-label="change to treeview" [loadingState]="isLoading">
<cds-icon shape="tree-view" size="14"></cds-icon>
</cds-icon-button>
</ng-template>

<cds-button action="flat" status="success" [loadingState]="isCommiting" size="sm"
(click)="commit()" [disabled]="formDisabled">
Commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { interval } from 'rxjs';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { basename, sleep, LoadingState, LocalStorage } from '@shared/functions';

type ViewMode = 'tree' | 'list';

@UntilDestroy()
@Component({
selector: 'app-repository-commit',
Expand All @@ -22,6 +24,8 @@ export class RepositoryCommitComponent implements OnInit {

fileTree: GroupedChangedFiles = [];
formDisabled = false;
viewMode: ViewMode = 'tree';


get commitMessage(): string {
return localStorage.getItem(`commitMessage-${this.repositoryService.currentId}`);
Expand Down Expand Up @@ -244,6 +248,13 @@ export class RepositoryCommitComponent implements OnInit {
this.isDiffLoading = false;
}

changeToListView() {
this.viewMode = 'list';
}

changeToTreeView() {
this.viewMode = 'tree';
}

hideChild(node: any) {
node.hideChildren = !node.hideChildren;
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/clarity-icons.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
minusIcon, moonIcon, noteIcon, pencilIcon, playIcon,
plusIcon, shrinkIcon, sunIcon, timesIcon, trashIcon, undoIcon,
unknownStatusIcon, uploadCloudIcon, wandIcon, windowCloseIcon, windowMaxIcon, windowMinIcon,
windowRestoreIcon, twoWayArrowsIcon, userIcon, refreshIcon, happyFaceIcon, arrowIcon, syncIcon, pinIcon, barsIcon, viewCardsIcon, viewListIcon
windowRestoreIcon, twoWayArrowsIcon, userIcon, refreshIcon, happyFaceIcon, arrowIcon, syncIcon, pinIcon, barsIcon, viewCardsIcon, viewListIcon, treeViewIcon
} from '@cds/core/icon';

import '@cds/core/icon/register.js';
Expand All @@ -20,7 +20,7 @@ const icons = [
fileIcon, sunIcon, moonIcon, homeIcon, historyIcon,
trashIcon, downloadIcon, twoWayArrowsIcon, userIcon,
refreshIcon, happyFaceIcon, arrowIcon, syncIcon, pinIcon,
barsIcon, viewCardsIcon, viewListIcon
barsIcon, viewCardsIcon, viewListIcon, treeViewIcon
]

ClarityIcons.addIcons(...icons);
Expand Down
1 change: 1 addition & 0 deletions src/theme/import.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import './animations';
@import './typo';
@import './button';
@import './layout';
7 changes: 7 additions & 0 deletions src/theme/layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[cds-layout~="m-r:auto"] {
margin-right: auto !important;
}

[cds-layout~="m-l:auto"] {
margin-left: auto !important;
}

0 comments on commit 485ae2d

Please sign in to comment.