Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Builder parser does not strip falsey style values #1697

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Feb 21, 2025

Description

The Builder JSON parser currently strips out falsey style values (I.e. padding: 0). The original motivation for this was to cut down on the amount of CSS generated with codegen in Builder. However, our codegen process has improved since then where this is not a big problem anymore.

More importantly, stripping falsey values is causing functional changes to the code because we make the assumption that a value of 0 is the same as not having the CSS declaration to begin with which is not always true. For example, we remove values such as flex-shrink: 0. However, the default value for flex-shrink is 1.

Another example can be seen here: https://codepen.io/liamdebeasi/pen/gbOrgJm

In the first block #text has z-index: 0 which causes it to show on top of the square. In the second block ,#text does not have z-index: 0 which causes it to show below the square.

This PR resolves the issue by removing logic that removes falsey CSS values.

For added context, this logic was originally added via a PR to Mitosis, but this PR was a port from another repo.


Make sure to follow the PR preparation steps in CONTRIBUTING.md before submitting your PR:

  • format the codebase: from the root, run yarn fmt:prettier.
  • update all snapshots (in core & CLI): from the root, run yarn test:update
  • add Changeset entry: from the root, run yarn g:changeset and follow the CLI instructions. Alternatively, use the Changeset Github Bot to create the file.

Copy link

changeset-bot bot commented Feb 21, 2025

⚠️ No Changeset found

Latest commit: f585cd0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

nx-cloud bot commented Feb 21, 2025

View your CI Pipeline Execution ↗ for commit 5212ea4.

Command Status Duration Result
nx run-many --target test ✅ Succeeded 4m 41s View ↗
nx e2e @builder.io/e2e-app ✅ Succeeded 1m 6s View ↗
nx run-many --target build --exclude @builder.i... ✅ Succeeded 3m 41s View ↗
nx build @builder.io/mitosis-site ✅ Succeeded 2m 22s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-21 16:00:32 UTC

@liamdebeasi liamdebeasi changed the title add failing test fix: Builder parser does not strip falsey style values Feb 21, 2025
@liamdebeasi liamdebeasi marked this pull request as ready for review February 21, 2025 16:10
Copy link
Contributor

@kylefowler kylefowler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ship it

@liamdebeasi liamdebeasi merged commit 05257f2 into BuilderIO:main Feb 21, 2025
11 checks passed
@liamdebeasi liamdebeasi deleted the ld/falsey-styles branch February 21, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants