badge.stories.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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>
  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. </div>
  64. );
  65. export const Theme = () => (
  66. <div>
  67. <Badge count={5} theme="solid">
  68. <a style={style}></a>
  69. </Badge>
  70. <Badge count={5} theme="light">
  71. <a style={style}></a>
  72. </Badge>
  73. <Badge count={5} theme="inverted">
  74. <a style={style}></a>
  75. </Badge>
  76. <Badge dot theme="solid">
  77. <a style={style}></a>
  78. </Badge>
  79. <Badge dot theme="light">
  80. <a style={style}></a>
  81. </Badge>
  82. <Badge dot theme="inverted">
  83. <a style={style}></a>
  84. </Badge>
  85. </div>
  86. );
  87. export const AvatarBadge = () => {
  88. const style = {
  89. width: '42px',
  90. height: '42px',
  91. borderRadius: '4px',
  92. };
  93. return (
  94. <div>
  95. <Badge count={5}>
  96. <Avatar color='blue' shape='square' style={style}>BM</Avatar>
  97. </Badge>
  98. <br/>
  99. <br/>
  100. <Badge dot>
  101. <Avatar color='blue' shape='square' style={style}>YL</Avatar>
  102. </Badge>
  103. <br/>
  104. <br/>
  105. <Badge count={<IconLock style={{color:'var(--semi-color-primary)'}}/>}>
  106. <Avatar color='light-blue' shape='square' style={style}>XZ</Avatar>
  107. </Badge>
  108. <br/>
  109. <br/>
  110. <Badge count='NEW' >
  111. <Avatar color='light-blue' shape='square' style={style}>WF</Avatar>
  112. </Badge>
  113. </div>
  114. );
  115. };
  116. AvatarBadge.storyName = '头像 badge';