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

source macro: preserve new lines #1372

Merged
merged 4 commits into from
Oct 12, 2023
Merged

source macro: preserve new lines #1372

merged 4 commits into from
Oct 12, 2023

Conversation

mrm007
Copy link
Collaborator

@mrm007 mrm007 commented Oct 12, 2023

@babel/generator's default value for retainLines is false. This means that applying the source macro on a code block with something like this:

const options = [
  { value: "1", label: "Option 1" },
  { value: "2", label: "Option 2" },
  { value: "3", label: "Option 3" },
  { value: "4", label: "Option 4" },
  { value: "5", label: "Option 5" },
];

results in this

const options = [
  {
    value: "1",
    label: "Option 1",
  },
  {
    value: "2",
    label: "Option 2",
  },
  {
    value: "3",
    label: "Option 3",
  },
  {
    value: "4",
    label: "Option 4",
  },
  {
    value: "5",
    label: "Option 5",
  },
];

Another example:

Before
const responsiveValue = useResponsiveValue()
const isMobile = responsiveValue({
  mobile: true,
  tablet: false,
})
const isDesktopOrAbove = responsiveValue({
  mobile: false,
  desktop: true,
})
After
const responsiveValue = useResponsiveValue()

const isMobile = responsiveValue({
  mobile: true,
  tablet: false,
})

const isDesktopOrAbove = responsiveValue({
  mobile: false,
  desktop: true,
})

@mrm007 mrm007 requested a review from a team as a code owner October 12, 2023 00:14
@changeset-bot
Copy link

changeset-bot bot commented Oct 12, 2023

🦋 Changeset detected

Latest commit: 1d3f33a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@braid-design-system/source.macro Patch

Not sure what this means? Click here to learn what changesets are.

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

Co-authored-by: Michael Taranto <michaeltaranto@users.noreply.github.com>
@mrm007 mrm007 merged commit 3f8a82c into master Oct 12, 2023
8 checks passed
@mrm007 mrm007 deleted the source-macro-preserve-lines branch October 12, 2023 03:48
@seek-oss-ci seek-oss-ci mentioned this pull request Oct 12, 2023
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.

2 participants