diff --git a/hooks/useDraggableAndResizable.ts b/hooks/useDraggableAndResizable.ts index 87224ce6..9b44ade8 100644 --- a/hooks/useDraggableAndResizable.ts +++ b/hooks/useDraggableAndResizable.ts @@ -2,8 +2,9 @@ import { useCallback, useMemo, useState } from 'react'; import type { DraggableEventHandler } from 'react-draggable'; import type { Position, RndResizeCallback } from 'react-rnd'; import { useTheme } from 'styled-components'; +import { DEFAULT_WINDOW_POSITION, DEFAULT_WINDOW_SIZE } from 'utils/constants'; -type Size = { +export type Size = { height: string; width: string; }; @@ -18,20 +19,10 @@ type Resizable = Size & { type DraggableAndResizable = Resizable & Draggable; -const defaultWindowSize = { - height: '200px', - width: '250px' -}; - -const defaultWindowPosition = { - x: 0, - y: 0 -}; - const useDraggableAndResizable = (maximized = false): DraggableAndResizable => { const { sizes } = useTheme(); - const [{ height, width }, setSize] = useState(defaultWindowSize); - const [{ x, y }, setPosition] = useState(defaultWindowPosition); + const [{ height, width }, setSize] = useState(DEFAULT_WINDOW_SIZE); + const [{ x, y }, setPosition] = useState(DEFAULT_WINDOW_POSITION); const updatePosition = useCallback( (_event, { x: positionX, y: positionY }) => setPosition({ x: positionX, y: positionY }), diff --git a/utils/constants.ts b/utils/constants.ts index 3b565006..e3107787 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -1,4 +1,15 @@ -export const MILLISECONDS_IN_SECOND = 1000; +import type { Size } from 'hooks/useDraggableAndResizable'; +import type { Position } from 'react-rnd'; + +export const DEFAULT_WINDOW_POSITION: Position = { + x: 0, + y: 0 +}; + +export const DEFAULT_WINDOW_SIZE: Size = { + height: '200px', + width: '250px' +}; export const IMAGE_FILE_EXTENSIONS = [ '.apng', @@ -21,3 +32,5 @@ export const IMAGE_FILE_EXTENSIONS = [ '.webp', '.xbm' ]; + +export const MILLISECONDS_IN_SECOND = 1000;