Skip to content

Commit

Permalink
fix(VIcon): add mdi set only if defaultSet is mdi (#18876)
Browse files Browse the repository at this point in the history
Co-authored-by: John Leider <john@vuetifyjs.com>
  • Loading branch information
dnldsht and johnleider committed Feb 21, 2024
1 parent 8ff3f8d commit 3daa452
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions packages/vuetify/src/composables/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,29 @@ export const VClassIcon = defineComponent({
})
export type VClassIcon = InstanceType<typeof VClassIcon>

export const defaultSets: Record<string, IconSet> = {
svg: {
component: VSvgIcon,
},
class: {
component: VClassIcon,
},
function genDefaults (): Record<string, IconSet> {
return {
svg: {
component: VSvgIcon,
},
class: {
component: VClassIcon,
},
}
}

// Composables
export function createIcons (options?: IconOptions) {
const sets = genDefaults()
const defaultSet = options?.defaultSet ?? 'mdi'

if (defaultSet === 'mdi' && !sets.mdi) {
sets.mdi = mdi
}

return mergeDeep({
defaultSet: 'mdi',
sets: {
...defaultSets,
mdi,
},
defaultSet,
sets,
aliases: {
...aliases,
/* eslint-disable max-len */
Expand Down Expand Up @@ -235,7 +241,7 @@ export const useIcon = (props: Ref<IconValue | undefined>) => {
setName => typeof icon === 'string' && icon.startsWith(`${setName}:`)
)

const iconName = iconSetName ? icon.slice(iconSetName.length + 1) : icon
const iconName = iconSetName?.startsWith('svg') ? icon.slice(iconSetName.length + 1) : icon.replace(':', '-')
const iconSet = icons.sets[iconSetName ?? icons.defaultSet]

return {
Expand Down

0 comments on commit 3daa452

Please sign in to comment.