index.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import React from 'react';
  2. import { Tag, Popover } 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. <Popover
  30. content={(
  31. <article>
  32. <p>hi bytedance</p>
  33. <p>hi bytedance</p>
  34. </article>
  35. )
  36. }
  37. position={Array.isArray(pos) ? pos[0] : pos}
  38. key={index}
  39. trigger={'click'}
  40. arrowPointAtCenter={true}
  41. {...restProps}
  42. >
  43. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  44. </Popover>
  45. ))}
  46. </div>
  47. <div style={{ width: 40, float: 'left' }}>
  48. {lefts.map((pos, index) => (
  49. <Popover
  50. content={(
  51. <article>
  52. <p>hi bytedance</p>
  53. <p>hi bytedance</p>
  54. </article>
  55. )}
  56. position={Array.isArray(pos) ? pos[0] : pos}
  57. key={index}
  58. trigger={'click'}
  59. arrowPointAtCenter={true}
  60. {...restProps}
  61. >
  62. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  63. </Popover>
  64. ))}
  65. </div>
  66. <div style={{ width: 40, marginLeft: 180 }}>
  67. {rights.map((pos, index) => (
  68. <Popover
  69. content={(
  70. <article>
  71. <p>hi bytedance</p>
  72. <p>hi bytedance</p>
  73. </article>
  74. )}
  75. position={Array.isArray(pos) ? pos[0] : pos}
  76. key={index}
  77. trigger={'click'}
  78. arrowPointAtCenter={true}
  79. {...restProps}
  80. >
  81. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  82. </Popover>
  83. ))}
  84. </div>
  85. <div style={{ marginLeft: 40, clear: 'both', whiteSpace: 'nowrap' }}>
  86. {bottoms.map((pos, index) => (
  87. <Popover
  88. content={(
  89. <article>
  90. <p>hi bytedance</p>
  91. <p>hi bytedance</p>
  92. </article>
  93. )}
  94. position={Array.isArray(pos) ? pos[0] : pos}
  95. key={index}
  96. trigger={'click'}
  97. arrowPointAtCenter={true}
  98. {...restProps}
  99. >
  100. <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
  101. </Popover>
  102. ))}
  103. </div>
  104. </div>
  105. );
  106. }
  107. function Demo() {
  108. return (
  109. <div>
  110. <div style={{ padding: 120 }}>
  111. <Item showArrow />
  112. </div>
  113. <div style={{ padding: 120 }}>
  114. <Item showArrow tagStyle={{ minHeight: 80, minWidth: 120 }} />
  115. </div>
  116. <div style={{ padding: 120 }}>
  117. <Item showArrow tagStyle={{ minHeight: 80, minWidth: 120 }} style={{ backgroundColor: 'green' }} />
  118. </div>
  119. <div style={{ padding: 120 }}>
  120. <Item
  121. showArrow
  122. tagStyle={{ minHeight: 80, minWidth: 120 }}
  123. style={{ backgroundColor: 'pink' }}
  124. content={null}
  125. />
  126. </div>
  127. <div style={{ padding: 120 }}>
  128. <Item showArrow content={null} style={{ backgroundColor: 'orange' }} />
  129. </div>
  130. </div>
  131. );
  132. }
  133. export default Demo;