mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 21:53:27 -05:00
511b842b12
* additional layout properties * changeset
60 lines
2 KiB
TypeScript
60 lines
2 KiB
TypeScript
import {
|
|
translateLayoutAlignContent,
|
|
translateLayoutAlignItems,
|
|
translateLayoutFlexDir,
|
|
translateLayoutGap,
|
|
translateLayoutItemAlignSelf,
|
|
translateLayoutJustifyContent,
|
|
translateLayoutJustifyItems,
|
|
translateLayoutPadding,
|
|
translateLayoutPaddingType,
|
|
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),
|
|
layoutPaddingType: translateLayoutPaddingType(node),
|
|
layoutJustifyContent: translateLayoutJustifyContent(node),
|
|
layoutJustifyItems: translateLayoutJustifyItems(node),
|
|
layoutAlignContent: translateLayoutAlignContent(node),
|
|
layoutAlignItems: translateLayoutAlignItems(node)
|
|
};
|
|
};
|
|
|
|
export const transformLayoutAttributes = (
|
|
node: LayoutMixin,
|
|
isFrame: boolean = false
|
|
): Pick<
|
|
LayoutChildAttributes,
|
|
| 'layoutItemH-Sizing'
|
|
| 'layoutItemV-Sizing'
|
|
| 'layoutItemAlignSelf'
|
|
| 'layoutItemAbsolute'
|
|
| 'layoutItemMaxH'
|
|
| 'layoutItemMinH'
|
|
| 'layoutItemMaxW'
|
|
| 'layoutItemMinW'
|
|
> => {
|
|
return {
|
|
'layoutItemH-Sizing': translateLayoutSizing(node.layoutSizingHorizontal, isFrame),
|
|
'layoutItemV-Sizing': translateLayoutSizing(node.layoutSizingVertical, isFrame),
|
|
'layoutItemAlignSelf': translateLayoutItemAlignSelf(node.layoutAlign),
|
|
'layoutItemAbsolute': node.layoutPositioning === 'ABSOLUTE',
|
|
'layoutItemMaxH': node.maxHeight ?? undefined,
|
|
'layoutItemMinH': node.minHeight ?? undefined,
|
|
'layoutItemMaxW': node.maxWidth ?? undefined,
|
|
'layoutItemMinW': node.minWidth ?? undefined
|
|
};
|
|
};
|