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

Add indents to multi-line formatted object strings #38

Merged

Conversation

kohlmannj
Copy link
Contributor

@kohlmannj kohlmannj commented Mar 22, 2018

Similar to #27, but based on the latest version of this library. Also, sorry about the delayed follow-up on this!

Description

Depending on its content, an object might be stringified as a multi-line string. I noticed this and added a bit of code to conditionally add indentation to all but the first line of the multi-string value in this case.

Before

The breakpoints prop is a multi-line object, but it doesn't have the correct indentation below.

<Responsive as={ThemedFigure}
  title='Shared Figure Title'
  breakpoints={{
"(max-width: 539px)": {
  "src": "http://placehold.it/320x160",
  "caption": "For some reason, this is just a captioned image on mobile."
},
"(min-width: 540px)": {
  "caption": "On desktop, this is a looping video. Try resizing the window to see what happens on mobile.",
  "children": <FrameAnimation src='https://video1.nytimes.com/paidpost/belvedere/the-view-from-here/tabletop.mp4' />
}
  }} />

After

Now the multi-line object is correctly indented.

<Responsive as={ThemedFigure}
  title='Shared Figure Title'
  breakpoints={{
    "(max-width: 539px)": {
      "src": "http://placehold.it/320x160",
      "caption": "For some reason, this is just a captioned image on mobile."
    },
    "(min-width: 540px)": {
      "caption": "On desktop, this is a looping video. Try resizing the window to see what happens on mobile.",
      "children": <FrameAnimation src='https://video1.nytimes.com/paidpost/belvedere/the-view-from-here/tabletop.mp4' />
    }
  }} />

@alansouzati
Copy link
Member

thanks for your contribution @kohlmannj

@alansouzati alansouzati merged commit 7fc3d7d into grommet:master Mar 22, 2018
@kohlmannj kohlmannj deleted the feature/multiline-string-indentation branch March 23, 2018 02:25
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.

None yet

2 participants