Created
November 20, 2020 18:31
-
-
Save jepser/ec724be5464f38336ffabdc2a492a3d6 to your computer and use it in GitHub Desktop.
Components convention
This file contains hidden or 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
export { default } from './SuperComponent'; |
This file contains hidden or 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 styled from 'styled-components'; | |
export const Root = styled.div``; | |
export const Label = styled.div``; | |
export const Title = styled.span``; |
This file contains hidden or 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 { Root, Label } from './SuperComponent.styled'; | |
type Props = { | |
name: string; | |
isPro?: boolean; | |
onClick?: (event: MouseEvent) => void; | |
}; | |
const SuperComponent: React.FC<Props> = ({ name, isPro = false, onClick }) => { | |
const handleClick = (event: MouseEvent) => { | |
onClick && onClick(event); | |
}; | |
return ( | |
<Root onClick={handleClick} role="button"> | |
{isPro && <Label />} | |
<Title>{name}</Title> | |
</Root> | |
); | |
}; | |
export default SuperComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment