mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 14:14:05 -05:00
b85a4f7279
* wip * added layout sizing * layout positioning * fixes * fixes * fixes * fixes * fixes * fixes
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import {
|
|
translateLayoutAlignContent,
|
|
translateLayoutAlignItems,
|
|
translateLayoutFlexDir,
|
|
translateLayoutGap,
|
|
translateLayoutJustifyContent,
|
|
translateLayoutJustifyItems,
|
|
translateLayoutPadding,
|
|
translateLayoutSizing,
|
|
translateLayoutWrapType
|
|
} from '@plugin/translators';
|
|
|
|
import { LayoutAttributes, LayoutChildAttributes } from '@ui/lib/types/shapes/layout';
|
|
|
|
export const transformAutoLayout = (node: BaseFrameMixin): LayoutAttributes => {
|
|
return {
|
|
layout: node.layoutMode !== 'NONE' ? 'flex' : undefined,
|
|
layoutFlexDir: translateLayoutFlexDir(node.layoutMode),
|
|
layoutGap: translateLayoutGap(
|
|
node.layoutMode,
|
|
node.itemSpacing,
|
|
node.primaryAxisAlignItems === 'SPACE_BETWEEN'
|
|
),
|
|
layoutWrapType: translateLayoutWrapType(node.layoutWrap),
|
|
layoutPadding: translateLayoutPadding(node),
|
|
layoutJustifyContent: translateLayoutJustifyContent(node),
|
|
layoutJustifyItems: translateLayoutJustifyItems(node),
|
|
layoutAlignContent: translateLayoutAlignContent(node),
|
|
layoutAlignItems: translateLayoutAlignItems(node)
|
|
};
|
|
};
|
|
|
|
export const transformLayoutAttributes = (
|
|
node: LayoutMixin
|
|
): Pick<
|
|
LayoutChildAttributes,
|
|
'layoutItemH-Sizing' | 'layoutItemV-Sizing' | 'layoutItemAbsolute'
|
|
> => {
|
|
return {
|
|
'layoutItemH-Sizing': translateLayoutSizing(node.layoutSizingHorizontal),
|
|
'layoutItemV-Sizing': translateLayoutSizing(node.layoutSizingVertical),
|
|
'layoutItemAbsolute': node.layoutPositioning === 'ABSOLUTE'
|
|
};
|
|
};
|