Skip to content

Commit

Permalink
feat(lib): add aliasing support
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Feb 23, 2023
1 parent cea7115 commit 68da136
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 103 deletions.
41 changes: 16 additions & 25 deletions bin/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,16 @@ const path = require("path");
const axios = require("axios");
const chalk = require("chalk");
const { Command } = require("commander");

const { version } = require("../package.json");
const { CATEGORY_MAP, ALIASES } = require(".");

const ICON_API_URL = "https://api.phosphoricons.com";

const [MAJOR_PART, MINOR_PART] = version.split(".");
const CURRENT_NUMERIC_VERSION = +MAJOR_PART + +MINOR_PART / 10;

const CATEGORY_MAP = {
Arrows: "ARROWS",
Brands: "BRAND",
Commerce: "COMMERCE",
Communication: "COMMUNICATION ",
Design: "DESIGN",
Development: "DEVELOPMENT",
Education: "EDUCATION",
Games: "GAMES",
"Health & Wellness": "HEALTH",
"Maps & Travel": "MAP",
"Math & Finance": "FINANCE",
Media: "MEDIA",
"Office & Editing": "OFFICE",
People: "PEOPLE",
"Security & Warnings": "SECURITY",
"System & Devices": "SYSTEM",
Time: "TIME",
"Weather & Nature": "WEATHER",
};
main().catch(console.error);

async function main() {
const program = new Command();
Expand Down Expand Up @@ -82,10 +65,13 @@ export const icons: ReadonlyArray<IconEntry> = [
fileString += `\
{
name: "${icon.name}",
pascal_name: "${icon.name
.split("-")
.map((substr) => substr.replace(/^\w/, (c) => c.toUpperCase()))
.join("")}",
pascal_name: "${pascalize(icon.name)}",${
!!ALIASES[icon.name]
? `alias: { name: "${
ALIASES[icon.name]
}", pascal_name: "${pascalize(ALIASES[icon.name])}" },`
: ""
}
categories: ${categories},
figma_category: FigmaCategory.${figma_category},
tags: ${JSON.stringify([
Expand Down Expand Up @@ -124,4 +110,9 @@ export const icons: ReadonlyArray<IconEntry> = [
}
}

main();
function pascalize(str) {
return str
.split("-")
.map((substr) => substr.replace(/^\w/, (c) => c.toUpperCase()))
.join("");
}
36 changes: 36 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";

const CATEGORY_MAP = {
Arrows: "ARROWS",
Brands: "BRAND",
Commerce: "COMMERCE",
Communication: "COMMUNICATION ",
Design: "DESIGN",
Development: "DEVELOPMENT",
Education: "EDUCATION",
Games: "GAMES",
"Health & Wellness": "HEALTH",
"Maps & Travel": "MAP",
"Math & Finance": "FINANCE",
Media: "MEDIA",
"Office & Editing": "OFFICE",
People: "PEOPLE",
"Security & Warnings": "SECURITY",
"System & Devices": "SYSTEM",
Time: "TIME",
"Weather & Nature": "WEATHER",
};

const ALIASES = {
"file-dashed": "file-dotted",
"folder-dashed": "folder-dotted",
"folder-simple-dashed": "folder-simple-dotted",
pulse: "activity",
seal: "circle-wavy",
"seal-check": "circle-wavy-check",
"seal-question": "circle-wavy-question",
"seal-warning": "circle-wavy-warning",
"text-b": "text-bolder",
};

module.exports = { CATEGORY_MAP, ALIASES };
196 changes: 118 additions & 78 deletions src/icons.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
import { IconEntry, IconCategory, FigmaCategory } from "./types";

export const icons: ReadonlyArray<IconEntry> = [
{
name: "activity",
pascal_name: "Activity",
categories: [IconCategory.HEALTH],
figma_category: FigmaCategory.HEALTH,
tags: [
"heartbeat",
"medical",
"ecg",
"ekg",
"vitals",
"monitor",
"medicine",
"pulse",
],
published_in: 1.0,
updated_in: 1.0,
},
{
name: "address-book",
pascal_name: "AddressBook",
Expand Down Expand Up @@ -3612,50 +3594,6 @@ export const icons: ReadonlyArray<IconEntry> = [
published_in: 1.4,
updated_in: 1.4,
},
{
name: "circle-wavy",
pascal_name: "CircleWavy",
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: ["badge", "verified", "verification", "shapes", "polygons", "seal"],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "circle-wavy-check",
pascal_name: "CircleWavyCheck",
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: ["badge", "verified", "verification", "shapes", "polygons", "seal"],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "circle-wavy-question",
pascal_name: "CircleWavyQuestion",
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: ["badge", "unverified", "verification", "shapes", "polygons", "seal"],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "circle-wavy-warning",
pascal_name: "CircleWavyWarning",
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: [
"badge",
"unverified",
"verification",
"errors",
"shapes",
"polygons",
"seal",
],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "circles-four",
pascal_name: "CirclesFour",
Expand Down Expand Up @@ -5399,6 +5337,16 @@ export const icons: ReadonlyArray<IconEntry> = [
published_in: 1.4,
updated_in: 1.4,
},
{
name: "file-dashed",
pascal_name: "FileDashed",
alias: { name: "file-dotted", pascal_name: "FileDotted" },
categories: [IconCategory.OFFICE, IconCategory.EDITOR],
figma_category: FigmaCategory.OFFICE,
tags: ["documents", "files", "browse", "draft", "open", "dotted"],
published_in: 1.3,
updated_in: 1.3,
},
{
name: "file-doc",
pascal_name: "FileDoc",
Expand All @@ -5408,15 +5356,6 @@ export const icons: ReadonlyArray<IconEntry> = [
published_in: 1.4,
updated_in: 1.4,
},
{
name: "file-dotted",
pascal_name: "FileDotted",
categories: [IconCategory.OFFICE, IconCategory.EDITOR],
figma_category: FigmaCategory.OFFICE,
tags: ["documents", "files", "browse", "draft", "open"],
published_in: 1.3,
updated_in: 1.3,
},
{
name: "file-html",
pascal_name: "FileHtml",
Expand Down Expand Up @@ -5933,8 +5872,9 @@ export const icons: ReadonlyArray<IconEntry> = [
updated_in: 1.0,
},
{
name: "folder-dotted",
pascal_name: "FolderDotted",
name: "folder-dashed",
pascal_name: "FolderDashed",
alias: { name: "folder-dotted", pascal_name: "FolderDotted" },
categories: [IconCategory.OFFICE, IconCategory.EDITOR, IconCategory.SYSTEM],
figma_category: FigmaCategory.OFFICE,
tags: [
Expand All @@ -5945,6 +5885,7 @@ export const icons: ReadonlyArray<IconEntry> = [
"folders",
"missing",
"temporary",
"dotted",
],
published_in: 1.4,
updated_in: 1.4,
Expand Down Expand Up @@ -6075,8 +6016,9 @@ export const icons: ReadonlyArray<IconEntry> = [
updated_in: 1.0,
},
{
name: "folder-simple-dotted",
pascal_name: "FolderSimpleDotted",
name: "folder-simple-dashed",
pascal_name: "FolderSimpleDashed",
alias: { name: "folder-simple-dotted", pascal_name: "FolderSimpleDotted" },
categories: [IconCategory.OFFICE, IconCategory.EDITOR, IconCategory.SYSTEM],
figma_category: FigmaCategory.OFFICE,
tags: [
Expand All @@ -6087,6 +6029,7 @@ export const icons: ReadonlyArray<IconEntry> = [
"folders",
"missing",
"temporary",
"dotted",
],
published_in: 1.4,
updated_in: 1.4,
Expand Down Expand Up @@ -10168,6 +10111,25 @@ export const icons: ReadonlyArray<IconEntry> = [
published_in: 1.2,
updated_in: 1.2,
},
{
name: "pulse",
pascal_name: "Pulse",
alias: { name: "activity", pascal_name: "Activity" },
categories: [IconCategory.HEALTH],
figma_category: FigmaCategory.HEALTH,
tags: [
"activity",
"heartbeat",
"medical",
"ecg",
"ekg",
"vitals",
"monitor",
"medicine",
],
published_in: 1.0,
updated_in: 1.0,
},
{
name: "push-pin",
pascal_name: "PushPin",
Expand Down Expand Up @@ -10571,6 +10533,75 @@ export const icons: ReadonlyArray<IconEntry> = [
published_in: 1.4,
updated_in: 1.4,
},
{
name: "seal",
pascal_name: "Seal",
alias: { name: "circle-wavy", pascal_name: "CircleWavy" },
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: [
"badge",
"verified",
"verification",
"shapes",
"polygons",
"circle-wavy",
],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "seal-check",
pascal_name: "SealCheck",
alias: { name: "circle-wavy-check", pascal_name: "CircleWavyCheck" },
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: [
"badge",
"verified",
"verification",
"shapes",
"polygons",
"circle-wavy",
],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "seal-question",
pascal_name: "SealQuestion",
alias: { name: "circle-wavy-question", pascal_name: "CircleWavyQuestion" },
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: [
"badge",
"unverified",
"verification",
"shapes",
"polygons",
"circle-wavy",
],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "seal-warning",
pascal_name: "SealWarning",
alias: { name: "circle-wavy-warning", pascal_name: "CircleWavyWarning" },
categories: [IconCategory.DESIGN],
figma_category: FigmaCategory.SECURITY,
tags: [
"badge",
"unverified",
"verification",
"errors",
"shapes",
"polygons",
"circle-wavy",
],
published_in: 1.2,
updated_in: 1.2,
},
{
name: "selection",
pascal_name: "Selection",
Expand Down Expand Up @@ -11964,11 +11995,20 @@ export const icons: ReadonlyArray<IconEntry> = [
updated_in: 1.0,
},
{
name: "text-bolder",
pascal_name: "TextBolder",
name: "text-b",
pascal_name: "TextB",
alias: { name: "text-bolder", pascal_name: "TextBolder" },
categories: [IconCategory.DESIGN, IconCategory.EDITOR, IconCategory.OFFICE],
figma_category: FigmaCategory.OFFICE,
tags: ["typography", "typeface", "print", "font", "boldface", "emphasis"],
tags: [
"typography",
"typeface",
"print",
"font",
"bold",
"boldface",
"emphasis",
],
published_in: 1.1,
updated_in: 1.1,
},
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export enum FigmaCategory {
export interface IconEntry {
name: string;
pascal_name: string;
alias?: {
name: string;
pascal_name: string;
};
categories: IconCategory[];
figma_category: FigmaCategory;
tags: string[];
Expand Down

0 comments on commit 68da136

Please sign in to comment.