Progress进度条 - 图1

Progress 进度条

基本用法

  1. import { Progress, Cell, Select, Radio, Stepper } from 'zarm';
  2. class Demo extends React.Component {
  3. state = {
  4. percent: 10,
  5. theme: 'primary',
  6. strokeShape: 'round',
  7. strokeWidth: '',
  8. };
  9. render() {
  10. const { percent, theme, strokeShape, strokeWidth } = this.state;
  11. return (
  12. <>
  13. <div className="progress">
  14. <Progress
  15. shape="line"
  16. percent={percent}
  17. theme={theme}
  18. strokeShape={strokeShape}
  19. strokeWidth={strokeWidth}
  20. />
  21. </div>
  22. <div className="progress">
  23. <Progress
  24. shape="circle"
  25. percent={percent}
  26. theme={theme}
  27. strokeShape={strokeShape}
  28. strokeWidth={strokeWidth}
  29. text={(percent) => (
  30. <div className="progress-content">
  31. <span className="progress-text">{percent}</span>
  32. <span className="progress-percent">%</span>
  33. </div>
  34. )}
  35. />
  36. </div>
  37. <div className="progress">
  38. <Progress
  39. shape="semi-circle"
  40. percent={percent}
  41. theme={theme}
  42. strokeShape={strokeShape}
  43. strokeWidth={strokeWidth}
  44. text={(percent) => (
  45. <div className="progress-content">
  46. <span className="progress-text">{percent}</span>
  47. <span className="progress-percent">%</span>
  48. </div>
  49. )}
  50. />
  51. </div>
  52. <Cell title="进度">
  53. <Stepper
  54. step={10}
  55. min={0}
  56. max={100}
  57. value={percent}
  58. onChange={(value) => {
  59. if (Number.isNaN(Number(value))) return;
  60. this.setState({
  61. percent: value,
  62. });
  63. }}
  64. />
  65. </Cell>
  66. <Cell title="主题">
  67. <Select
  68. value={theme}
  69. dataSource={[
  70. { value: 'primary', label: 'primary' },
  71. { value: 'success', label: 'success' },
  72. { value: 'warning', label: 'warning' },
  73. { value: 'danger', label: 'danger' },
  74. ]}
  75. onOk={(selected) => {
  76. this.setState({
  77. theme: selected[0].value,
  78. });
  79. }}
  80. />
  81. </Cell>
  82. <Cell title="线条形状">
  83. <Radio.Group
  84. compact
  85. type="button"
  86. value={strokeShape}
  87. onChange={(value) => {
  88. this.setState({
  89. strokeShape: value,
  90. });
  91. }}>
  92. <Radio value="round">round</Radio>
  93. <Radio value="rect">rect</Radio>
  94. </Radio.Group>
  95. </Cell>
  96. <Cell title="线条粗细">
  97. <Stepper
  98. step={1}
  99. min={0}
  100. value={strokeWidth}
  101. onChange={(value) => {
  102. if (Number.isNaN(Number(value))) return;
  103. this.setState({
  104. strokeWidth: value,
  105. });
  106. }}
  107. />
  108. </Cell>
  109. </>
  110. )
  111. }
  112. }
  113. ReactDOM.render(<Demo />, mountNode);

API

属性类型默认值说明
themestring'primary'主题,可选值 primary, success, warning, danger
sizestring'md'大小,可选值 lg, md, sm,number类型的值,或者任何合法的css宽度值
shapestring'line'形状,可选值 line, circle, semi-circle
percentnumber0进度百分比(范围:0~100)
text(percent?: number) => ReactNode(percent) => ${percent}%进度文本显示
strokeShapestring'round'线条形状,可选值 round, rect
strokeWidthnumber-线条粗细,单位: px,不设置则根据大小自动调整