From 1b294488317355bd1e30bbcf042cb88568e5935c Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Mon, 15 Apr 2024 11:31:32 +0000 Subject: [PATCH] improve types --- ui-src/lib/types/bool/boolAttributes.ts | 1 - ui-src/lib/types/circle/circleAttributes.ts | 3 --- ui-src/lib/types/frame/frameAttributes.ts | 1 - ui-src/lib/types/group/groupAttributes.ts | 1 - ui-src/lib/types/image/imageAttributes.ts | 1 - ui-src/lib/types/rect/rectAttributes.ts | 3 --- ui-src/lib/types/shape/shapeBaseAttributes.ts | 16 +++++++++------- ui-src/lib/types/text/textAttributes.ts | 3 --- 8 files changed, 9 insertions(+), 20 deletions(-) diff --git a/ui-src/lib/types/bool/boolAttributes.ts b/ui-src/lib/types/bool/boolAttributes.ts index 8a58974..d19e7c4 100644 --- a/ui-src/lib/types/bool/boolAttributes.ts +++ b/ui-src/lib/types/bool/boolAttributes.ts @@ -5,7 +5,6 @@ import { BoolContent } from './boolContent'; export const BOOL_TYPE: unique symbol = Symbol.for('bool'); export type BoolAttributes = { - id?: Uuid; type: 'bool' | typeof BOOL_TYPE; shapes?: Uuid[]; boolType: string; // @TODO: in Penpot this is of type :keyword. check if it makes sense diff --git a/ui-src/lib/types/circle/circleAttributes.ts b/ui-src/lib/types/circle/circleAttributes.ts index 330ff33..3117968 100644 --- a/ui-src/lib/types/circle/circleAttributes.ts +++ b/ui-src/lib/types/circle/circleAttributes.ts @@ -1,8 +1,5 @@ -import { Uuid } from '@ui/lib/types/utils/uuid'; - export const CIRCLE_TYPE: unique symbol = Symbol.for('circle'); export type CircleAttributes = { type: 'circle' | typeof CIRCLE_TYPE; - id?: Uuid; }; diff --git a/ui-src/lib/types/frame/frameAttributes.ts b/ui-src/lib/types/frame/frameAttributes.ts index faecdd2..d828ff5 100644 --- a/ui-src/lib/types/frame/frameAttributes.ts +++ b/ui-src/lib/types/frame/frameAttributes.ts @@ -4,7 +4,6 @@ export const FRAME_TYPE: unique symbol = Symbol.for('frame'); export type FrameAttributes = { type: 'frame' | typeof FRAME_TYPE; - id?: Uuid; shapes?: Uuid[]; fileThumbnail?: boolean; hideFillOnExport?: boolean; diff --git a/ui-src/lib/types/group/groupAttributes.ts b/ui-src/lib/types/group/groupAttributes.ts index bf5a417..0e6e5fe 100644 --- a/ui-src/lib/types/group/groupAttributes.ts +++ b/ui-src/lib/types/group/groupAttributes.ts @@ -4,6 +4,5 @@ export const GROUP_TYPE: unique symbol = Symbol.for('group'); export type GroupAttributes = { type: 'group' | typeof GROUP_TYPE; - id?: Uuid; shapes?: Uuid[]; }; diff --git a/ui-src/lib/types/image/imageAttributes.ts b/ui-src/lib/types/image/imageAttributes.ts index 4fffe18..7b95f75 100644 --- a/ui-src/lib/types/image/imageAttributes.ts +++ b/ui-src/lib/types/image/imageAttributes.ts @@ -3,7 +3,6 @@ import { Uuid } from '@ui/lib/types/utils/uuid'; export const IMAGE_TYPE: unique symbol = Symbol.for('image'); export type ImageAttributes = { - id?: Uuid; type: 'image' | typeof IMAGE_TYPE; dataUri?: string; metadata: { diff --git a/ui-src/lib/types/rect/rectAttributes.ts b/ui-src/lib/types/rect/rectAttributes.ts index 2db19ef..7f91451 100644 --- a/ui-src/lib/types/rect/rectAttributes.ts +++ b/ui-src/lib/types/rect/rectAttributes.ts @@ -1,8 +1,5 @@ -import { Uuid } from '@ui/lib/types/utils/uuid'; - export const RECT_TYPE: unique symbol = Symbol.for('rect'); export type RectAttributes = { type: 'rect' | typeof RECT_TYPE; - id?: Uuid; }; diff --git a/ui-src/lib/types/shape/shapeBaseAttributes.ts b/ui-src/lib/types/shape/shapeBaseAttributes.ts index 8459242..50da0b6 100644 --- a/ui-src/lib/types/shape/shapeBaseAttributes.ts +++ b/ui-src/lib/types/shape/shapeBaseAttributes.ts @@ -3,15 +3,17 @@ import { Point } from '@ui/lib/types/utils/point'; import { Selrect } from '@ui/lib/types/utils/selrect'; import { Uuid } from '@ui/lib/types/utils/uuid'; -export const FRAME_TYPE: unique symbol = Symbol.for('frame'); -export const GROUP_TYPE: unique symbol = Symbol.for('group'); -export const BOOL_TYPE: unique symbol = Symbol.for('bool'); -export const RECT_TYPE: unique symbol = Symbol.for('rect'); +import { BOOL_TYPE } from '../bool/boolAttributes'; +import { CIRCLE_TYPE } from '../circle/circleAttributes'; +import { FRAME_TYPE } from '../frame/frameAttributes'; +import { GROUP_TYPE } from '../group/groupAttributes'; +import { IMAGE_TYPE } from '../image/imageAttributes'; +import { RECT_TYPE } from '../rect/rectAttributes'; +import { TEXT_TYPE } from '../text/textAttributes'; + +// @TODO: Move to its own file once we support all the shapes export const PATH_TYPE: unique symbol = Symbol.for('path'); -export const TEXT_TYPE: unique symbol = Symbol.for('text'); -export const CIRCLE_TYPE: unique symbol = Symbol.for('circle'); export const SVG_RAW_TYPE: unique symbol = Symbol.for('svg-raw'); -export const IMAGE_TYPE: unique symbol = Symbol.for('image'); export type ShapeBaseAttributes = { id?: Uuid; diff --git a/ui-src/lib/types/text/textAttributes.ts b/ui-src/lib/types/text/textAttributes.ts index dc90414..411d742 100644 --- a/ui-src/lib/types/text/textAttributes.ts +++ b/ui-src/lib/types/text/textAttributes.ts @@ -1,11 +1,8 @@ -import { Uuid } from '@ui/lib/types/utils/uuid'; - import { TextContent } from './textContent'; export const TEXT_TYPE: unique symbol = Symbol.for('text'); export type TextAttributes = { - id?: Uuid; type: 'text' | typeof TEXT_TYPE; content?: TextContent; };