Skip to content

Instantly share code, notes, and snippets.

@davidecampello
Created February 25, 2021 14:50
Show Gist options
  • Select an option

  • Save davidecampello/c3ac37c20e402d1843b69e7b3566adbf to your computer and use it in GitHub Desktop.

Select an option

Save davidecampello/c3ac37c20e402d1843b69e7b3566adbf to your computer and use it in GitHub Desktop.
ionic-icon-extractor and directive
export async function http<T>(request: RequestInfo): Promise<T> {
const response = await fetch(request);
const body = await response.json();
return body;
}
async function get() {
console.log("get");
const icons = await http<{
icons: {
name: string;
}[];
}>(
"https://raw.githubusercontent.com/ionic-team/ionicons/master/src/data.json"
);
console.log(icons);
const set = new Set<string>();
icons.icons.forEach(i => {
set.add(i.name.replace("-outline", "").replace("-sharp", ""));
});
console.log([...Array.from(set)].map(s => `'${s}'`).join(" | \n"));
}
get();
/*
export type IonIconName =
'accessibility' |
'add' |
......
;
@Directive({
selector: '[iconAdaptive]'
})
export class IonIconAdaptiveDirective implements OnInit {
private iconName: IonIconName;
@Input() set iconAdaptive(name: IonIconName) {
this.iconName = name;
this.setIcon();
}
constructor(@Host() private baseComponent: IonIcon) {
}
ngOnInit(): void {
this.setIcon();
}
private setIcon() {
this.baseComponent.ios = `${this.iconName}-outline`;
this.baseComponent.md = `${this.iconName}-sharp`;
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment