Skip to content

Commit

Permalink
fix: remove prefix ri- for lucide icons
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi committed Nov 21, 2024
1 parent fa65d2a commit 070fed6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scripts/generate-icons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs-extra';
import { pascalCase } from 'scule';
import { XMLParser } from 'fast-xml-parser';

const PREFIX = 'ri-';
const REMIX_PREFIX = 'ri-';
const LUCIDE_PREFIX = 'lu-';
const TARGET = 'src/icons/';
const CHUNK_SIZE = 500;
Expand Down Expand Up @@ -74,7 +74,7 @@ async function getAllSvgDataFromPath(pathDir) {
}

try {
const name = PREFIX + path.basename(pathDir).replace('.svg', '');
const name = REMIX_PREFIX + path.basename(pathDir).replace('.svg', '');
const generatedName = pascalCase(name);
const svg = await readFile(pathDir, 'utf8');
const svgPath = getPathFromSvgString(svg);
Expand Down Expand Up @@ -110,7 +110,7 @@ async function getLucideSvgDataFromPath(pathDir) {

try {
const filePath = path.basename(pathDir).replace('.js', '');
const name = PREFIX + LUCIDE_PREFIX + filePath;
const name = LUCIDE_PREFIX + filePath;
const generatedName = pascalCase(name);
const iconModule = await import(`${pathDir}`);
const components = iconModule.default[2];
Expand Down
7 changes: 4 additions & 3 deletions src/components/icons/RuiIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@ const props = withDefaults(defineProps<Props>(), {
const { registeredIcons } = useIcons();
const isLucide = computed(() => props.name.startsWith('lu-'));
const components: ComputedRef<[string, Record<string, string>][] | undefined> = computed(() => {
const name = props.name;
if (!isRuiIcon(name)) {
console.warn(`icon ${name} must be a valid RuiIcon`);
}
const iconName = `ri-${name}`;
const prefix = get(isLucide) ? '' : 'ri-';
const iconName = `${prefix}${name}`;
const found = registeredIcons[iconName];
if (!found) {
console.error(`Icons "${name}" not found. Make sure that you have register the icon when installing the RuiPlugin`);
}
return found;
});
const isLucide = computed(() => props.name.startsWith('lu-'));
</script>

<template>
Expand Down

0 comments on commit 070fed6

Please sign in to comment.