Skip to content

Commit

Permalink
refactor: 优化 progress 展示
Browse files Browse the repository at this point in the history
  • Loading branch information
fikyair committed Oct 19, 2021
1 parent 750121a commit 692ae36
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 87 deletions.
21 changes: 0 additions & 21 deletions src/components/Modal/modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ import Button from "../Button";
import ModalDoc from "./modal-doc.mdx";
import Card from "../Card/card";

const BaseModal2 = (props: ModalProps) => {
const [visible2, setVisible2] = useState(false);
const [visible3, setVisible3] = useState(false);
const [visible4, setVisible4] = useState(false);
const [visible5, setVisible5] = useState(false);
const [visible6, setVisible6] = useState(false);
const [visible7, setVisible7] = useState(false);
const [visible8, setVisible8] = useState(false);
const [visible9, setVisible9] = useState(false);

return (
<>
<div style={{ marginTop: 20 }}></div>
<div style={{ marginTop: 20 }}></div>

<div style={{ marginTop: 20 }}></div>
<div style={{ marginTop: 20 }}></div>
</>
);
};

const BaseModal = () => {
const commonCss = { fontSize: 13, marginBottom: 20 };
const cardCss = { margin: "20px 20px 0 0" };
Expand Down
12 changes: 1 addition & 11 deletions src/components/Progress/progress-doc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,4 @@ import dedent from 'ts-dedent';
### 具体参数
<ArgsTable of={Progress} />

export const Template = (args) => <Progress {...args} />


### 组件展示


##### primary 类型

<Story name="default" id="progress--primary" args={{ showText: true }}>
{Template.bind({})}
</Story>
export const Template = (args) => <Progress {...args} />
140 changes: 140 additions & 0 deletions src/components/Progress/progress.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import Progress, { ProgressProps } from "./progress";
import ProgressDoc from "./progress-doc.mdx";
import Card from "../Card/card";

const BaseProgress = () => {
const commonCss = { marginBottom: 20 };
const commonCssText = { fontSize: 14, marginBottom: 20 };
const cardCss = { margin: "20px 20px 0 0", width: 500 };
return (
<div style={{ display: "flex", width: 1050, flexWrap: "wrap" }}>
<Card title="主题" style={cardCss} shadow>
<Progress
percent={30}
theme="danger"
style={commonCss}
showText={false}
/>
<Progress
percent={40}
theme="dark"
style={commonCss}
showText={false}
/>
<Progress
percent={50}
theme="info"
style={commonCss}
showText={false}
/>
<Progress
percent={60}
theme="light"
style={commonCss}
showText={false}
/>
<Progress
percent={70}
theme="primary"
style={commonCss}
showText={false}
/>
<Progress
percent={80}
theme="secondary"
style={commonCss}
showText={false}
/>
<Progress
percent={90}
theme="success"
style={commonCss}
showText={false}
/>
<Progress
percent={100}
theme="warning"
style={commonCss}
showText={false}
/>
</Card>
<Card title="展示描述" style={cardCss} shadow>
<Progress percent={30} theme="danger" style={commonCss} />
<Progress percent={40} theme="dark" style={commonCss} />
<Progress percent={50} theme="info" style={commonCss} />
<Progress percent={60} theme="light" style={commonCss} />
<Progress percent={70} theme="primary" style={commonCss} />
<Progress percent={80} theme="secondary" style={commonCss} />
<Progress percent={90} theme="success" style={commonCss} />
<Progress percent={100} theme="warning" style={commonCss} />
</Card>
<Card title="设置粗细" style={cardCss} shadow>
<div style={commonCssText}>通过 strokeHeight 来设置进度条的粗细</div>
<Progress percent={30} theme="danger" strokeHeight={10} style={commonCss} />
<Progress percent={40} theme="dark" strokeHeight={20} style={commonCss} />
<Progress percent={50} theme="info" strokeHeight={20} style={commonCss} />
<Progress percent={60} theme="light" strokeHeight={20} style={commonCss} />
<Progress percent={70} theme="primary" strokeHeight={20} style={commonCss} />
<Progress percent={80} theme="secondary" strokeHeight={20} style={commonCss} />
<Progress percent={90} theme="success" strokeHeight={20} style={commonCss} />
<Progress percent={100} theme="warning" strokeHeight={30} style={commonCss} />
</Card>
</div>
);
};

export default {
component: Progress,
title: "Progress 进度条",
parameters: {
docs: {
page: ProgressDoc,
source: {
type: "code",
},
},
controls: {
// include: ['percent', 'strokeHeight', 'showText', 'theme'],
hideNoControlsWarning: true,
},
},
argTypes: {
percent: {
control: {
type: "range",
min: 0,
max: 100,
step: 1,
},
},
theme: {
control: {
type: "select",
options: [
"primary",
"secondary",
"success",
"info",
"warning",
"danger",
"light",
"dark",
],
},
},
},
} as Meta;

const _default: Story<ProgressProps> = () => <BaseProgress />;

// primary
export const Primary = _default.bind({});

Primary.args = {
theme: "primary",
percent: 30,
strokeHeight: 10,
showText: true,
};
7 changes: 3 additions & 4 deletions src/components/Progress/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ProgressProps {
/**
* 自定义样式
*/
styles?: React.CSSProperties,
style?: React.CSSProperties,
/**
* 主题
*/
Expand All @@ -32,11 +32,11 @@ export const Progress: FC<ProgressProps> = (props) => {
percent,
strokeHeight,
showText,
styles,
style,
theme,
} = props;
return (
<div className="chocolate-progress" style={styles}>
<div className="chocolate-progress" style={style}>
<div className={sc("bar-outer")} style={{ height: `${strokeHeight}px` }}>
<div
className={`${sc("bar-inner")} color-${theme}`}
Expand All @@ -54,7 +54,6 @@ Progress.defaultProps = {
showText: true,
theme: "primary",
percent: 0,
styles: {}
}

export default Progress;
51 changes: 0 additions & 51 deletions src/components/Progress/select.stories.tsx

This file was deleted.

0 comments on commit 692ae36

Please sign in to comment.