0.0.134 • Published 8 months ago
@rhtml/decorators v0.0.134
@rhtml/decorators
Installation
npm i @rhtml/decoratorsUsage
import { Attribute, Options, Input } from '@rhtml/custom-attributes';
import { HostListener } from '@rhtml/decorators';
@Modifier({
selector: 'test'
})
export class TestDirective extends Attribute {
@Input()
myProperty: string;
@HostListener('mouseenter')
enter(event: Event) {
console.log('ENTER', this, event);
console.log(this.myProperty);
}
@HostListener('mouseleave')
leave(event: Event) {
console.log('LEAVE', this, event);
console.log(this.myProperty);
}
}<div test myProperty="12312">
111
</div>Usage inside @rxdi/lit-html
import { Component, html, LitElement } from '@rxdi/lit-html';
import { HostListener } from '@rhtml/decorators';
/**
* @customElement home-component
*/
@Component({
selector: 'home-component',
template(this) {
return html`
Home Component
`;
}
})
export class HomeComponent extends LitElement {
@HostListener('mouseenter') onEnter() {
console.log('Enter home');
}
@HostListener('mouseleave') onLeave() {
console.log('Leave home');
}
}@HostBinding and @Input decorators
Specifiyng Input and HostBinding decorator gives you an reactive ability to assign styles directly to input properties
This way by editing padding, color or background will reflect to the style associated with
By doing this we can skip OnInit, OnDestroy, OnUpdate manual assign inside hooks
import { Attribute, Input, Modifier } from '@rhtml/custom-attributes';
import { HostBinding } from '@rhtml/decorators';
@Modifier({
selector: 'layout'
})
export class CustomLayout extends Attribute {
@Input({ observe: true })
@HostBinding('style.padding')
padding: string;
@Input({ observe: true })
@HostBinding('style.color')
color: string;
@Input({ observe: true })
@HostBinding('style.background')
background: string;
}0.0.134
8 months ago
0.0.133
1 year ago
0.0.131
2 years ago
0.0.132
2 years ago
0.0.130
2 years ago
0.0.129
2 years ago
0.0.128
2 years ago
0.0.127
2 years ago
0.0.126
2 years ago
0.0.125
2 years ago
0.0.120
3 years ago
0.0.124
3 years ago
0.0.123
3 years ago
0.0.122
3 years ago
0.0.121
3 years ago
0.0.119
3 years ago
0.0.118
3 years ago
0.0.117
3 years ago
0.0.116
4 years ago
0.0.115
4 years ago
0.0.114
4 years ago
0.0.113
4 years ago
0.0.112
4 years ago
0.0.111
4 years ago
0.0.110
4 years ago
0.0.109
4 years ago
0.0.108
4 years ago
0.0.107
4 years ago
0.0.106
4 years ago
0.0.105
4 years ago
0.0.104
4 years ago
0.0.103
4 years ago
0.0.102
4 years ago
0.0.101
4 years ago