@rhtml/decorators 0.0.111 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -12,16 +12,13 @@ npm i @rhtml/decorators
12
12
  import { Attribute, Options, Input } from '@rhtml/custom-attributes';
13
13
  import { HostListener } from '@rhtml/decorators';
14
14
 
15
+ @Modifier({
16
+ selector: 'test'
17
+ })
15
18
  export class TestDirective extends Attribute {
16
19
  @Input()
17
20
  myProperty: string;
18
21
 
19
- public static options(this: HTMLElement): Options {
20
- return {
21
- name: 'test'
22
- };
23
- }
24
-
25
22
  @HostListener('mouseenter')
26
23
  enter(event: Event) {
27
24
  console.log('ENTER', this, event);
@@ -70,3 +67,31 @@ export class HomeComponent extends LitElement {
70
67
  }
71
68
  }
72
69
  ```
70
+
71
+ #### @HostBinding and @Input decorators
72
+
73
+ Specifiyng Input and HostBinding decorator gives you an reactive ability to assign styles directly to input properties
74
+ This way by editing `padding`, `color` or `background` will reflect to the style associated with
75
+ By doing this we can skip `OnInit`, `OnDestroy`, `OnUpdate` manual assign inside hooks
76
+
77
+ ```typescript
78
+ import { Attribute, Input, Modifier } from '@rhtml/custom-attributes';
79
+ import { HostBinding } from '@rhtml/decorators';
80
+
81
+ @Modifier({
82
+ selector: 'layout'
83
+ })
84
+ export class CustomLayout extends Attribute {
85
+ @Input({ observe: true })
86
+ @HostBinding('style.padding')
87
+ padding: string;
88
+
89
+ @Input({ observe: true })
90
+ @HostBinding('style.color')
91
+ color: string;
92
+
93
+ @Input({ observe: true })
94
+ @HostBinding('style.background')
95
+ background: string;
96
+ }
97
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhtml/decorators",
3
- "version": "0.0.111",
3
+ "version": "0.0.114",
4
4
  "description": "Reactive HyperText Markup Language",
5
5
  "scripts": {
6
6
  "start": "npx parcel ./examples/index.html --out-dir build/examples",