Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import React from "react";
  2. import styled from "styled-components";
  3.  
  4. type Orientation = "vertical" | "horizontal";
  5.  
  6. interface LinearLayoutProps {
  7. as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
  8. fullWidth?: boolean;
  9. orientation?: Orientation;
  10. }
  11.  
  12. const Component = styled.div<{ orientation?: Orientation }>`
  13. display: flex;
  14. flex-direction: ${({ orientation }) => orientation === "vertical" ? "column" : "row" };
  15. `;
  16.  
  17. const LinearLayout: React.FC<LinearLayoutProps> = ({
  18. as = "div",
  19. orientation = "vertical",
  20. ...props
  21. }) => {
  22. return (
  23. <Component
  24. as={as}
  25. {...props}
  26. />
  27. );
  28. };
  29.  
  30. export default LinearLayout;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement