-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated to Bootstrap Icons v.1.2.1 breaking changes - all icons now camelCase
- Loading branch information
Showing
1,218 changed files
with
7,354 additions
and
7,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 42 additions & 39 deletions
81
...otstrap-icons-lib/src/lib/components/ngx-bootstrap-icons/ngx-bootstrap-icons.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.