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

Support className to make styled-components usage easier #2089

Closed
iam4x opened this issue Apr 1, 2017 · 4 comments
Closed

Support className to make styled-components usage easier #2089

iam4x opened this issue Apr 1, 2017 · 4 comments

Comments

@iam4x
Copy link
Contributor

iam4x commented Apr 1, 2017

Feature: What is your use case for such a feature?

You can style directly third party components with styled-components this way:

import React from 'react';
import styled from 'styled-components';
import {Hits} from 'react-instantsearch';

const StyledHits = styled(Hits)`
  border: 1px solid black;
  background: red;

  .hit {
    display: block;
    border: 1px solid green;
  }
`;

[...]

return (
  <StyledHits 
       hitComponent={ ({name}) => <span className='hit'>{name}</span>) } 
  />
);

Feature: What is your proposed API entry? The new option to add? What is the behavior?

Every widget/component should accept className property for the root container.

What project are you opening an issue for?

  • react-instantsearch
@vvo
Copy link
Contributor

vvo commented Apr 1, 2017

Would this also allow https://github.com/zeit/styled-jsx? Just wondering, I bet https://github.com/zeit/styled-jsx is right now mostly used in next.js websites.

@mthuret
Copy link
Contributor

mthuret commented Apr 3, 2017

This is to allow the usage of styled-components with our widgets right (as opposed to connectors) ?

Using the classnames that are already defined is not working? (ex: .ais-Menu__root)

@iam4x
Copy link
Contributor Author

iam4x commented Apr 3, 2017

@vvo I don't know, but I have a project with next.js where I can check.

@mthuret Right now either you create a custom component with the connector, or you have to add a container which wrap the react-instantsearch component:

import React from 'react';
import styled from 'styled-components';
import {Hits} from 'react-instantsearch';

const HitsContainer = styled.div`
  .ais-Hits__root {
    [ ... ]
  }
`;

render() {
  return (
    <HitsContainer>
      <Hits />
    <HitsContainer>
  )
}

If react-instantsearch accepted a className prop to be passed in combination of .ais-Hits__root it will reduce boilerplate code.

And it's a common usage for third party components to accept this className property, what do you think?

@mthuret
Copy link
Contributor

mthuret commented Apr 11, 2017

React InstantSearch has been moved here: https://github.com/algolia/react-instantsearch
This issue has either been rewritten or placed inside our backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants