Skip to content

Instantly share code, notes, and snippets.

@jepser
Created November 20, 2020 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jepser/ec724be5464f38336ffabdc2a492a3d6 to your computer and use it in GitHub Desktop.
Save jepser/ec724be5464f38336ffabdc2a492a3d6 to your computer and use it in GitHub Desktop.
Components convention
export { default } from './SuperComponent';
import styled from 'styled-components';
export const Root = styled.div``;
export const Label = styled.div``;
export const Title = styled.span``;
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