Repository URL to install this package:
Version:
0.14.1 ▾
|
// === poc probably remove ===
const directionMap = {
top: '180deg',
right: '-90deg',
bottom: '',
left: '90deg',
}
type DirectionOrRaw = 'top' | 'right' | 'bottom' | 'left' | string
function rotate(directionOrRaw: DirectionOrRaw): string {
const degrees = directionMap[directionOrRaw]
return `rotate(${degrees})`
}
export { directionMap, rotate }
// === registry ===
export const iconRegistry = {}
const isNotIndex = path => path.includes('index') === false
const toFolder = filename =>
filename
.split('/')
.filter(isNotIndex)
.pop()
// manually exported
export function loadIconRegistry() {
// @todo need to ensure to not load the circular index
// const requireIcons = require.context('./', true, /.*\/index.ts$/)
// const setFolderNameOnIcons = filename => {
// const iconName = toFolder(filename)
// const Component = requireIcons(filename)
// iconRegistry[iconName] = Component.default
// }
// requireIcons.keys().forEach(setFolderNameOnIcons)
// console.log('[icons]: ', iconRegistry)
// return iconRegistry
}
let index = 0
export function fromPropsToIdentifier(props: any): string {
index += 1
const identifier =
props.identifier ||
props.className ||
props.vectorClassName ||
props.wording ||
'EMPTY'
return identifier + index
}