Skip to content

Commit

Permalink
document
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi committed Nov 21, 2024
1 parent 78d5015 commit 8d7ae81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ describe('Builder', () => {
{
"style": {
"bindingType": "expression",
"code": "{ fontSize: state.fontSize, '@media (max-width: 640px)': {\\"left\\":\\"state.left\\",\\"top\\":\\"state.top\\"}, '@media (max-width: 1200px)': {\\"color\\":\\"state.color\\"}, }",
"code": "{ fontSize: state.fontSize, \\"@media (max-width: 640px)\\": {\\"left\\":\\"state.left\\",\\"top\\":\\"state.top\\"}, \\"@media (max-width: 1200px)\\": {\\"color\\":\\"state.color\\"}, }",
"type": "single",
},
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/parsers/builder/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ const getStyleStringFromBlock = (block: BuilderElement, options: BuilderToMitosi
const [_, size, prop] = key.split('.');
const mediaKey = `@media (max-width: ${sizes[size as Size].max}px)`;

const objKey = `'${mediaKey}'`;
/**
* The media query key has spaces/special characters so we need to ensure
* that the key is always a string otherwise there will be runtime errors.
*/
const objKey = `"${mediaKey}"`;
responsiveStyles[objKey] = {
...responsiveStyles[objKey],
[prop]: block.bindings[key],
Expand Down

0 comments on commit 8d7ae81

Please sign in to comment.