mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-21 21:16:23 +08:00
32 lines
911 B
TypeScript
32 lines
911 B
TypeScript
import { PickCreateComponentType } from '@/packages/index.d'
|
|
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
|
|
type AttrType = PickCreateComponentType<'attr'>
|
|
|
|
export const useComponentStyle = (attr: AttrType, index: number) => {
|
|
const componentStyle = {
|
|
zIndex: index + 1,
|
|
left: `${attr.x}px`,
|
|
top: `${attr.y}px`
|
|
}
|
|
return componentStyle
|
|
}
|
|
|
|
export const useSizeStyle = (attr: AttrType, scale?: number) => {
|
|
const sizeStyle = {
|
|
width: `${scale ? scale * attr.w : attr.w}px`,
|
|
height: `${scale ? scale * attr.h : attr.h}px`,
|
|
border: '1px solid red'
|
|
}
|
|
return sizeStyle
|
|
}
|
|
|
|
export const useEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
|
|
return {
|
|
position: 'relative',
|
|
width: canvas.width ? `${canvas.width || 100}px` : '100%',
|
|
height: canvas.height ? `${canvas.height}px` : '100%',
|
|
border: '1px solid red'
|
|
}
|
|
}
|