From ee3352278cf03fdd12f2a4663b403052de3f089a Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Fri, 17 Feb 2023 12:58:19 +0100 Subject: [PATCH] feat: migrate to `@egoist/tailwindcss-icons` --- .github/workflows/ci.yml | 4 +- docs/app.vue | 6 +- docs/nuxt.config.ts | 1 + docs/pages/components/[component].vue | 26 +-- docs/pages/examples.vue | 30 ++-- package.json | 5 +- src/module.ts | 12 +- src/runtime/components/elements/Button.vue | 5 +- src/runtime/components/elements/Dropdown.vue | 3 +- src/runtime/components/elements/Icon.vue | 16 ++ src/runtime/components/feedback/Alert.vue | 13 +- .../components/feedback/AlertDialog.vue | 5 +- src/runtime/components/forms/Input.vue | 5 +- src/runtime/components/forms/Select.vue | 3 +- src/runtime/components/forms/SelectCustom.vue | 5 +- src/runtime/components/forms/Toggle.vue | 5 +- .../components/navigation/CommandPalette.vue | 5 +- .../navigation/CommandPaletteGroup.vue | 6 +- .../navigation/VerticalNavigation.vue | 3 +- .../components/overlays/Notification.vue | 7 +- src/runtime/presets/default.ts | 40 +++-- yarn.lock | 153 ++++++------------ 22 files changed, 178 insertions(+), 180 deletions(-) create mode 100644 src/runtime/components/elements/Icon.vue diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74e9c980..60c29081 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,8 +41,8 @@ jobs: - name: Lint run: yarn lint - # - name: Typecheck - # run: yarn typecheck + - name: Typecheck + run: yarn typecheck - name: Build run: yarn build diff --git a/docs/app.vue b/docs/app.vue index cecf0b6e..a0bd8cb9 100644 --- a/docs/app.vue +++ b/docs/app.vue @@ -9,11 +9,11 @@ -
+
- + - +
diff --git a/docs/nuxt.config.ts b/docs/nuxt.config.ts index 2f195fe8..24746bfd 100644 --- a/docs/nuxt.config.ts +++ b/docs/nuxt.config.ts @@ -16,6 +16,7 @@ export default defineNuxtConfig({ }, preset: { }, + icons: ['heroicons', 'mdi'], tailwindcss: { theme: { extend: { diff --git a/docs/pages/components/[component].vue b/docs/pages/components/[component].vue index cedbca4d..79642e92 100644 --- a/docs/pages/components/[component].vue +++ b/docs/pages/components/[component].vue @@ -35,7 +35,7 @@ { alertDialog.value = v }, component: { @@ -154,21 +156,21 @@ const defaultProps = { items: [ [{ label: 'Edit', - icon: 'heroicons-solid:pencil' + icon: 'i-heroicons-pencil-square-20-solid' }, { label: 'Duplicate', - icon: 'heroicons-solid:duplicate' + icon: 'i-heroicons-document-duplicate-20-solid' }], [{ label: 'Archive', - icon: 'heroicons-solid:archive' + icon: 'i-heroicons-archive-box-20-solid' }, { label: 'Move', - icon: 'heroicons-solid:external-link' + icon: 'i-heroicons-arrow-right-circle-20-solid' }], [{ label: 'Delete', - icon: 'heroicons-solid:trash' + icon: 'i-heroicons-trash-20-solid' }] ] }, @@ -176,22 +178,22 @@ const defaultProps = { links: [ { label: 'Home', - icon: 'heroicons-outline:home', + icon: 'i-heroicons-home', to: '/' }, { label: 'Examples', - icon: 'heroicons-outline:book-open', + icon: 'i-heroicons-book-open', to: '/examples' }, { label: 'Migration', - icon: 'heroicons-outline:refresh', + icon: 'i-heroicons-arrow-path', to: '/migration' }, { label: 'External link', - icon: 'heroicons-outline:external-link', + icon: 'i-heroicons-link', to: 'https://google.fr', target: '_blank' } @@ -207,7 +209,7 @@ const defaultProps = { }] }, Icon: { - name: 'heroicons-outline:bell' + name: 'i-heroicons-bell' }, Input: { name: 'input', diff --git a/docs/pages/examples.vue b/docs/pages/examples.vue index 1ea91054..3ceb42d6 100644 --- a/docs/pages/examples.vue +++ b/docs/pages/examples.vue @@ -26,7 +26,7 @@ Button: - + Button text @@ -43,7 +43,7 @@
-

@@ -73,7 +73,7 @@

- + Open menu! @@ -98,7 +98,7 @@ @@ -117,7 +117,7 @@
- + @@ -125,7 +125,7 @@
Notifications:
- +
@@ -174,7 +174,7 @@
- + @@ -189,7 +189,7 @@ placeholder="Select a person" text-attribute="name" value-attribute="id" - icon="heroicons-outline:user" + icon="i-heroicons-user" /> @@ -198,7 +198,7 @@ - + @@ -302,27 +302,27 @@ function onSubmit () { const dropdownItems = [ [{ label: 'Edit', - icon: 'heroicons-solid:pencil', + icon: 'i-heroicons-pencil-square-20-solid', click: (e) => { e.preventDefault() onClick() } }, { label: 'Duplicate', - icon: 'heroicons-solid:duplicate' + icon: 'i-heroicons-document-duplicate-20-solid' }], [{ label: 'Archive', - icon: 'heroicons-solid:archive' + icon: 'i-heroicons-archive-box-20-solid' }, { label: 'Move', - icon: 'heroicons-solid:external-link', + icon: 'i-heroicons-arrow-right-circle-20-solid', to: 'https://www.google.fr', target: '_blank' }], [{ label: 'Delete', - icon: 'heroicons-solid:trash' + icon: 'i-heroicons-trash-20-solid' }] ] @@ -335,7 +335,7 @@ const customDropdownItems = [ }], [{ label: 'About', - icon: 'heroicons-solid:plus', + icon: 'i-heroicons-plus-20-solid', to: '/about' }] ] diff --git a/package.json b/package.json index 7ef5a4c4..c6bedaa0 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,9 @@ "release": "yarn lint && standard-version && git push --follow-tags" }, "dependencies": { + "@egoist/tailwindcss-icons": "^1.0.3", "@headlessui/vue": "^1.7.10", - "@iconify/vue": "^4.1.0", + "@iconify-json/heroicons": "^1.1.9", "@nuxt/kit": "^3.2.0", "@nuxtjs/color-mode": "^3.2.0", "@nuxtjs/tailwindcss": "^6.4.0", @@ -40,10 +41,10 @@ "defu": "^6.1.2", "fuse.js": "^6.6.2", "lodash-es": "^4.17.21", - "nuxt-icon": "^0.3.2", "tailwindcss": "^3.2.6" }, "devDependencies": { + "@iconify-json/mdi": "^1.1.47", "@nuxt/module-builder": "^0.2.1", "@nuxtjs/eslint-config-typescript": "^12.0.0", "@types/lodash-es": "^4.17.6", diff --git a/src/module.ts b/src/module.ts index cae86894..cb96fa0f 100644 --- a/src/module.ts +++ b/src/module.ts @@ -2,6 +2,7 @@ import { defineNuxtModule, installModule, addComponentsDir, addImportsDir, addTe import { defu } from 'defu' import colors from 'tailwindcss/colors.js' import type { Config } from 'tailwindcss' +import { iconsPlugin, getIconCollections } from '@egoist/tailwindcss-icons' import { name, version } from '../package.json' import { colorsAsRegex, excludeColors } from './runtime/utils/colors' import defaultPreset from './runtime/presets/default' @@ -39,6 +40,8 @@ export interface ModuleOptions { colors?: ColorsOptions + icons: string[] + tailwindcss?: Partial } @@ -49,6 +52,7 @@ const defaults = { primary: 'indigo', gray: 'gray' }, + icons: ['heroicons'], tailwindcss: { theme: {} } @@ -72,7 +76,7 @@ export default defineNuxtModule({ // Transpile runtime const runtimeDir = resolve('./runtime') nuxt.options.build.transpile.push(runtimeDir) - nuxt.options.build.transpile.push('@popperjs/core', '@headlessui/vue', '@iconify/vue') + nuxt.options.build.transpile.push('@popperjs/core', '@headlessui/vue') // @ts-ignore nuxt.hook('tailwindcss:config', function (tailwindConfig: TailwindConfig) { @@ -108,6 +112,9 @@ export default defineNuxtModule({ variants: ['focus'] }]) + tailwindConfig.plugins = tailwindConfig.plugins || [] + tailwindConfig.plugins.push(iconsPlugin({ collections: getIconCollections(options.icons) })) + const ui: object = defu(preset, defaultPreset(variantColors)) addTemplate({ @@ -121,9 +128,6 @@ export default defineNuxtModule({ }) }) - nuxt.options.appConfig.nuxtIcon = defu(nuxt.options.appConfig.nuxtIcon, { size: false }) - - await installModule('nuxt-icon') await installModule('@nuxtjs/color-mode', { classSuffix: '' }) await installModule('@nuxtjs/tailwindcss', { viewer: false, diff --git a/src/runtime/components/elements/Button.vue b/src/runtime/components/elements/Button.vue index a21c4d87..df65f280 100644 --- a/src/runtime/components/elements/Button.vue +++ b/src/runtime/components/elements/Button.vue @@ -6,14 +6,14 @@ :aria-label="ariaLabel" v-bind="buttonProps" > -