fix(kiwi): preserve pattern spacing

This commit is contained in:
Danila Poyarkov 2026-05-25 10:23:19 +03:00
parent 6a036acf89
commit a79d671873
5 changed files with 7 additions and 0 deletions

View file

@ -79,6 +79,7 @@ function applyImagePaintFields(fill: Fill, p: Paint): void {
function applySchemaPaintFields(fill: Fill, p: Paint): void {
if (p.sourceNodeId) fill.sourceNodeId = guidToString(p.sourceNodeId)
if (p.spacing) fill.spacing = p.spacing
if (p.patternSpacing) fill.patternSpacing = p.patternSpacing
if (p.patternTileType) fill.patternTileType = p.patternTileType as Fill['patternTileType']
if (p.verticalAlignment) fill.verticalAlignment = p.verticalAlignment as Fill['verticalAlignment']

View file

@ -218,6 +218,7 @@ function fillToKiwiPaint(f: SceneNode['fills'][number]): Paint {
if (f.imageScaleMode) paint.imageScaleMode = f.imageScaleMode
if (f.imageTransform) paint.transform = f.imageTransform
if (f.sourceNodeId) paint.sourceNodeId = stringToGuid(f.sourceNodeId)
if (f.spacing) paint.spacing = f.spacing
if (f.patternSpacing) paint.patternSpacing = f.patternSpacing
if (f.patternTileType) paint.patternTileType = f.patternTileType
if (f.verticalAlignment) paint.verticalAlignment = f.verticalAlignment

View file

@ -145,6 +145,7 @@ export interface Fill {
imageScaleMode?: ImageScaleMode
imageTransform?: GradientTransform
sourceNodeId?: string
spacing?: number
patternSpacing?: Vector
patternTileType?: PatternTileType
verticalAlignment?: PatternAlignment

View file

@ -15,6 +15,7 @@ describe('Figma paint schema field export', () => {
opacity: 0.75,
visible: true,
sourceNodeId: '12:34',
spacing: 6,
patternSpacing: { x: 8, y: 12 },
patternTileType: 'VERTICAL_HEXAGONAL',
verticalAlignment: 'CENTER',
@ -45,6 +46,7 @@ describe('Figma paint schema field export', () => {
expect(fills?.[0]).toMatchObject({
type: 'PATTERN',
sourceNodeId: { sessionID: 12, localID: 34 },
spacing: 6,
patternSpacing: { x: 8, y: 12 },
patternTileType: 'VERTICAL_HEXAGONAL',
verticalAlignment: 'CENTER',

View file

@ -18,6 +18,7 @@ describe('Figma paint schema field import', () => {
opacity: 0.75,
visible: true,
sourceNodeId,
spacing: 6,
patternSpacing: { x: 8, y: 12 },
patternTileType: 'HORIZONTAL_HEXAGONAL',
verticalAlignment: 'CENTER',
@ -32,6 +33,7 @@ describe('Figma paint schema field import', () => {
type: 'PATTERN',
opacity: 0.75,
sourceNodeId: '12:34',
spacing: 6,
patternSpacing: { x: 8, y: 12 },
patternTileType: 'HORIZONTAL_HEXAGONAL',
verticalAlignment: 'CENTER',