/**
* Icons are from Blender
*
* LICENSE: https://download.blender.org/release/GPL-license.txt
*/
export const svg = {
'collapsed': ``,
'expanded': ``,
'eye-opened': ``,
'eye-closed': ``,
'chevron-right': ``,
'chevron-left': ``,
'chevron-down': ``,
'search': ``,
'cross': ``,
'copy': ``,
'warning': ``,
'error': ``,
'checkbox': ``,
'selectable': ``,
'unselectable': ``,
'scene': ``,
'object': ``,
'text': ``,
'bold': ``,
'italic': ``,
'small-caps': ``,
'text-left': ``,
'text-center': ``,
'text-right': ``,
'text-justify': ``,
} as const
let cache: string
export function bCssVars(): string {
if (typeof URL.createObjectURL !== 'function')
return ''
if (cache)
return cache
const cssVars: string[] = []
for (const [name, data] of Object.entries(svg)) {
const url = URL.createObjectURL(
new Blob([data], { type: 'image/svg+xml' }),
)
cssVars.push(`--b-icon-${name}: url(${url})`)
}
cache = cssVars.join(';\n')
return cache
}
/**
* CSS style with :root selector
*/
export function bCssVarsRootStyle(): string {
return `:root { ${bCssVars()} }`
}
/**
* Mounts CSS variables to the document head
*/
export function mountCssVarsRootStyle(): void {
const style = document.createElement('style')
style.textContent = bCssVarsRootStyle()
document.head.appendChild(style)
}