useStyle.hook.ts 459 B

1234567891011121314151617181920
  1. import { PickCreateComponentType } from '@/packages/index.d'
  2. type AttrType = PickCreateComponentType<'attr'>
  3. export const useComponentStyle = (attr: AttrType, index: number) => {
  4. const componentStyle = {
  5. zIndex: index + 1,
  6. left: `${attr.x}px`,
  7. top: `${attr.y}px`
  8. }
  9. return componentStyle
  10. }
  11. export const useSizeStyle = (attr: AttrType) => {
  12. const sizeStyle = {
  13. width: `${attr.w}px`,
  14. height: `${attr.h}px`
  15. }
  16. return sizeStyle
  17. }