Spaces:
Runtime error
Runtime error
Download src/hooks/useIconRender.ts from leurez/moss: direct link, hf CLI and curl.
- Browser
- Download file 650 Bytes
-
https://huggingface.co/spaces/leurez/moss/resolve/main/src/hooks/useIconRender.ts
- Command line
-
hf download hf://spaces/leurez/moss/src/hooks/useIconRender.ts
-
curl -L -o useIconRender.ts https://huggingface.co/spaces/leurez/moss/resolve/main/src/hooks/useIconRender.ts
650 Bytes
| import { h } from 'vue' | |
| import { SvgIcon } from '@/components/common' | |
| export const useIconRender = () => { | |
| interface IconConfig { | |
| icon?: string | |
| color?: string | |
| fontSize?: number | |
| } | |
| interface IconStyle { | |
| color?: string | |
| fontSize?: string | |
| } | |
| const iconRender = (config: IconConfig) => { | |
| const { color, fontSize, icon } = config | |
| const style: IconStyle = {} | |
| if (color) | |
| style.color = color | |
| if (fontSize) | |
| style.fontSize = `${fontSize}px` | |
| if (!icon) | |
| window.console.warn('iconRender: icon is required') | |
| return () => h(SvgIcon, { icon, style }) | |
| } | |
| return { | |
| iconRender, | |
| } | |
| } | |