Skip to content

Commit

Permalink
added proportion lock to all current nodes that support it (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenadros authored Apr 19, 2024
1 parent 44d691e commit 0be0730
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions plugin-src/transformers/partials/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './transformBlend';
export * from './transformChildren';
export * from './transformDimensionAndPosition';
export * from './transformFills';
export * from './transformProportion';
export * from './transformSceneNode';
export * from './transformStrokes';
export * from './transformTextStyle';
Expand Down
7 changes: 7 additions & 0 deletions plugin-src/transformers/partials/transformProportion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';

export const transformProportion = (node: LayoutMixin): Partial<ShapeAttributes> => {
return {
proportionLock: node.constrainProportions
};
};
4 changes: 3 additions & 1 deletion plugin-src/transformers/transformEllipseNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
transformBlend,
transformDimensionAndPosition,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
Expand All @@ -20,6 +21,7 @@ export const transformEllipseNode = (
...transformStrokes(node),
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
...transformBlend(node),
...transformProportion(node)
};
};
5 changes: 4 additions & 1 deletion plugin-src/transformers/transformFrameNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
transformChildren,
transformDimensionAndPosition,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
Expand Down Expand Up @@ -33,6 +34,8 @@ export const transformFrameNode = async (
// they plan to add it in the future. Refactor this when available.
// @see: https://forum.figma.com/t/add-a-blendmode-property-for-sectionnode/58560
...(isSectionNode(node) ? [] : transformBlend(node)),
...transformSceneNode(node)
...transformSceneNode(node),
// Figma API does not expose constraints proportions for sections
...(isSectionNode(node) ? [] : transformProportion(node))
};
};
4 changes: 3 additions & 1 deletion plugin-src/transformers/transformPathNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
transformBlend,
transformDimensionAndPosition,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes,
transformVectorPaths
Expand All @@ -25,6 +26,7 @@ export const transformPathNode = (
...transformVectorPaths(node, baseX, baseY),
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
...transformBlend(node),
...transformProportion(node)
};
};
4 changes: 3 additions & 1 deletion plugin-src/transformers/transformRectangleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
transformBlend,
transformDimensionAndPosition,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
Expand All @@ -20,6 +21,7 @@ export const transformRectangleNode = (
...transformStrokes(node),
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
...transformBlend(node),
...transformProportion(node)
};
};
4 changes: 3 additions & 1 deletion plugin-src/transformers/transformTextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
transformBlend,
transformDimensionAndPosition,
transformFills,
transformProportion,
transformSceneNode,
transformTextStyle
} from '@plugin/transformers/partials';
Expand Down Expand Up @@ -42,6 +43,7 @@ export const transformTextNode = (node: TextNode, baseX: number, baseY: number):
},
...transformDimensionAndPosition(node, baseX, baseY),
...transformSceneNode(node),
...transformBlend(node)
...transformBlend(node),
...transformProportion(node)
};
};

0 comments on commit 0be0730

Please sign in to comment.