AvatarItem.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright 2017-2020 @polkadot/app-parachains 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. interface Props {
  7. children?: React.ReactNode;
  8. className?: string;
  9. color?: string;
  10. icon: React.ReactNode;
  11. isBig?: boolean;
  12. title: React.ReactNode;
  13. subtitle: React.ReactNode;
  14. }
  15. function AvatarItem ({ children, className = '', icon, isBig, subtitle, title }: Props): React.ReactElement<Props> {
  16. return (
  17. <div className={['ui--AvatarItem', className, isBig && 'big'].join(' ')}>
  18. <div className='ui--AvatarItem-icon'>
  19. {icon}
  20. </div>
  21. <div className='ui--AvatarItem-details'>
  22. <div className='ui--AvatarItem-title'>
  23. {title}
  24. </div>
  25. <div className='ui--AvatarItem-subtitle'>
  26. {subtitle}
  27. </div>
  28. </div>
  29. {children}
  30. </div>
  31. );
  32. }
  33. export default React.memo(styled(AvatarItem)`
  34. & {
  35. display: flex;
  36. align-items: center;
  37. .ui--AvatarItem-icon {
  38. width: 2.4rem;
  39. height: 2.4rem;
  40. margin-right: 0.5rem;
  41. display: flex;
  42. align-items: center;
  43. justify-content: center;
  44. > * {
  45. border-radius: 50%;
  46. width: 100%;
  47. height: 100%;
  48. }
  49. > .ui--Icon {
  50. color: white;
  51. line-height: 2.4rem;
  52. margin-right: 0 !important;
  53. }
  54. > img {
  55. }
  56. }
  57. .ui--AvatarItem-details {
  58. flex: 1;
  59. .ui--AvatarItem-title {
  60. font-weight: bold;
  61. font-size: 1rem;
  62. }
  63. .ui--AvatarItem-subtitle {
  64. color: rgba(100, 100, 100, 0.6);
  65. font-size: 1rem;
  66. }
  67. }
  68. &.big {
  69. .ui--AvatarItem-icon {
  70. width: 3.4rem;
  71. height: 3.4rem;
  72. margin-right: 0.6rem;
  73. > .ui--Icon {
  74. font-size: 1.6rem;
  75. line-height: 3.4rem;
  76. }
  77. }
  78. .ui--AvatarItem-details {
  79. .ui--AvatarItem-name {
  80. font-size: 1.4rem;
  81. line-height: 1.4rem;
  82. }
  83. }
  84. }
  85. }
  86. `);