0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00

Update Types to 2.0.2 (#48)

* updated types

* minor fixes

* minor fixes
This commit is contained in:
Alex Sánchez 2024-04-18 16:36:49 +02:00 committed by GitHub
parent 3dc9559618
commit 08473b5124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 227 additions and 33 deletions

View file

@ -1,6 +1,10 @@
import { LayoutChildAttributes } from '@ui/lib/types/layout/layoutChildAttributes';
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';
import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes'; import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes';
import { BoolAttributes } from './boolAttributes'; import { BoolAttributes } from './boolAttributes';
export type BoolShape = ShapeBaseAttributes & ShapeAttributes & BoolAttributes; export type BoolShape = ShapeBaseAttributes &
ShapeAttributes &
BoolAttributes &
LayoutChildAttributes;

View file

@ -1,3 +1,4 @@
import { Stroke } from '@ui/lib/types/utils/stroke';
import { Uuid } from '@ui/lib/types/utils/uuid'; import { Uuid } from '@ui/lib/types/utils/uuid';
import { Fill } from '../utils/fill'; import { Fill } from '../utils/fill';
@ -7,9 +8,9 @@ export const FRAME_TYPE: unique symbol = Symbol.for('frame');
export type FrameAttributes = { export type FrameAttributes = {
type: 'frame' | typeof FRAME_TYPE; type: 'frame' | typeof FRAME_TYPE;
shapes?: Uuid[]; shapes?: Uuid[];
fileThumbnail?: boolean;
hideFillOnExport?: boolean; hideFillOnExport?: boolean;
showContent?: boolean; showContent?: boolean;
hideInViewer?: boolean; hideInViewer?: boolean;
fills?: Fill[]; fills?: Fill[];
strokes?: Stroke[];
}; };

View file

@ -1,7 +1,14 @@
import { LayoutAttributes } from '@ui/lib/types/layout/layoutAttributes';
import { LayoutChildAttributes } from '@ui/lib/types/layout/layoutChildAttributes';
import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes'; import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes';
import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes'; import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes';
import { Children } from '@ui/lib/types/utils/children'; import { Children } from '@ui/lib/types/utils/children';
import { FrameAttributes } from './frameAttributes'; import { FrameAttributes } from './frameAttributes';
export type FrameShape = ShapeBaseAttributes & ShapeGeomAttributes & FrameAttributes & Children; export type FrameShape = ShapeBaseAttributes &
ShapeGeomAttributes &
FrameAttributes &
LayoutAttributes &
LayoutChildAttributes &
Children;

View file

@ -4,7 +4,7 @@ export const IMAGE_TYPE: unique symbol = Symbol.for('image');
export type ImageAttributes = { export type ImageAttributes = {
type: 'image' | typeof IMAGE_TYPE; type: 'image' | typeof IMAGE_TYPE;
dataUri?: string; dataUri?: string; //@TODO: check how this works because it's not defined in penpot, it's just used in the export
metadata: { metadata: {
width: number; width: number;
height: number; height: number;

View file

@ -1,3 +1,4 @@
import { LayoutChildAttributes } from '@ui/lib/types/layout/layoutChildAttributes';
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';
import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes'; import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes';
import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes'; import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes';
@ -7,4 +8,5 @@ import { ImageAttributes } from './imageAttributes';
export type ImageShape = ShapeBaseAttributes & export type ImageShape = ShapeBaseAttributes &
ShapeGeomAttributes & ShapeGeomAttributes &
ShapeAttributes & ShapeAttributes &
ImageAttributes; ImageAttributes &
LayoutChildAttributes;

14
ui-src/lib/types/layout/gridCell.d.ts vendored Normal file
View file

@ -0,0 +1,14 @@
import { Uuid } from '@ui/lib/types/utils/uuid';
export type GridCell = {
id?: Uuid;
areaName?: string;
row: number;
rowSpan: number;
column: number;
columnSpan: number;
position?: 'auto' | 'manual' | 'area';
alignSelf?: 'auto' | 'start' | 'end' | 'center' | 'stretch';
justifySelf?: 'auto' | 'start' | 'end' | 'center' | 'stretch';
shapes?: Uuid[];
};

View file

@ -0,0 +1,4 @@
export type GridTrack = {
type: 'percent' | 'flex' | 'auto' | 'fixed';
value?: number;
};

View file

@ -0,0 +1,46 @@
import { GridCell } from '@ui/lib/types/layout/gridCell';
import { GridTrack } from '@ui/lib/types/layout/gridTrack';
import { Uuid } from '@ui/lib/types/utils/uuid';
type JustifyAlignContent =
| 'start'
| 'center'
| 'end'
| 'space-between'
| 'space-around'
| 'space-evenly'
| 'stretch';
type JustifyAlignItems = 'start' | 'end' | 'center' | 'stretch';
export type LayoutAttributes = {
layout?: 'flex' | 'grid';
layoutFlexDir?:
| 'row'
| 'reverse-row'
| 'row-reverse'
| 'column'
| 'reverse-column'
| 'column-reverse';
layoutGap?: {
rowGap?: number;
columnGap?: number;
};
layoutGapType?: 'simple' | 'multiple';
layoutWrapType?: 'wrap' | 'nowrap' | 'no-wrap';
layoutPaddingType?: 'simple' | 'multiple';
layoutPadding?: {
p1?: number;
p2?: number;
p3?: number;
p4?: number;
};
layoutJustifyContent?: JustifyAlignContent;
layoutJustifyItems?: JustifyAlignItems;
layoutAlignContent?: JustifyAlignContent;
layoutAlignItems?: JustifyAlignItems;
layoutGridDir?: 'row' | 'column';
layoutGridRows?: GridTrack[];
layoutGridColumns?: GridTrack[];
layoutGridCells?: { [uuid: Uuid]: GridCell };
};

View file

@ -1,3 +1,4 @@
import { LayoutChildAttributes } from '@ui/lib/types/layout/layoutChildAttributes';
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';
import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes'; import { ShapeBaseAttributes } from '@ui/lib/types/shape/shapeBaseAttributes';
import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes'; import { ShapeGeomAttributes } from '@ui/lib/types/shape/shapeGeomAttributes';
@ -7,4 +8,5 @@ import { TextAttributes } from './textAttributes';
export type TextShape = ShapeBaseAttributes & export type TextShape = ShapeBaseAttributes &
ShapeGeomAttributes & ShapeGeomAttributes &
ShapeAttributes & ShapeAttributes &
TextAttributes; TextAttributes &
LayoutChildAttributes;

View file

@ -1,8 +1,23 @@
export type Animation = { export type Animation = AnimationDissolve | AnimationSlide | AnimationPush;
animationType: symbol; // 'dissolve' | 'slide' | 'push'
type AnimationDissolve = {
animationType: 'dissolve';
duration: number; duration: number;
easing: symbol; // 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' easing: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
way?: symbol; // 'in' | 'out' };
direction?: symbol; // 'right' | 'left' | 'up' | 'down'
offsetEffect?: boolean; type AnimationSlide = {
animationType: 'slide';
duration: number;
easing: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
way: 'in' | 'out';
direction: 'right' | 'left' | 'up' | 'down';
offsetEffect: boolean;
};
type AnimationPush = {
animationType: 'push';
duration: number;
easing: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out';
direction: 'right' | 'left' | 'up' | 'down';
}; };

View file

@ -2,7 +2,7 @@ import { Uuid } from './uuid';
export type Blur = { export type Blur = {
id: Uuid; id: Uuid;
type: symbol; // layer-blur type: 'layer-blur';
value: number; value: number;
hidden: boolean; hidden: boolean;
}; };

18
ui-src/lib/types/utils/color.d.ts vendored Normal file
View file

@ -0,0 +1,18 @@
import { Gradient } from '@ui/lib/types/utils/gradient';
import { ImageColor } from '@ui/lib/types/utils/imageColor';
import { RgbColor } from '@ui/lib/types/utils/rgbColor';
import { Uuid } from '@ui/lib/types/utils/uuid';
export type Color = {
id?: Uuid;
name?: string;
path?: string;
value?: string;
color?: RgbColor;
opacity?: number;
modifiedAt?: string; //@TODO: check this attribute in penpot
refId?: Uuid;
refFile?: Uuid;
gradient: Gradient;
image?: ImageColor;
};

View file

@ -1,3 +1,5 @@
import { ImageColor } from '@ui/lib/types/utils/imageColor';
import { Gradient } from './gradient'; import { Gradient } from './gradient';
import { Uuid } from './uuid'; import { Uuid } from './uuid';
@ -7,4 +9,5 @@ type Fill = {
fillColorGradient?: Gradient; fillColorGradient?: Gradient;
fillColorRefFile?: Uuid; fillColorRefFile?: Uuid;
fillColorRefId?: Uuid; fillColorRefId?: Uuid;
fillImage?: ImageColor;
}; };

View file

@ -1,3 +1,5 @@
import { RgbColor } from '@ui/lib/types/utils/rgbColor';
export type Grid = ColumnGrid | RowGrid | SquareGrid; export type Grid = ColumnGrid | RowGrid | SquareGrid;
type ColumnGrid = { type ColumnGrid = {
@ -7,7 +9,7 @@ type ColumnGrid = {
}; };
type RowGrid = { type RowGrid = {
type: 'column'; type: 'row';
display: boolean; display: boolean;
params: ColumnParams; params: ColumnParams;
}; };
@ -33,7 +35,6 @@ type SquareParams = {
}; };
type GridColor = { type GridColor = {
// @TODO: Maybe we need a proper type here color: RgbColor;
color: number;
opacity: number; opacity: number;
}; };

11
ui-src/lib/types/utils/imageColor.d.ts vendored Normal file
View file

@ -0,0 +1,11 @@
import { Uuid } from '@ui/lib/types/utils/uuid';
//@TODO: check how this exports the image through a dataUri
export type ImageColor = {
name?: string;
width: number;
height: number;
mtype?: string;
id?: Uuid;
keepAspectRatio?: boolean;
};

View file

@ -1,17 +1,81 @@
import { Point } from '@ui/lib/types/utils/point';
import { Animation } from './animation'; import { Animation } from './animation';
import { Uuid } from './uuid'; import { Uuid } from './uuid';
export type Interaction = { export type Interaction =
eventType: symbol; // 'click' | 'mouse-press' | 'mouse-over' | 'mouse-enter' | 'mouse-leave' | 'after-delay' | InteractionNavigate
actionType: symbol; // 'navigate' | 'open-overlay' | 'toggle-overlay' | 'close-overlay' | 'prev-screen' | 'open-url' | InteractionOpenOverlay
| InteractionToggleOverlay
| InteractionCloseOverlay
| InteractionPrevScreen
| InteractionOpenUrl;
type EventType =
| 'click'
| 'mouse-press'
| 'mouse-over'
| 'mouse-enter'
| 'mouse-leave'
| 'after-delay';
type OverlayPosType =
| 'manual'
| 'center'
| 'top-left'
| 'top-right'
| 'top-center'
| 'bottom-left'
| 'bottom-right'
| 'bottom-center';
type InteractionNavigate = {
actionType: 'navigate';
eventType: EventType;
destination?: Uuid; destination?: Uuid;
preserveScroll?: boolean; preserveScroll?: boolean;
animation?: Animation; animation?: Animation;
overlayPosition?: { x: number; y: number }; };
overlayPosType?: symbol; // 'manual' | 'center' | 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center'
type InteractionOpenOverlay = {
actionType: 'open-overlay';
eventType: EventType;
overlayPosition?: Point;
overlayPosType?: OverlayPosType;
destination?: Uuid;
closeClickOutside?: boolean; closeClickOutside?: boolean;
backgroundOverlay?: boolean; backgroundOverlay?: boolean;
animation?: Animation;
positionRelativeTo?: Uuid; positionRelativeTo?: Uuid;
url?: string; };
delay?: number;
type InteractionToggleOverlay = {
actionType: 'toggle-overlay';
eventType: EventType;
overlayPosition?: Point;
overlayPosType?: OverlayPosType;
destination?: Uuid;
closeClickOutside?: boolean;
backgroundOverlay?: boolean;
animation?: Animation;
positionRelativeTo?: Uuid;
};
type InteractionCloseOverlay = {
actionType: 'close-overlay';
eventType: EventType;
destination?: Uuid;
animation?: Animation;
positionRelativeTo?: Uuid;
};
type InteractionPrevScreen = {
actionType: 'prev-screen';
eventType: EventType;
};
type InteractionOpenUrl = {
actionType: 'open-url';
eventType: EventType;
url: string;
}; };

5
ui-src/lib/types/utils/rgbColor.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
export type RgbColor = {
title?: string;
description?: string;
gen: string;
};

View file

@ -1,4 +1,5 @@
import { Gradient } from './gradient'; import { Color } from '@ui/lib/types/utils/color';
import { Uuid } from './uuid'; import { Uuid } from './uuid';
export type Shadow = { export type Shadow = {
@ -9,11 +10,5 @@ export type Shadow = {
blur: number; blur: number;
spread: number; spread: number;
hidden: boolean; hidden: boolean;
color: { color: Color;
color?: string;
opacity?: number;
gradient?: Gradient;
fileId?: Uuid;
id?: Uuid;
};
}; };

View file

@ -1,5 +1,6 @@
import { Gradient } from './gradient'; import { Gradient } from '@ui/lib/types/utils/gradient';
import { Uuid } from './uuid'; import { ImageColor } from '@ui/lib/types/utils/imageColor';
import { Uuid } from '@ui/lib/types/utils/uuid';
export type Stroke = { export type Stroke = {
strokeColor?: string; strokeColor?: string;
@ -12,6 +13,7 @@ export type Stroke = {
strokeCapStart?: StrokeCaps; strokeCapStart?: StrokeCaps;
strokeCapEnd?: StrokeCaps; strokeCapEnd?: StrokeCaps;
strokeColorGradient?: Gradient; strokeColorGradient?: Gradient;
strokeImage?: ImageColor;
}; };
export type StrokeAlignment = 'center' | 'inner' | 'outer'; export type StrokeAlignment = 'center' | 'inner' | 'outer';