Skip to content

Commit 3be7de3

Browse files
authored
Merge pull request #489 from kne-union/meetacoo-1
Meetacoo 1
2 parents 0cffc0e + 9150249 commit 3be7de3

File tree

14 files changed

+130
-154
lines changed

14 files changed

+130
-154
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ yarn-debug.log*
2323
yarn-error.log*
2424
package-lock.json
2525
.idea
26+
.codebuddy

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kne-components/components-core",
3-
"version": "0.4.8",
3+
"version": "0.4.9",
44
"files": [
55
"build"
66
],

src/components/EnumStateTag/README.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/components/EnumStateTag/doc/api.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/components/EnumStateTag/doc/example.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/components/EnumStateTag/doc/style.scss

Whitespace-only changes.

src/components/EnumStateTag/doc/summary.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/EnumStateTag/style.module.scss

Whitespace-only changes.

src/components/StateTag/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,49 @@ render(<BaseExample />);
285285

286286
```
287287

288+
- 基本示例
289+
- 枚举状态标签
290+
- _StateTag(@components/StateTag),antd(antd),global(@components/Global)
291+
292+
```jsx
293+
const { StateTagEnum } = _StateTag;
294+
const { PureGlobal } = global;
295+
const { Space } = antd;
296+
297+
const BaseExample = ()=>{
298+
return (
299+
<PureGlobal
300+
preset={{
301+
locale: "zh-CN",
302+
enums: {
303+
testEnums: async ({ locale }) => {
304+
console.log(locale);
305+
return new Promise((resolve) => {
306+
setTimeout(() => {
307+
resolve([
308+
{ value: "1", description: "第一项", type: 'success' },
309+
{ value: "2", description: "第二项", type: 'danger' },
310+
{ value: "3", description: "第三项", type: 'info'},
311+
]);
312+
}, 1000);
313+
});
314+
},
315+
},
316+
}}
317+
>
318+
<Space>
319+
<StateTagEnum moduleName="testEnums" name="1" />
320+
<StateTagEnum moduleName="testEnums" name="2" />
321+
<StateTagEnum moduleName="testEnums" name="3" />
322+
</Space>
323+
</PureGlobal>
324+
)
325+
};
326+
327+
render(<BaseExample />);
328+
329+
```
330+
288331

289332
### API
290333

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React, {useMemo} from "react";
2+
import classnames from "classnames";
3+
4+
import style from "./style.module.scss";
5+
import {Space, Tag} from "antd";
6+
7+
const tagTypeEnum = {
8+
default: "#666666",
9+
skill: {
10+
color: "#666666", borderColor: "#EEEEEE",
11+
},
12+
result: "#666666",
13+
filterResult: "#5CB8B2",
14+
success: "#027A48",
15+
progress: "#F09700",
16+
danger: "#D14343",
17+
info: "#155ACF",
18+
other: "#6740C3",
19+
};
20+
21+
const StateTag = ({
22+
showBorder = false,
23+
text = "",
24+
type = "default",
25+
showBackground = true,
26+
className,
27+
filterName,
28+
...props
29+
}) => {
30+
const tagColor = useMemo(() => ({
31+
color: tagTypeEnum?.[type]?.color || tagTypeEnum[type],
32+
borderColor: tagTypeEnum?.[type]?.borderColor || tagTypeEnum[type],
33+
}), [type]);
34+
35+
return (<Space
36+
data-testid={"components-core-state-tag"}
37+
className={classnames(style["state-tag-wrapper"], type === "filterResult" ? style["state-tag-filter-result-wrapper"] : "")}
38+
align="center"
39+
size={4}
40+
>
41+
{filterName ? (<span className={style["state-tag-filter-name"]}>{filterName}:</span>) : null}
42+
<Tag
43+
color={tagColor.color}
44+
{...props}
45+
style={{
46+
background: showBackground ? tagColor.color + "0F" : "none",
47+
color: tagColor.color,
48+
border: showBorder ? `1px solid ${tagColor.borderColor}` : "none",
49+
}}
50+
className={classnames(style["state-tag"], className, type === "result" ? style["state-result-tag"] : "", type === "skill" ? style["state-skill-tag"] : "", style[`state-tag-${type}`], showBackground ? style["show-bg"] : "", showBorder ? style["show-border"] : "", props?.onClick ? style["event-tag"] : "")}
51+
>
52+
<span className={style["tag-text"]}>{text}</span>
53+
</Tag>
54+
</Space>);
55+
};
56+
57+
export default StateTag;

0 commit comments

Comments
 (0)