-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from Alessy/drag-handle
feat: (draghandle) drag handle implementation
- Loading branch information
Showing
11 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...ects/ng-sortgrid-demo/src/app/introduction/examples/drag-handle/drag-handle.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.example-box { | ||
width: 200px; | ||
height: 200px; | ||
padding: 10px; | ||
box-sizing: border-box; | ||
border: solid 1px #ccc; | ||
color: rgba(0, 0, 0, 0.87); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
background: #fff; | ||
border-radius: 4px; | ||
position: relative; | ||
z-index: 1; | ||
transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1); | ||
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), | ||
0 2px 2px 0 rgba(0, 0, 0, 0.14), | ||
0 1px 5px 0 rgba(0, 0, 0, 0.12); | ||
} | ||
|
||
.example-handle { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
color: #ccc; | ||
cursor: move; | ||
width: 24px; | ||
height: 24px; | ||
} |
19 changes: 19 additions & 0 deletions
19
...cts/ng-sortgrid-demo/src/app/introduction/examples/drag-handle/drag-handle.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h5 style="margin-bottom: 20px">1. Drag the items around using handle</h5> | ||
|
||
<div class="example-container"> | ||
<div *ngFor="let item of items" | ||
ngSortgridItem | ||
[ngSortGridItems]="items" | ||
class="example-box"> | ||
|
||
<h1 style="color: darkslategray"> | ||
{{ item }} | ||
</h1> | ||
|
||
<div class="example-handle" ngSortgridDragHandle> | ||
<svg width="24px" fill="currentColor" viewBox="0 0 24 24"> | ||
<path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"></path> | ||
<path d="M0 0h24v24H0z" fill="none"></path> | ||
</svg> | ||
</div> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
projects/ng-sortgrid-demo/src/app/introduction/examples/drag-handle/drag-handle.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ngsg-demo-drag-handle', | ||
templateUrl: 'drag-handle.component.html', | ||
styleUrls: ['./drag-handle.component.css'] | ||
}) | ||
export class DragHandleComponent { | ||
|
||
public items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | ||
} | ||
|
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
projects/ng-sortgrid/src/lib/ngsg-drag-handle.directive.spec.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,17 @@ | ||
import { NgsgDragHandleDirective } from './ngsg-drag-handle.directive'; | ||
|
||
describe('NgsgDragHandleDirective', () => { | ||
let sut: NgsgDragHandleDirective; | ||
|
||
const elementRef = { nativeElement: {} } as any; | ||
|
||
beforeEach(() => { | ||
sut = new NgsgDragHandleDirective( | ||
elementRef | ||
); | ||
}); | ||
|
||
it('should create an instance', () => { | ||
expect(sut).toBeTruthy(); | ||
}); | ||
}); |
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,9 @@ | ||
import { Directive, ElementRef } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[ngSortgridDragHandle]' | ||
}) | ||
export class NgsgDragHandleDirective { | ||
|
||
constructor(public el: ElementRef){} | ||
} |
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
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,9 +1,10 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { NgsgItemDirective } from './ngsg-item.directive'; | ||
import { NgsgDragHandleDirective } from './ngsg-drag-handle.directive'; | ||
|
||
@NgModule({ | ||
declarations: [NgsgItemDirective], | ||
exports: [NgsgItemDirective] | ||
declarations: [NgsgItemDirective, NgsgDragHandleDirective], | ||
exports: [NgsgItemDirective, NgsgDragHandleDirective] | ||
}) | ||
export class NgsgModule {} |