badge.stories.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import React from 'react';
  2. import { Avatar, Badge } from '../../index';
  3. import { IconLock } from '@douyinfe/semi-icons';
  4. export default {
  5. title: 'Badge',
  6. }
  7. const style = {
  8. width: '42px',
  9. height: '42px',
  10. borderRadius: '4px',
  11. background: '#eee',
  12. display: 'inline-block',
  13. verticalAlign: 'middle',
  14. };
  15. export const Default = () => (
  16. <div>
  17. <Badge count={5}>
  18. <a style={style}></a>
  19. </Badge>
  20. <Badge dot>
  21. <a style={style}></a>
  22. </Badge>
  23. <Badge count={5} />
  24. <Badge dot />
  25. </div>
  26. );
  27. export const MaxCount = () => (
  28. <div>
  29. <Badge count={99}>
  30. <a style={style}></a>
  31. </Badge>
  32. <Badge count={100}>
  33. <a style={style}></a>
  34. </Badge>
  35. <Badge count={99} overflowCount={10}>
  36. <a style={style}></a>
  37. </Badge>
  38. <Badge count={1000} overflowCount={999}>
  39. <a style={style}></a>
  40. </Badge>
  41. </div>
  42. );
  43. export const Type = () => (
  44. <div style={{ marginTop: 20}}>
  45. <Badge count={5} type="primary">
  46. <a style={style}></a>
  47. </Badge>
  48. <Badge count={5} type="secondary">
  49. <a style={style}></a>
  50. </Badge>
  51. <Badge count={5} type="tertiary">
  52. <a style={style}></a>
  53. </Badge>
  54. <Badge count={5} type="warning">
  55. <a style={style}></a>
  56. </Badge>
  57. <Badge count={5} type="danger">
  58. <a style={style}></a>
  59. </Badge>
  60. <Badge dot type="primary">
  61. <a style={style}></a>
  62. </Badge>
  63. <Badge dot type="success">
  64. <a style={style}></a>
  65. </Badge>
  66. </div>
  67. );
  68. export const Theme = () => (
  69. <div>
  70. <Badge count={5} theme="solid">
  71. <a style={style}></a>
  72. </Badge>
  73. <Badge count={5} theme="light">
  74. <a style={style}></a>
  75. </Badge>
  76. <Badge count={5} theme="inverted">
  77. <a style={style}></a>
  78. </Badge>
  79. <Badge dot theme="solid">
  80. <a style={style}></a>
  81. </Badge>
  82. <Badge dot theme="light">
  83. <a style={style}></a>
  84. </Badge>
  85. <Badge dot theme="inverted">
  86. <a style={style}></a>
  87. </Badge>
  88. </div>
  89. );
  90. export const AvatarBadge = () => {
  91. const style = {
  92. width: '42px',
  93. height: '42px',
  94. borderRadius: '4px',
  95. };
  96. return (
  97. <div>
  98. <Badge count={5}>
  99. <Avatar color='blue' shape='square' style={style}>BM</Avatar>
  100. </Badge>
  101. <br/>
  102. <br/>
  103. <Badge dot>
  104. <Avatar color='blue' shape='square' style={style}>YL</Avatar>
  105. </Badge>
  106. <br/>
  107. <br/>
  108. <Badge count={<IconLock style={{color:'var(--semi-color-primary)'}}/>}>
  109. <Avatar color='light-blue' shape='square' style={style}>XZ</Avatar>
  110. </Badge>
  111. <br/>
  112. <br/>
  113. <Badge count='NEW' >
  114. <Avatar color='light-blue' shape='square' style={style}>WF</Avatar>
  115. </Badge>
  116. </div>
  117. );
  118. };
  119. AvatarBadge.storyName = '头像 badge';