From dd1ffdd0f2c983f90193b5295e8f65ebde2c22a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=9B?= <41524451+CaptainObjective@users.noreply.github.com> Date: Thu, 1 Sep 2022 08:50:24 +0200 Subject: [PATCH] Better icon intellisense (#4) --- .prettierrc.yaml | 1 + package-lock.json | 34 ++++++++++++++++++++++++++++++++++ package.json | 2 ++ src/types/common.ts | 2 +- src/types/icon.ts | 12 ++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/types/icon.ts diff --git a/.prettierrc.yaml b/.prettierrc.yaml index 82b68c8..d3793d0 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -2,3 +2,4 @@ # See: https://prettier.io/docs/en/configuration.html#editorconfig singleQuote: true +endOfLine: auto diff --git a/package-lock.json b/package-lock.json index 08d31e7..121dd1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "devDependencies": { "@astrojs/react": "1.1.1", "@astrojs/tailwind": "1.0.0", + "@iconify/json": "2.1.100", "@types/react": "18.0.18", "@types/react-dom": "18.0.6", "@typescript-eslint/eslint-plugin": "5.36.1", @@ -40,6 +41,7 @@ "postcss": "8.4.16", "prettier": "2.7.1", "tailwindcss": "3.1.8", + "type-fest": "2.19.0", "vite": "3.0.9", "vite-tsconfig-paths": "3.5.0" }, @@ -767,6 +769,16 @@ "react": ">=16" } }, + "node_modules/@iconify/json": { + "version": "2.1.100", + "resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.1.100.tgz", + "integrity": "sha512-ztPJgsoqJQ2T216O0Wl94YmK085kLWeu25SekkwZaaTVZ5XaByER/h84AWGaKz7sBnnvdWJ+8ExAGyBGdr44bg==", + "dev": true, + "dependencies": { + "@iconify/types": "*", + "pathe": "^0.3.0" + } + }, "node_modules/@iconify/types": { "version": "2.0.0-beta.1", "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0-beta.1.tgz", @@ -7060,6 +7072,12 @@ "node": ">=8" } }, + "node_modules/pathe": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-0.3.5.tgz", + "integrity": "sha512-grU/QeYP0ChuE5kjU2/k8VtAeODzbernHlue0gTa27+ayGIu3wqYBIPGfP9r5xSqgCgDd4nWrjKXEfxMillByg==", + "dev": true + }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -10054,6 +10072,16 @@ "iconify-icon": "^1.0.0-beta.3" } }, + "@iconify/json": { + "version": "2.1.100", + "resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.1.100.tgz", + "integrity": "sha512-ztPJgsoqJQ2T216O0Wl94YmK085kLWeu25SekkwZaaTVZ5XaByER/h84AWGaKz7sBnnvdWJ+8ExAGyBGdr44bg==", + "dev": true, + "requires": { + "@iconify/types": "*", + "pathe": "^0.3.0" + } + }, "@iconify/types": { "version": "2.0.0-beta.1", "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0-beta.1.tgz", @@ -14404,6 +14432,12 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, + "pathe": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-0.3.5.tgz", + "integrity": "sha512-grU/QeYP0ChuE5kjU2/k8VtAeODzbernHlue0gTa27+ayGIu3wqYBIPGfP9r5xSqgCgDd4nWrjKXEfxMillByg==", + "dev": true + }, "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", diff --git a/package.json b/package.json index ea10804..9222712 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "devDependencies": { "@astrojs/react": "1.1.1", "@astrojs/tailwind": "1.0.0", + "@iconify/json": "2.1.100", "@types/react": "18.0.18", "@types/react-dom": "18.0.6", "@typescript-eslint/eslint-plugin": "5.36.1", @@ -50,6 +51,7 @@ "postcss": "8.4.16", "prettier": "2.7.1", "tailwindcss": "3.1.8", + "type-fest": "2.19.0", "vite": "3.0.9", "vite-tsconfig-paths": "3.5.0" } diff --git a/src/types/common.ts b/src/types/common.ts index 05d691a..d2ff24f 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -1,6 +1,6 @@ import type { ImageMetadata } from '@astrojs/image'; -export type Icon = string; +import type { Icon } from './icon'; export type LocalImage = Promise<{ default: ImageMetadata }>; diff --git a/src/types/icon.ts b/src/types/icon.ts new file mode 100644 index 0000000..1cafe9b --- /dev/null +++ b/src/types/icon.ts @@ -0,0 +1,12 @@ +import type { StringKeyOf, ValueOf } from 'type-fest'; + +type IconSets = { + 'fa6-brands': typeof import('@iconify/json/json/fa6-brands.json'); + 'fa6-solid': typeof import('@iconify/json/json/fa6-solid.json'); + 'simple-icons': typeof import('@iconify/json/json/simple-icons.json'); + 'circle-flags': typeof import('@iconify/json/json/circle-flags.json'); +}; + +export type Icon = ValueOf<{ + [IconSet in keyof IconSets]: `${IconSet}:${StringKeyOf}`; +}>;