Skip to content

Commit 94351dd

Browse files
committed
refactor(sample): use component in the samples
1 parent 0a0dc33 commit 94351dd

7 files changed

Lines changed: 57 additions & 13 deletions

File tree

projects/ng-sortgrid-demo/src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {GettingStartedMemoryComponent} from './examples/getting-started/getting-
99
import {StepComponent} from './examples/step/step.component';
1010
import {ReactOnChangesMemoryComponent} from './examples/react-on-changes/react-on-changes-memory.component';
1111
import {GroupsMemoryComponent} from './examples/groups/groups-memory.component';
12+
import {CardComponent} from './examples/card/card.component';
1213

1314
@NgModule({
1415
declarations: [
@@ -18,7 +19,8 @@ import {GroupsMemoryComponent} from './examples/groups/groups-memory.component';
1819
GettingStartedMemoryComponent,
1920
StepComponent,
2021
ReactOnChangesMemoryComponent,
21-
GroupsMemoryComponent
22+
GroupsMemoryComponent,
23+
CardComponent
2224
],
2325
imports: [BrowserModule, NgsgModule],
2426
providers: [],
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.card {
2+
width: 200px;
3+
height: 200px;
4+
border: solid 1px #ccc;
5+
font-size: 30pt;
6+
font-weight: bold;
7+
color: rgba(0, 0, 0, 0.87);
8+
cursor: move;
9+
display: flex;
10+
justify-content: center;
11+
align-items: center;
12+
text-align: center;
13+
background: #fff;
14+
border-radius: 4px;
15+
position: relative;
16+
z-index: 1;
17+
transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
18+
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
19+
0 2px 2px 0 rgba(0, 0, 0, 0.14),
20+
0 1px 5px 0 rgba(0, 0, 0, 0.12);
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div>
2+
<h1 style="color: darkslategray">
3+
{{ item }}
4+
</h1>
5+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component, Input} from '@angular/core';
2+
3+
@Component({
4+
selector: 'ngsg-card',
5+
templateUrl: './card.component.html',
6+
styleUrls: ['./card.component.css']
7+
})
8+
export class CardComponent {
9+
10+
@Input() item: number;
11+
}
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
<h5 style="margin-bottom: 20px">3. Drag the items around - hold CMD or Control and click on an item to select multiple files</h5>
1+
<h5 style="margin-bottom: 20px">3. Drag the items around - hold CMD or Control and click on an item to select multiple
2+
files</h5>
23
<div class="example-container">
3-
<div *ngFor="let item of items" ngSortgridItem [ngSortGridItems]="items" class="example-box">
4-
{{ item }}
5-
</div>
4+
<ngsg-card *ngFor="let item of items"
5+
ngSortgridItem
6+
[ngSortGridItems]="items"
7+
[item]="item"
8+
class="example-box">
9+
</ngsg-card>
610
</div>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
<div class="row">
22
<div class="col">
33
<div class="example-container">
4-
<div *ngFor="let item of items"
4+
<ngsg-card *ngFor="let item of items"
55
ngSortgridItem
66
ngSortGridGroup="one"
7+
[item]="item"
78
[ngSortGridItems]="items"
8-
(sorted)="applyOrder($event)"
99
class="example-box">
1010
{{ item }}
11-
</div>
11+
</ngsg-card>
1212
</div>
1313
</div>
1414
<div class="col">
1515
<div class="example-container">
16-
<div *ngFor="let item of items"
16+
<ngsg-card *ngFor="let item of items"
1717
ngSortgridItem
1818
ngSortGridGroup="two"
19+
[item]="item"
1920
[ngSortGridItems]="items"
20-
(sorted)="applyOrder($event)"
2121
class="example-box">
2222
{{ item }}
23-
</div>
23+
</ngsg-card>
2424
</div>
2525
</div>
2626
</div>

projects/ng-sortgrid-demo/src/app/examples/react-on-changes/react-on-changes-memory.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ <h2 class="card-text">{{ sortOrder }}</h2>
55
</div>
66
</div>
77
<div class="example-container">
8-
<div *ngFor="let item of items"
8+
<ngsg-card *ngFor="let item of items"
99
ngSortgridItem
10+
[item]="item"
1011
[ngSortGridItems]="items"
1112
(sorted)="applyOrder($event)"
1213
class="example-box">
1314
{{ item }}
14-
</div>
15+
</ngsg-card>
1516
</div>

0 commit comments

Comments
 (0)