mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Extracted default window constants
This commit is contained in:
@@ -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<Size>(defaultWindowSize);
|
||||
const [{ x, y }, setPosition] = useState<Position>(defaultWindowPosition);
|
||||
const [{ height, width }, setSize] = useState<Size>(DEFAULT_WINDOW_SIZE);
|
||||
const [{ x, y }, setPosition] = useState<Position>(DEFAULT_WINDOW_POSITION);
|
||||
const updatePosition = useCallback<DraggableEventHandler>(
|
||||
(_event, { x: positionX, y: positionY }) =>
|
||||
setPosition({ x: positionX, y: positionY }),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user