28 lines
701 B
Plaintext
28 lines
701 B
Plaintext
---
|
|
export interface Props {
|
|
name: string,
|
|
width?: string,
|
|
height?: string,
|
|
display?: string,
|
|
};
|
|
|
|
const { name, width, height, display } = Astro.props;
|
|
|
|
const icons = import.meta.glob<{string: string}>('@components/icons/*.svg', { query: '?raw', import: 'default' });
|
|
const path = `/src/components/icons/${name}.svg`;
|
|
if (icons[path] === undefined) {
|
|
throw new Error(`Icon ${name} does not exist.`);
|
|
}
|
|
const icon = await icons[path]();
|
|
---
|
|
|
|
<span class="icon" set:html={icon} />
|
|
|
|
<style define:vars={{ width, height, display }}>
|
|
.icon :global(svg) {
|
|
display: var(--display, block);
|
|
width: var(--width, 100%);
|
|
height: var(--height, 100%);
|
|
}
|
|
</style>
|