Skip to content

Commit ad93f94

Browse files
committed
Fix assets
1 parent f158bd9 commit ad93f94

1 file changed

Lines changed: 126 additions & 0 deletions

File tree

src/codegen/__tests__/codegen.test.ts

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,132 @@ describe('Codegen', () => {
569569
} as unknown as VectorNode,
570570
expected: `<Image boxSize="24px" src="/icons/InvisibleIcon.svg" />`,
571571
},
572+
{
573+
title: 'renders nested svg asset with 3 solid fill boxes in frame',
574+
node: {
575+
type: 'FRAME',
576+
name: 'NestedIcon',
577+
children: [
578+
{
579+
type: 'RECTANGLE',
580+
name: 'Box1',
581+
children: [],
582+
visible: true,
583+
isAsset: false,
584+
fills: [
585+
{
586+
type: 'SOLID',
587+
visible: true,
588+
color: { r: 1, g: 0, b: 0 },
589+
opacity: 1,
590+
},
591+
],
592+
},
593+
{
594+
type: 'RECTANGLE',
595+
name: 'Box2',
596+
children: [],
597+
visible: true,
598+
isAsset: false,
599+
fills: [
600+
{
601+
type: 'SOLID',
602+
visible: true,
603+
color: { r: 1, g: 0, b: 0 },
604+
opacity: 1,
605+
},
606+
],
607+
},
608+
{
609+
type: 'RECTANGLE',
610+
name: 'Box3',
611+
children: [],
612+
visible: true,
613+
isAsset: false,
614+
fills: [
615+
{
616+
type: 'SOLID',
617+
visible: true,
618+
color: { r: 1, g: 0, b: 0 },
619+
opacity: 1,
620+
},
621+
],
622+
},
623+
],
624+
isAsset: false,
625+
layoutSizingHorizontal: 'FIXED',
626+
layoutSizingVertical: 'FIXED',
627+
width: 24,
628+
height: 24,
629+
} as unknown as FrameNode,
630+
expected: `<Box
631+
bg="#F00"
632+
boxSize="24px"
633+
maskImage="url(/icons/NestedIcon.svg)"
634+
maskRepeat="no-repeat"
635+
maskSize="contain"
636+
/>`,
637+
},
638+
{
639+
title: 'renders nested svg asset with different colors as image',
640+
node: {
641+
type: 'FRAME',
642+
name: 'NestedMultiColorIcon',
643+
children: [
644+
{
645+
type: 'RECTANGLE',
646+
name: 'Box1',
647+
children: [],
648+
visible: true,
649+
isAsset: false,
650+
fills: [
651+
{
652+
type: 'SOLID',
653+
visible: true,
654+
color: { r: 1, g: 0, b: 0 },
655+
opacity: 1,
656+
},
657+
],
658+
},
659+
{
660+
type: 'RECTANGLE',
661+
name: 'Box2',
662+
children: [],
663+
visible: true,
664+
isAsset: false,
665+
fills: [
666+
{
667+
type: 'SOLID',
668+
visible: true,
669+
color: { r: 0, g: 1, b: 0 },
670+
opacity: 1,
671+
},
672+
],
673+
},
674+
{
675+
type: 'RECTANGLE',
676+
name: 'Box3',
677+
children: [],
678+
visible: true,
679+
isAsset: false,
680+
fills: [
681+
{
682+
type: 'SOLID',
683+
visible: true,
684+
color: { r: 0, g: 0, b: 1 },
685+
opacity: 1,
686+
},
687+
],
688+
},
689+
],
690+
isAsset: true,
691+
layoutSizingHorizontal: 'FIXED',
692+
layoutSizingVertical: 'FIXED',
693+
width: 24,
694+
height: 24,
695+
} as unknown as FrameNode,
696+
expected: `<Image boxSize="24px" src="/icons/NestedMultiColorIcon.svg" />`,
697+
},
572698
{
573699
title: 'renders layout for absolute child same size as parent',
574700
node: {

0 commit comments

Comments
 (0)