AddressSmall.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 { Address, AccountId } from '@polkadot/types/interfaces';
  5. import React from 'react';
  6. import styled from 'styled-components';
  7. import AccountName from './AccountName';
  8. import IdentityIcon from './IdentityIcon';
  9. interface Props {
  10. children?: React.ReactNode;
  11. className?: string;
  12. defaultName?: string;
  13. onClickName?: () => void;
  14. overrideName?: React.ReactNode;
  15. withSidebar?: boolean;
  16. toggle?: unknown;
  17. value?: string | Address | AccountId | null | Uint8Array;
  18. }
  19. function AddressSmall ({ children, className = '', defaultName, onClickName, overrideName, toggle, value, withSidebar = true }: Props): React.ReactElement<Props> {
  20. return (
  21. <div className={`ui--AddressSmall ${className}`}>
  22. <IdentityIcon value={value as Uint8Array} />
  23. <AccountName
  24. className={withSidebar ? 'withSidebar' : ''}
  25. defaultName={defaultName}
  26. onClick={onClickName}
  27. override={overrideName}
  28. toggle={toggle}
  29. value={value}
  30. withSidebar={withSidebar}
  31. >
  32. {children}
  33. </AccountName>
  34. </div>
  35. );
  36. }
  37. export default React.memo(styled(AddressSmall)`
  38. white-space: nowrap;
  39. .ui--IdentityIcon,
  40. .ui--AccountName {
  41. vertical-align: middle;
  42. }
  43. .ui--IdentityIcon {
  44. margin-right: 0.75rem;
  45. }
  46. .ui--AccountName {
  47. display: inline-block;
  48. max-width: 26rem;
  49. overflow: hidden;
  50. &.withSidebar {
  51. cursor: help;
  52. }
  53. @media only screen and (max-width: 1700px) {
  54. max-width: 24rem;
  55. }
  56. @media only screen and (max-width: 1600px) {
  57. max-width: 22rem;
  58. }
  59. @media only screen and (max-width: 1500px) {
  60. max-width: 20rem;
  61. }
  62. @media only screen and (max-width: 1400px) {
  63. max-width: 18rem;
  64. }
  65. @media only screen and (max-width: 1300px) {
  66. max-width: 16rem;
  67. }
  68. @media only screen and (max-width: 1200px) {
  69. max-width: 14rem;
  70. }
  71. @media only screen and (max-width: 1200px) {
  72. max-width: 12rem;
  73. }
  74. }
  75. `);