Skip to content

Instantly share code, notes, and snippets.

@martinratinaud
Last active March 7, 2022 20:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martinratinaud/c0b07ad87676c9ce916afb86223fbd24 to your computer and use it in GitHub Desktop.
Save martinratinaud/c0b07ad87676c9ce916afb86223fbd24 to your computer and use it in GitHub Desktop.
typescript Dot Notation styled-components
import * as React from 'react';
import styled from 'styled-components';
const FullPageLayout = styled<any>(styled.div``)`
display: flex;
flex-direction: column;
`;
interface HeaderProps {
fixed?: boolean;
}
const Header = styled<HeaderProps>(({ fixed, ...rest }) => <header {...rest} />)`
background-color: red;
`;
const Main = styled<any>(styled.main``)`
background-color: yellow;
`;
const Footer = styled<any>(styled.footer``)`
background-color: green;
`;
interface FullPageLayoutProps {
children: any;
}
const FullPageLayoutWrapper = ({ children, ...rest }: FullPageLayoutProps) => (
<FullPageLayout {...rest}>{children}</FullPageLayout>
);
FullPageLayoutWrapper.Header = Header;
FullPageLayoutWrapper.Main = Main;
FullPageLayoutWrapper.Footer = Footer;
export default FullPageLayoutWrapper;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment