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

Use displayName of parent non-glamorous component name #12

Open
emattias opened this issue Jul 12, 2017 · 3 comments
Open

Use displayName of parent non-glamorous component name #12

emattias opened this issue Jul 12, 2017 · 3 comments

Comments

@emattias
Copy link

emattias commented Jul 12, 2017

I would like it to use the displayName of my custom components since I rarely give the glamorous components names.

This example hopefully explains what I mean better:

const SideNav = (props) => {
  const { data: {
    merchant_logo: logo,
    merchant_name: name,
  } } = props

  return (
      <g.Div
        css={{
          backgroundColor: '#2B2C2C',
        }}
      >
        <g.Figure
          css={{
            margin: 0,
          }}
        >
        text
        </g.Figure>
      </g.Div>
  )
}

In the example above the first div would get the className of something like SideNav-div and the <g.Figure /> would get something like SideNav-div-figure

@emattias emattias changed the title Use name or parent non-glamorous component name Use name of parent non-glamorous component name Jul 12, 2017
@emattias emattias changed the title Use name of parent non-glamorous component name Use displayName of parent non-glamorous component name Jul 12, 2017
@kentcdodds
Copy link
Collaborator

Hi @emattias! I've thought about how we could do something like that... I wonder though what the value would be, because you already have SideNav appearing in ReactDevTools, then you can clearly see the g.Div followed by a g.Figure. I'm just not certain what more information would give you which you don't already readily have... 🤔

@emattias
Copy link
Author

I rarely use react devtools. I use glamorous.config.useDisplayNameInClassName = true and the regular element tab in chrome devtools instead (because that workflow can be used in any web project, not just ones using react).

There I don't know about SideNav. Also, if the custom component (SideNav in my example) is a large one, it is still useful to see which element is from the className rather than having to go up the dom tree and then back again to understand which element is which.

@kentcdodds
Copy link
Collaborator

Ok, I think I can get behind that. Might be a little challenging, but I'd be open to a pull request

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

No branches or pull requests

2 participants