Skip to content

Commit

Permalink
patch: replaces unplugin-icons with @mdi/js (v0.22.14)
Browse files Browse the repository at this point in the history
  • Loading branch information
this-oliver committed Apr 16, 2023
1 parent 71d0ba8 commit b6ba226
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 78 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ssasy-auth/extension",
"nickname": "ssasy",
"version": "0.22.13",
"version": "0.22.14",
"license": "MIT",
"description": "a browser extension that is built with a secure, usable and scalable authentictaion scheme",
"repository": "this-oliver/ssasy-ext",
Expand Down Expand Up @@ -37,6 +37,7 @@
"test": "vitest test"
},
"dependencies": {
"@mdi/js": "^7.2.96",
"@ssasy-auth/core": "1.9.1",
"pinia": "^2.0.33",
"vue": "^3.2.47",
Expand All @@ -46,7 +47,6 @@
},
"devDependencies": {
"@ffflorian/jszip-cli": "^3.1.9",
"@iconify/json": "^2.2.31",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.14.6",
"@types/webextension-polyfill": "^0.10.0",
Expand Down Expand Up @@ -75,7 +75,6 @@
"typescript": "^4.9.5",
"unocss": "^0.50.4",
"unplugin-auto-import": "^0.15.1",
"unplugin-icons": "^0.15.3",
"unplugin-vue-components": "^0.24.0",
"vite": "^4.1.4",
"vite-plugin-pages": "^0.28.0",
Expand Down
46 changes: 6 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function goBack() {
small
rounded="pill"
@click="goBack">
<material-symbols-arrow-back />
<v-icon icon="$mdi-arrow-left" />
</base-btn>

<logo id="bar-center"/>
Expand Down
6 changes: 0 additions & 6 deletions src/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
Components in this dir will be auto-registered and on-demand, powered by [`vite-plugin-components`](https://github.com/antfu/vite-plugin-components).

Components can be shared in all views.

### Icons

You can use icons from almost any icon sets by the power of [Iconify](https://iconify.design/).

It will only bundle the icons you use. Check out [vite-plugin-icons](https://github.com/antfu/vite-plugin-icons) for more details.
2 changes: 1 addition & 1 deletion src/components/cards/InfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const props = defineProps({
<v-col cols="1">
<div class="mx-auto">
<slot name="icon">
<mdi-information-outline />
<v-icon icon="$mdi-information-outline" />
</slot>
</div>
</v-col>
Expand Down
32 changes: 19 additions & 13 deletions src/pages/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,44 @@ import BaseBtn from '~/components/base/BaseBtn.vue';
const options: ActionItem[] = [
{
label: 'Key',
to: '/key'
to: '/key',
icon: '$mdi-key'
},
{
label: 'Settings',
to: '/settings'
to: '/settings',
icon: '$mdi-cog'
}
];
</script>

<template>
<base-page title="Home">
<v-row justify="center">
<v-col
cols="11"
md="6"
class="home-welcome text-center">
<h1>🎉 Welcome!</h1>
</v-col>

<v-divider class="opacity-0" />

<v-col
v-for="option in options"
:key="option.label"
cols="7"
md="4"
class="mt-1">
<base-btn
large
block
extra-large
:to="option.to">
{{ option.label }}
<v-row
justify="space-between"
style="width: 100%;">
<v-col>
{{ option.label }}
</v-col>

<v-col>
<v-icon
v-if="option.icon"
:icon="option.icon"/>
</v-col>
</v-row>
</base-btn>
</v-col>
</v-row>
Expand Down
21 changes: 19 additions & 2 deletions src/plugins/vuetify-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { aliases, mdi } from 'vuetify/iconsets/mdi-svg'
import { VSkeletonLoader } from 'vuetify/labs/VSkeletonLoader'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import { type ThemeDefinition } from 'vuetify'
import * as icons from '@mdi/js'

import type { ThemeDefinition } from 'vuetify'

export const AppTheme: ThemeDefinition = {
dark: false,
Expand Down Expand Up @@ -46,6 +48,18 @@ export const AppThemeDark: ThemeDefinition = {
}
}

function getProcessedIcons(icons: any){
const processedIcons: any = {};

for (const key in icons) {
// convert from PascalCase to kebab-case
const kebabCaseKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase()

processedIcons[kebabCaseKey] = icons[key]
}

return processedIcons
}

export default createVuetify({
components: {
Expand All @@ -62,7 +76,10 @@ export default createVuetify({
},
icons: {
defaultSet: 'mdi',
aliases,
aliases: {
...aliases,
...getProcessedIcons(icons)
},
sets: {
mdi
}
Expand Down
13 changes: 1 addition & 12 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import UnoCSS from 'unocss/vite'
Expand Down Expand Up @@ -44,18 +42,9 @@ export const sharedConfig: UserConfig = {
Components({
dirs: [ r('src/components') ],
// generate `components.d.ts` for ts support with Volar
dts: r('src/components.d.ts'),
resolvers: [
// auto import icons
IconsResolver({
componentPrefix: ''
})
]
dts: r('src/components.d.ts')
}),

// https://github.com/antfu/unplugin-icons
Icons(),

// https://github.com/unocss/unocss
UnoCSS(),

Expand Down

0 comments on commit b6ba226

Please sign in to comment.