Skip to content

Commit

Permalink
fixed some linter errors (#124)
Browse files Browse the repository at this point in the history
updated to Bootstrap Icons v.1.2.1
breaking changes - all icons now camelCase
  • Loading branch information
avmaisak authored Dec 13, 2020
1 parent 60f208a commit 6d1913c
Show file tree
Hide file tree
Showing 1,218 changed files with 7,354 additions and 7,333 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
npm i ngx-bootstrap-icons --save
```

![Bootstrap Icons full set](https://user-images.githubusercontent.com/98681/85891337-be640680-b7a3-11ea-84a0-0a103fce118c.png)
![Bootstrap Icons full set](https://github.com/twbs/icons/raw/main/.github/preview.png)


### Demo
Expand Down Expand Up @@ -48,12 +48,12 @@ import { allIcons } from 'ngx-bootstrap-icons';

_3.2 Import some icons_
```ts
import { Alarm, AlarmFill, AlignBottom } from 'ngx-bootstrap-icons';
import { alarm, alarmFill, alignBottom } from 'ngx-bootstrap-icons';
// Select some icons (use an object, not an array)
const icons = {
Alarm,
AlarmFill,
AlignBottom
alarm,
alarmFill,
alignBottom
};
```

Expand Down Expand Up @@ -81,13 +81,13 @@ _4.1. Import Module (some icons)_

```ts
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons';
import { Alarm, AlarmFill, AlignBottom } from 'ngx-bootstrap-icons';
import { alarm, alarmFill, alignBottom } from 'ngx-bootstrap-icons';

// Select some icons (use an object, not an array)
const icons = {
Alarm,
AlarmFill,
AlignBottom
alarm,
alarmFill,
alignBottom
};

@NgModule({
Expand Down Expand Up @@ -127,11 +127,11 @@ _5. Use it in template_
or
_Optionally use our enums for autocomplete support_
```ts
import { IconNamesEnum } from 'ngx-bootstrap-icons';
import { iconNamesEnum } from 'ngx-bootstrap-icons';

public IconNames = IconNamesEnum;
public iconNames = iconNamesEnum;

<i-bs [name]="IconNames.AlarmFill"></i-bs>
<i-bs [name]="iconNames.AlarmFill"></i-bs>
```

Also you can use width and height for icon (By default width and height are 1rem)
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@
## v.1.2.4 (12.12.2020)

* [icons] - fixed #121 (updated Bootstrap Icons to v1.2.0 )

## v.1.3.0 (13.12.2020)

* [icons] - updated Bootstrap Icons to v1.2.1
* [icons] - fixed some linter errors
* [icons] - breaking changes - all icons now camelCase
65 changes: 35 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap-icons-demo",
"version": "1.2.4",
"version": "1.3.0",
"homepage": "https://avmaisak.github.io/ngx-bootstrap-icons/",
"scripts": {
"ng": "./node_modules/@angular/cli/bin/ng",
Expand Down Expand Up @@ -30,7 +30,7 @@
"angular-cli-ghpages": "^0.6.2",
"bootstrap": "^4.5.3",
"lodash": "^4.17.20",
"ngx-bootstrap-icons": "1.2.4",
"ngx-bootstrap-icons": "1.3.0",
"ngx-clipboard": "^14.0.1",
"rxjs": "6.6.3",
"tslib": "2.0.3",
Expand All @@ -44,23 +44,24 @@
"@angular-eslint/eslint-plugin-template": "0.8.0-beta.5",
"@angular-eslint/schematics": "^0.8.0-beta.5",
"@angular-eslint/template-parser": "0.8.0-beta.5",
"eslint-plugin-simple-import-sort": "^7.0.0",
"@angular/cli": "11.0.4",
"@angular/compiler-cli": "11.0.4",
"@angular/language-service": "11.0.4",
"@types/jasmine": "3.6.2",
"@types/jasminewd2": "2.0.8",
"@types/node": "14.14.12",
"@types/node": "14.14.13",
"@typescript-eslint/eslint-plugin": "4.9.1",
"@typescript-eslint/parser": "4.9.1",
"bootstrap-icons": "1.2.0",
"bootstrap-icons": "1.2.1",
"camelcase": "^6.2.0",
"cli-color": "^2.0.0",
"codelyzer": "6.0.1",
"eslint": "^7.15.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jasmine": "^4.1.1",
"eslint-plugin-jsdoc": "^30.7.8",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jasmine-core": "3.6.0",
"jasmine-spec-reporter": "6.0.0",
"karma": "5.2.3",
Expand All @@ -73,7 +74,6 @@
"ts-node": "9.1.1",
"tsickle": "0.39.1",
"tslint": "6.1.3",
"typescript": "4.0.5",
"uppercamelcase": "3.0.0"
"typescript": "4.0.5"
}
}
2 changes: 1 addition & 1 deletion projects/ngx-bootstrap-icons-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-bootstrap-icons",
"version": "1.2.4",
"version": "1.3.0",
"description": "Bootstrap Icons components library for your Angular Applications",
"homepage": "https://avmaisak.github.io/ngx-bootstrap-icons/",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
import {
ChangeDetectorRef, Component, ElementRef, Inject, Input, OnChanges, SimpleChanges,
ChangeDetectorRef, Component, ElementRef, Inject, Input, OnChanges, SimpleChanges,
} from '@angular/core';
import { IconNamesEnum } from '../../enums/icon-names.enum';

import { iconNamesEnum } from '../../enums/icon-names.enum';
import { Icons } from '../../providers/icon.provider';
import { uppercamelcase } from '../../utils/utils';

/**
* Bootstrap icon component.
*/
@Component({
// tslint:disable-next-line: component-selector
selector: 'i-bs',
template: '<ng-content></ng-content>',
// tslint:disable-next-line: component-selector
selector: 'i-bs',
template: '<ng-content></ng-content>',
})
export class NgxBootstrapIconsLibComponent implements OnChanges {
/** Icon name. */
@Input() name!: string | IconNamesEnum;

/** Icon width. */
@Input() width!: string;

/** Icon height. */
@Input() height!: string;

constructor(
private elem: ElementRef,
private changeDetector: ChangeDetectorRef,
@Inject(Icons)
private icons: Icons,
) { }

/**
* OnChanges event.
*
* @param changes
*/
ngOnChanges(changes: SimpleChanges) {
// icons are provided as an array of objects because of "multi: true"
const icons = Object.assign({}, ...(this.icons as any as object[]));
let svg = icons[uppercamelcase(changes.name.currentValue)] || '';

if (!svg) console.warn(`Icon not found: ${changes.name.currentValue}\n`);
if (this.width && svg.includes('width')) svg = svg.replace('width="16"', `width="${this.width}"`);
if (this.height && svg.includes('height')) svg = svg.replace('height="16"', `height="${this.height}"`);

this.elem.nativeElement.innerHTML = svg;
this.changeDetector.markForCheck();
}
/** Icon name. */
@Input() public name!: string | iconNamesEnum;

/** Icon width. */
@Input() public width!: string;

/** Icon height. */
@Input() public height!: string;

constructor(
private _elem: ElementRef,
private _changeDetector: ChangeDetectorRef,
@Inject(Icons)
private _icons: Icons,
) { }

/**
* OnChanges event.
*
* @param changes
*/
public ngOnChanges(changes: SimpleChanges): void {
// eslint-disable-next-line global-require
const camelcase = require('camelcase');
// icons are provided as an array of objects because of "multi: true"
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const icons = Object.assign({}, ...(this._icons as any as object[]));
let svg = icons[camelcase(changes.name.currentValue)] || '';

if (!svg) console.warn(`Icon not found: ${changes.name.currentValue}\n`);
if (this.width && svg.includes('width')) svg = svg.replace('width="16"', `width="${this.width}"`);
if (this.height && svg.includes('height')) svg = svg.replace('height="16"', `height="${this.height}"`);

this._elem.nativeElement.innerHTML = svg;
this._changeDetector.markForCheck();
}
}
Loading

0 comments on commit 6d1913c

Please sign in to comment.