Skip to content

Commit

Permalink
fix: Builder generator includes width on Columns components (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi authored Feb 13, 2025
1 parent 9e2ebac commit 469394f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-days-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/mitosis': patch
---

Builder: include Column widths in generator
56 changes: 56 additions & 0 deletions packages/core/src/__tests__/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,62 @@ describe('Builder', () => {
`);
});

test('map Column widths', () => {
const content = {
data: {
blocks: [
{
'@type': '@builder.io/sdk:Element' as const,
component: {
name: 'Columns',
options: {
columns: [{ blocks: [], width: 50 }, { blocks: [] }],
},
},
},
],
},
};

const mitosisJson = builderContentToMitosisComponent(content);

const backToBuilder = componentToBuilder()({ component: mitosisJson });
expect(backToBuilder).toMatchInlineSnapshot(`
{
"data": {
"blocks": [
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [],
"code": {
"actions": {},
"bindings": {},
},
"component": {
"name": "Columns",
"options": {
"columns": [
{
"blocks": [],
"width": 50,
},
{
"blocks": [],
},
],
},
},
},
],
"jsCode": "",
"tsCode": "",
},
}
`);
});

test('nodes as props', () => {
const content = {
data: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/generators/builder/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const componentMappers: {

const columns = block.children!.map((item) => ({
blocks: item.children,
width: item.component?.options?.width,
}));

block.component!.options.columns = columns;
Expand Down

0 comments on commit 469394f

Please sign in to comment.