Skip to content

Commit 8deaea7

Browse files
committed
📝 docs: update readme for standalone components
1 parent 203ab62 commit 8deaea7

File tree

3 files changed

+26
-46
lines changed

3 files changed

+26
-46
lines changed

.github/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2023 hackingharold
3+
Copyright (c) 2024 hackingharold
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 hackingharold
3+
Copyright (c) 2024 hackingharold
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

readme.md

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ npm install @ngx-dropzone/cdk @ngx-dropzone/material
3838
## Versioning
3939

4040
For the versioning, we stay consistent with the major Angular releases.
41-
So Angular (components) 18 will be compatible with `@ngx-dropzone/cdk@18.x.x`.
41+
So Angular (components) 19 will be compatible with `@ngx-dropzone/cdk@19.x.x`.
4242

4343
Please note, that v16 is the first officially supported version.
4444
For older Angular releases, use the libs at your own risk.
@@ -48,22 +48,24 @@ For older Angular releases, use the libs at your own risk.
4848
This describes how to use the Material dropzone.
4949
If you want to extend the CDK with your own styling, see below.
5050

51-
```js
52-
// in app.module.ts
53-
import { MatFormFieldModule } from '@angular/material/form-field';
54-
import { DropzoneCdkModule } from '@ngx-dropzone/cdk';
55-
import { DropzoneMaterialModule } from '@ngx-dropzone/material';
51+
```ts
52+
// in app.component.ts
53+
import { MatFormField, MatLabel } from '@angular/material/form-field';
54+
import { MatIcon } from '@angular/material/icon';
55+
import { FileInputDirective } from '@ngx-dropzone/cdk';
56+
import { MatDropzone } from '@ngx-dropzone/material';
5657

57-
@NgModule({
58+
@Component({
5859
...
5960
imports: [
60-
MatFormFieldModule,
61-
DropzoneCdkModule,
62-
DropzoneMaterialModule,
61+
MatFormField,
62+
MatLabel,
63+
MatIcon,
64+
MatDropzone,
65+
FileInputDirective,
6366
],
6467
...
6568
})
66-
export class AppModule { }
6769
```
6870

6971
Now you can use it in your markup.
@@ -88,27 +90,19 @@ for `[(ngModel)]` and `[formControl]` directives, so you can seamlessly integrat
8890
file upload into your form.
8991

9092
First, make sure to import the `ReactiveFormsModule`.
93+
Then, you're able to define your form control element (incl. validation).
9194

92-
```js
93-
// in app.module.ts
95+
```ts
96+
// in app.component.ts
9497
import { ReactiveFormsModule } from '@angular/forms';
9598

96-
@NgModule({
97-
...
99+
@Component({
100+
selector: "form-control-dropzone",
98101
imports: [
99102
ReactiveFormsModule,
103+
MatError,
100104
...
101105
],
102-
...
103-
})
104-
export class AppModule { }
105-
```
106-
107-
Then, you're able to define your form control element (incl. validation).
108-
109-
```ts
110-
@Component({
111-
selector: "form-control-dropzone",
112106
template: `
113107
<mat-form-field>
114108
<ngx-mat-dropzone>
@@ -164,7 +158,7 @@ because people are way too opinionated about their styling and behaviour.
164158
</mat-form-field>
165159
```
166160

167-
```js
161+
```ts
168162
export class AppComponent {
169163
fileCtrl = new FormControl();
170164

@@ -212,32 +206,18 @@ However, you might want to apply your own custom styling (or library).
212206

213207
In this case, you're able to build upon the dropzone CDK. See the [Material dropzone](/projects/material/src/lib/mat-dropzone/mat-dropzone.component.ts) as an example.
214208

215-
The basic setup requires you to import the `DropzoneCdkModule` into your app.
216-
217-
```js
218-
// in app.module.ts
219-
import { DropzoneCdkModule } from '@ngx-dropzone/cdk';
220-
221-
@NgModule({
222-
...
223-
imports: [
224-
DropzoneCdkModule,
225-
],
226-
...
227-
})
228-
export class AppModule { }
229-
```
230-
231-
Next up, you extend the `DropzoneComponent` and apply your own styling and functionality.
209+
The basic setup requires you to extend the `DropzoneComponent` in your app to apply your own styling and functionality.
232210
Use the following skeleton as a starting point. You may always have a look at the
233211
Material reference implementation linked above.
234212

235213
```ts
236214
import { Component } from "@angular/core";
237-
import { DropzoneComponent } from "@ngx-dropzone/cdk";
215+
import { AcceptService, DropzoneComponent, DropzoneService, FileInputDirective } from "@ngx-dropzone/cdk";
238216

239217
@Component({
240218
selector: "my-dropzone",
219+
imports: [FileInputDirective, DropzoneComponent],
220+
providers: [DropzoneService, AcceptService],
241221
template: `
242222
<div class="my-dropzone">
243223
<ng-content select="[fileInput]"></ng-content>

0 commit comments

Comments
 (0)