Columar.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2017-2020 @polkadot/react-components authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import React from 'react';
  5. import styled from 'styled-components';
  6. import Column from './Column';
  7. interface Props {
  8. children: React.ReactNode;
  9. className?: string;
  10. is60?: boolean;
  11. }
  12. type ColumarType = React.ComponentType<Props> & {
  13. Column: React.ComponentType<Props>;
  14. };
  15. function Columar ({ children, className = '', is60 }: Props): React.ReactElement<Props> {
  16. return (
  17. <div className={`ui--Columnar ${is60 ? 'is60' : 'is50'} ${className}`}>
  18. {children}
  19. </div>
  20. );
  21. }
  22. const ColumarExp = React.memo(styled(Columar)`
  23. display: flex;
  24. flex-wrap: wrap;
  25. &.is50 {
  26. .ui--Column {
  27. @media (min-width: 1025px) {
  28. max-width: 50%;
  29. min-width: 50%;
  30. }
  31. }
  32. }
  33. &.is60 {
  34. .ui--Column:first-child {
  35. @media (min-width: 1025px) {
  36. max-width: 60%;
  37. min-width: 60%;
  38. }
  39. }
  40. .ui--Column:last-child {
  41. @media (min-width: 1025px) {
  42. max-width: 40%;
  43. min-width: 40%;
  44. }
  45. }
  46. }
  47. `) as unknown as ColumarType;
  48. ColumarExp.Column = Column;
  49. export default ColumarExp;