index.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import React from 'react';
  2. import { Tag, Tooltip } from '../../../index';
  3. function Item(props = {}) {
  4. const tops = [
  5. ['topLeft', 'TL'],
  6. ['top', 'Top'],
  7. ['topRight', 'TR'],
  8. ];
  9. const lefts = [
  10. ['leftTop', 'LT'],
  11. ['left', 'Left'],
  12. ['leftBottom', 'LB'],
  13. ];
  14. const rights = [
  15. ['rightTop', 'RT'],
  16. ['right', 'Right'],
  17. ['rightBottom', 'RB'],
  18. ];
  19. const bottoms = [
  20. ['bottomLeft', 'BL'],
  21. ['bottom', 'Bottom'],
  22. ['bottomRight', 'BR'],
  23. ];
  24. const { tagStyle, ...restProps } = props;
  25. return (
  26. <div style={{ paddingLeft: 40 }}>
  27. <div style={{ marginLeft: 40, whiteSpace: 'nowrap' }}>
  28. {tops.map((pos, index) => (
  29. <Tooltip
  30. content={
  31. <article>
  32. <p>hi bytedance</p>
  33. <p>hi bytedance</p>
  34. </article>
  35. }
  36. position={Array.isArray(pos) ? pos[0] : pos}
  37. key={index}
  38. trigger={'click'}
  39. arrowPointAtCenter={true}
  40. {...restProps}
  41. >
  42. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  43. </Tooltip>
  44. ))}
  45. </div>
  46. <div style={{ width: 40, float: 'left' }}>
  47. {lefts.map((pos, index) => (
  48. <Tooltip
  49. content={
  50. <article>
  51. <p>hi bytedance</p>
  52. <p>hi bytedance</p>
  53. </article>
  54. }
  55. position={Array.isArray(pos) ? pos[0] : pos}
  56. key={index}
  57. trigger={'click'}
  58. arrowPointAtCenter={true}
  59. {...restProps}
  60. >
  61. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  62. </Tooltip>
  63. ))}
  64. </div>
  65. <div style={{ width: 40, marginLeft: 180 }}>
  66. {rights.map((pos, index) => (
  67. <Tooltip
  68. content={
  69. <article>
  70. <p>hi bytedance</p>
  71. <p>hi bytedance</p>
  72. </article>
  73. }
  74. position={Array.isArray(pos) ? pos[0] : pos}
  75. key={index}
  76. trigger={'click'}
  77. arrowPointAtCenter={true}
  78. {...restProps}
  79. >
  80. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  81. </Tooltip>
  82. ))}
  83. </div>
  84. <div style={{ marginLeft: 40, clear: 'both', whiteSpace: 'nowrap' }}>
  85. {bottoms.map((pos, index) => (
  86. <Tooltip
  87. content={
  88. <article>
  89. <p>hi bytedance</p>
  90. <p>hi bytedance</p>
  91. </article>
  92. }
  93. position={Array.isArray(pos) ? pos[0] : pos}
  94. key={index}
  95. trigger={'click'}
  96. arrowPointAtCenter={true}
  97. {...restProps}
  98. >
  99. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  100. </Tooltip>
  101. ))}
  102. </div>
  103. </div>
  104. );
  105. }
  106. function Demo() {
  107. return (
  108. <div>
  109. <div style={{ padding: 120 }}>
  110. <Item showArrow />
  111. </div>
  112. <div style={{ padding: 120 }}>
  113. <Item showArrow tagStyle={{ minHeight: 80, minWidth: 120 }} />
  114. </div>
  115. <div style={{ padding: 120 }}>
  116. <Item showArrow tagStyle={{ minHeight: 80, minWidth: 120 }} style={{ backgroundColor: 'green' }} />
  117. </div>
  118. <div style={{ padding: 120 }}>
  119. <Item
  120. showArrow
  121. tagStyle={{ minHeight: 80, minWidth: 120 }}
  122. style={{ backgroundColor: 'pink' }}
  123. content={null}
  124. />
  125. </div>
  126. <div style={{ padding: 120 }}>
  127. <Item showArrow content={null} style={{ backgroundColor: 'orange' }} />
  128. </div>
  129. </div>
  130. );
  131. }
  132. export default Demo;