@eturnity/eturnity_reusable_components 7.12.6-EPDM-7951.7 → 7.12.6-EPDM-7951.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -102,29 +102,22 @@ const IconImage = styled.div`
|
|
102
102
|
|
103
103
|
const icon = reactive({ html: '' })
|
104
104
|
|
105
|
-
const loadSvg = async (
|
106
|
-
const
|
105
|
+
const loadSvg = async () => {
|
106
|
+
const fileName = props.name.toLowerCase()
|
107
107
|
// We need to use "new URL" to load dynamic assets (https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url)
|
108
108
|
const fetchUrl = new URL(
|
109
|
-
`../../assets/svgIcons/${
|
109
|
+
`../../assets/svgIcons/${fileName}.svg`,
|
110
110
|
import.meta.url
|
111
111
|
).href
|
112
112
|
try {
|
113
|
-
const
|
114
|
-
icon.html = await
|
115
|
-
} catch (
|
113
|
+
const response = await fetch(fetchUrl)
|
114
|
+
icon.html = await response.text()
|
115
|
+
} catch (_) {
|
116
116
|
console.error(`Failed to load ${props.name}.svg`)
|
117
117
|
}
|
118
118
|
}
|
119
119
|
|
120
|
-
onMounted(
|
121
|
-
const iconPath = `../../assets/svgIcons/${props.name.toLowerCase()}.svg?raw`
|
122
|
-
const module = await import(/* @vite-ignore */ iconPath)
|
123
|
-
console.log(module.default)
|
124
|
-
icon.html = module.default
|
125
|
-
})
|
126
|
-
|
127
|
-
// onMounted(() => loadSvg())
|
120
|
+
onMounted(() => loadSvg())
|
128
121
|
|
129
122
|
watch(() => props.name, loadSvg)
|
130
123
|
</script>
|