Created
October 15, 2020 12:34
-
-
Save alexaivars/2a0f6426252c5c7b37fa411a4f4cfbbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import styled, { StyledComponentBase } from 'styled-components'; | |
type ComponentProps = { text: string } & React.HTMLAttributes<HTMLDivElement>; | |
const Component: React.FunctionComponent<ComponentProps> = ({ | |
text = 'default', | |
className, | |
...props | |
}) => ( | |
<div className={className} {...props}> | |
{text} | |
</div> | |
); | |
type ComponentWithStyleProps = { | |
color: string; | |
} & ComponentProps; | |
type ComponentWithStyleType = StyledComponentBase< | |
React.FunctionComponent<ComponentProps>, | |
any, | |
ComponentWithStyleProps, | |
never | |
>; | |
export const ComponentWithStyle:ComponentWithStyleType = styled(Component)< | |
ComponentWithStyleProps | |
>` | |
border: 10px solid ${({ color }) => color}; | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment