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

Feature request: Break React storybook stories onto multiple lines #3551

Open
suchipi opened this issue Dec 22, 2017 · 3 comments
Open

Feature request: Break React storybook stories onto multiple lines #3551

suchipi opened this issue Dec 22, 2017 · 3 comments
Labels
lang:jsx Issues affecting JSX (not general JS issues) status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:enhancement A potential new feature to be added, or an improvement to how we print something

Comments

@suchipi
Copy link
Member

suchipi commented Dec 22, 2017

Is there interest in special-casing React Storybook printing so that examples are always multiline? This is how I've always formatted my stories, but I'm not sure how common it is.

Prettier 1.9.2
Playground link

Input:

import * as React from "react";
import { storiesOf } from "@storybook/react";
import ProgressBar from "./ProgressBar";

storiesOf("ProgressBar", module)
  .add("0", () => (
    <ProgressBar value={0} />
  ))
  .add("0.5", () => (
    <ProgressBar value={0.5} />
  ))
  .add("1", () => (
    <ProgressBar value={1} />
  ));

Output:

import * as React from "react";
import { storiesOf } from "@storybook/react";
import ProgressBar from "./ProgressBar";

storiesOf("ProgressBar", module)
  .add("0", () => <ProgressBar value={0} />)
  .add("0.5", () => <ProgressBar value={0.5} />)
  .add("1", () => <ProgressBar value={1} />);

Expected behavior:

Same as input

@suchipi suchipi added lang:javascript Issues affecting JS status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:enhancement A potential new feature to be added, or an improvement to how we print something labels Dec 22, 2017
@azz
Copy link
Member

azz commented Dec 22, 2017

What about the render props use case:

<Foo
  renderBar={({ value }) => <Bar value={value} />}
/>

vs.

<Foo
  renderBar={({ value }) => (
    <Bar value={value} />
  )}
/>

/cc @mjackson @kentcdodds thoughts?

@azz azz added lang:jsx Issues affecting JSX (not general JS issues) and removed lang:javascript Issues affecting JS labels Dec 22, 2017
@suchipi
Copy link
Member Author

suchipi commented Dec 22, 2017

Meta question: is lang:jsx a superset of lang:javascript? I've been adding them both in some cases.

@kentcdodds
Copy link
Member

I'm fine with either personally. I'd expect the one line for short lines and the multiple line with parentheses for long ones 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:jsx Issues affecting JSX (not general JS issues) status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

No branches or pull requests

3 participants