2022-02-16 19:18:39 +08:00
|
|
|
import { PublicConfigType } from '@/packages/index.d'
|
|
|
|
type AttrType = Pick<PublicConfigType, 'attr'>['attr']
|
2022-01-26 17:38:16 +08:00
|
|
|
|
|
|
|
export const useComponentStyle = (attr: AttrType, index: number) => {
|
|
|
|
const componentStyle = {
|
2022-01-31 23:37:43 +08:00
|
|
|
zIndex: index + 1,
|
2022-01-26 17:38:16 +08:00
|
|
|
left: `${attr.x}px`,
|
2022-02-01 17:12:16 +08:00
|
|
|
top: `${attr.y}px`
|
2022-01-27 20:47:22 +08:00
|
|
|
}
|
|
|
|
return componentStyle
|
|
|
|
}
|
2022-01-27 23:16:51 +08:00
|
|
|
|
2022-01-27 20:47:22 +08:00
|
|
|
export const useSizeStyle = (attr: AttrType) => {
|
|
|
|
const sizeStyle = {
|
2022-01-26 17:38:16 +08:00
|
|
|
width: `${attr.w}px`,
|
|
|
|
height: `${attr.h}px`
|
|
|
|
}
|
2022-01-27 20:47:22 +08:00
|
|
|
return sizeStyle
|
2022-01-26 17:38:16 +08:00
|
|
|
}
|