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

Proposal: Exported styled children components #77

Open
Idered opened this issue Nov 22, 2019 · 1 comment
Open

Proposal: Exported styled children components #77

Idered opened this issue Nov 22, 2019 · 1 comment

Comments

@Idered
Copy link
Contributor

Idered commented Nov 22, 2019

It's hard to prepare component for every scenario. For cases not handled by props we should at least give user easy way to customize style of component. One way to do that is to export all styled child components which later could be used in user app:

import * as S from './styles'
export const TextInputElements = {
  Container: S.InputContainer,
  Input: S.Input
}

Which can be used in user application like this:

import {createGlobalStyle} from 'styled-components/macro'
import {TextInputElements} from '@smashing/text-input'

const CustomizedTextInput = createGlobalStyle`
  ${TextInputElements.Container} {
    padding: 8px 12px;
  }
`

It's impossible to style basing on a props passed to styled component

const App = () => (
  <div>
    <Pages/>
    <CustomizedTextInput />
  </div>
)

All Smashing components should implement this pattern.

Any one has a better name for export TextInputElements which will hold all styled children components?

@hzub
Copy link
Contributor

hzub commented Nov 22, 2019

IMO ComponentNameElements is a decent name, we could keep it this way

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

2 participants