-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(composer): implement basic drag'n'drop in canvas component
Co-Authored-By: RyuuGan <[email protected]> re orchestratora/rfcs#2
- Loading branch information
Showing
17 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"author": "Orchestrator <[email protected]>", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@angular/cdk": "^7.0.0", | ||
"@angular/common": "^7.0.0", | ||
"@angular/core": "^7.0.0", | ||
"@orchestrator/core": "^0.0.0", | ||
|
2 changes: 1 addition & 1 deletion
2
libs/composer/src/lib/composer-canvas/composer-canvas.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p>composer-canvas works!</p> | ||
<orc-orchestrator [config]="initialConfig"></orc-orchestrator> |
11 changes: 6 additions & 5 deletions
11
libs/composer/src/lib/composer-canvas/composer-canvas.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { OrchestratorConfigItem } from '@orchestrator/core'; | ||
|
||
import { ComposerDroppableComponent } from '../composer-droppable'; | ||
|
||
@Component({ | ||
selector: 'orc-composer-canvas', | ||
templateUrl: './composer-canvas.component.html', | ||
styleUrls: ['./composer-canvas.component.css'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ComposerCanvasComponent implements OnInit { | ||
constructor() {} | ||
|
||
ngOnInit() {} | ||
export class ComposerCanvasComponent { | ||
initialConfig: OrchestratorConfigItem = ComposerDroppableComponent.getWrapperConfig(); | ||
} |
4 changes: 3 additions & 1 deletion
4
libs/composer/src/lib/composer-canvas/composer-canvas.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
libs/composer/src/lib/composer-components/composer-components.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
nz-list-item { | ||
background: white; | ||
} | ||
|
||
nz-list-item-meta::ng-deep .ant-list-item-meta-title { | ||
word-break: break-all; | ||
} |
9 changes: 7 additions & 2 deletions
9
libs/composer/src/lib/composer-components/composer-components.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
libs/composer/src/lib/composer-components/composer-components.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
libs/composer/src/lib/composer-droppable/composer-droppable-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
Option, | ||
OptionRequired, | ||
OrchestratorConfigItem, | ||
OrchestratorDynamicComponentType, | ||
} from '@orchestrator/core'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ComposerDroppableConfig<C = any> | ||
implements OrchestratorConfigItem<C> { | ||
@OptionRequired() | ||
component: string | OrchestratorDynamicComponentType<C>; | ||
|
||
@Option() | ||
config?: C; | ||
|
||
@Option() | ||
id?: string; | ||
|
||
@Option() | ||
classes?: string | string[] | { [name: string]: boolean }; | ||
|
||
@Option() | ||
attributes?: { [attr: string]: string }; | ||
|
||
@Option() | ||
handlers?: { [event: string]: string | Function }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.drop-list { | ||
padding: 10px; | ||
background: lightcyan; | ||
border: 1px dashed lightblue; | ||
text-align: center; | ||
} | ||
|
||
.drop-list.cdk-drop-list-dragging .drop-list-hint { | ||
display: none; | ||
} |
10 changes: 9 additions & 1 deletion
10
libs/composer/src/lib/composer-droppable/composer-droppable.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
<p>composer-droppable works!</p> | ||
<orc-orchestrator *ngIf="config.component" [config]="config"></orc-orchestrator> | ||
<div | ||
*ngIf="!config.component" | ||
class="drop-list" | ||
cdkDropList | ||
(cdkDropListDropped)="drop($event)" | ||
> | ||
<span class="drop-list-hint">Drop component here!</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
libs/composer/src/lib/composer-droppable/composer-droppable.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
nz-sider { | ||
height: 100vh; | ||
position: fixed; | ||
left: 0; | ||
} | ||
|
||
nz-content { | ||
margin: 24px 16px 0; | ||
overflow: initial; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'orc-composer', | ||
templateUrl: './composer.component.html', | ||
styleUrls: ['./composer.component.css'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ComposerComponent implements OnInit { | ||
constructor() {} | ||
|
||
ngOnInit() {} | ||
export class ComposerComponent { | ||
sideWidth = 250; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters