1.0.13 • Published 2 years ago

light-components v1.0.13

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

LightComponents

  1. Install library to your project npm install light-components
  2. Import to your module

import { LightComponentsModule } from 'light-components' add it to imports:

@NgModule({
  imports: [
    ...
    LightComponentsModule,
  ],
})
  1. And use in template:
<form-select label="Some label" [(value)]="<some variable>"></form-select>

Available props:

  • dense: boolean - small component
  • type: input type - input type
  • outline: boolean - add border
  • rules: Array - validation rules (for custom rules)
  • error: string - error message(for example, to display backend error)

Icon usage

<icon name=""></icon>

Name should be one of mdi icons

Alert usage:

  1. Add dependency injection
constructor(private alert: AlertService) {}
  1. add alert component to your template
<app-alert></app-alert>
  1. Usage:
alert.showSuccess(message?: string);
alert.showError(message?: string)
alert.showInfo(message?: string)
alert.showWarning(message?: string)

Form validation

  1. Include validated fields into <lib-form>...</lib-form> block and ad ref #form (or other name).
<lib-form #form>
  <form-input
    label="Name"
    dense
    outline
    [(value)]="model.name"
    [rules]="[max(20), min(3), required]"
  ></form-input>
  <file-uploader
    label="Avatar"
    dense
    outline
    [(value)]="model.avatar"
    [rules]="[required]"
  ></file-uploader>
  <form-select
    label="Country"
    dense
    outline
    [items]="items"
    [(value)]="model.country"
    [rules]="[required]"
  ></form-select>
  <button (click)="submit()">Submit</button>
</lib-form>
  • add viewChild for this component:
export class AppComponent {
    @ViewChild('form')
    form: any;
    ...
}
  • next validate form and do something:
 submit() {
    if (this.form.validate()) {
      // do something if valid form
    }
  }

In case if form is not valid, there was shown errors.

has multiple prop

usage

<form-select multiple></form-select>

<form-select></form-select> has returnObject prop. It allows for get full selected object instead of item value only

usage

<form-select returnObject></form-select>

What's news?

Compress icons size from 4.5MB to 350KB

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago