Skip to content

Commit

Permalink
added translate growtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenadros committed Apr 24, 2024
1 parent acd2680 commit 09cd993
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
8 changes: 6 additions & 2 deletions plugin-src/transformers/transformTextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
transformSceneNode,
transformTextStyle
} from '@plugin/transformers/partials';
import { translateStyledTextSegments, translateVerticalAlign } from '@plugin/translators';
import {
translateGrowType,
translateStyledTextSegments,
translateVerticalAlign
} from '@plugin/translators';

import { TextShape } from '@ui/lib/types/text/textShape';

Expand Down Expand Up @@ -45,7 +49,7 @@ export const transformTextNode = (node: TextNode, baseX: number, baseY: number):
}
]
},
growType: 'auto-width',
growType: translateGrowType(node.textAutoResize),
positionData: segments,
...transformDimensionAndPosition(node, baseX, baseY),
...transformEffects(node),
Expand Down
1 change: 1 addition & 0 deletions plugin-src/translators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './translateBlendMode';
export * from './translateShadowEffects';
export * from './translateFills';
export * from './translateFontStyle';
export * from './translateGrowType';
export * from './translateHorizontalAlign';
export * from './translateStrokes';
export * from './translateStyledTextSegments';
Expand Down
15 changes: 15 additions & 0 deletions plugin-src/translators/translateGrowType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GrowType } from '@ui/lib/types/shape/shapeAttributes';

export const translateGrowType = (
growType: 'NONE' | 'WIDTH_AND_HEIGHT' | 'HEIGHT' | 'TRUNCATE'
): GrowType => {
switch (growType) {
case 'WIDTH_AND_HEIGHT':
return 'auto-width';
case 'HEIGHT':
return 'auto-height';
case 'TRUNCATE':
default:
return 'fixed';
}
};
4 changes: 3 additions & 1 deletion ui-src/lib/types/shape/shapeAttributes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ export type ShapeAttributes = {
interactions?: Interaction[];
shadow?: Shadow[];
blur?: Blur;
growType?: 'auto-width' | 'auto-height' | 'fixed';
growType?: GrowType;
};

export type GrowType = 'auto-width' | 'auto-height' | 'fixed';

0 comments on commit 09cd993

Please sign in to comment.