-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(icon): provide splitte icon files for Vue.js #1417
Comments
@tiloyi pour les icones et SVG : <component :is="icon" /> const iconName = computed(() => `Device_${props.name}_${props.size}px`); Version directe : const icon = defineAsyncComponent(() => {
return import(`/node_modules/@mozaic-ds/icons/svg/${iconName.value}.svg`);
}); Version "distionnaire" : const modules = import.meta.glob('/node_modules/@mozaic-ds/icons/svg/*.svg')
const icon = defineAsyncComponent(async () => {
const moduleName = `/node_modules/@mozaic-ds/icons/svg/${iconName.value}.svg`
return await modules[moduleName]()
});
|
Je suis bête, je l'avais fait sans plugin : <template>
<img :src="svg"/>
</template> import {onBeforeMount, ref} from 'vue'
const props = defineProps({
svgFile: {
type: String,
required: true,
},
// native attributes
alt: String,
})
const svg = ref<string>();
onBeforeMount(async () => {
const svgModuleFactories = import.meta.glob('/node_modules/@mozaic-ds/icons/svg/*.svg')
const svgModuleFactory = svgModuleFactories[`/node_modules/@mozaic-ds/icons/svg/${props.svgFile}`]
const svgModule = await svgModuleFactory() as { default: string }
svg.value = svgModule.default
}) |
https://github.com/adeo/pricely/tree/main/sspm-front/src/mozaic/MIcon ℹ️ serait idéal : harmoniser les noms d'icone entre fichiers SVG, Vue.js, WebComponents, React |
Effectivement j'ai également un surplus de 200kB :
Si je ne dis pas de bêtise :
Sachant qu'il y a 1441 icones : c'est cohérent 👍 |
I want to propose an evolution/improvement on
Icon set
Description
Naming convension
Currently all icons are listed in
icon/js/icon.js
file, where each couple of name/size has constant name with convension{name}{size}
👍ℹ️ Name comes from catalog
Problem
In JS, the solution to load 1 icon is to load the entire file, and filter constantes following previous convension.
It's not a good practice regarding application loading: the bundle file is very big (>1Mo 😨)
SVG files
A solution is to load directly SVG from
/icons/svg/*.svg
.But the problem is filename doesn't respect the previous convension: they have different prefix.
Describe the solution you would like
Create new folder, specifically for Vue.js, will create another one more name for an icon.
And there are already too many cases: icon name ≠ React/vue name ≠ Web Component name ≠ Svg file name ...
So in my opinion, rename icons to follow the same convension is the best solution 👍
Describe the alternatives you considered
No response
Additional comments
icons/js/icons.js
who declare thesize
attribute, andicons/svg/*.svg
who don't declare thissize
attribute.The text was updated successfully, but these errors were encountered: