tango-ui-cw 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +889 -757
- package/package.json +1 -1
- package/src/component/CSSFab/useTangoStyle.jsx +182 -182
- package/src/component/MaterialButton/{MaterialButton.css → MaterialButton.module.css} +64 -64
- package/src/component/MaterialButton/index.jsx +69 -58
- package/src/component/MaterialInput/{MaterialInput.css → MaterialInput.module.css} +37 -33
- package/src/component/MaterialInput/index.jsx +34 -29
- package/src/component/TButton/TButton.module.css +184 -0
- package/src/component/TButton/index.jsx +81 -74
- package/src/component/TColorPicker/{TColorPicker.css → TColorPicker.module.css} +24 -24
- package/src/component/TColorPicker/index.jsx +107 -106
- package/src/component/TDate/index.jsx +146 -148
- package/src/component/TDatePicker/TDatePicker.module.css +12 -0
- package/src/component/TDatePicker/index.jsx +72 -72
- package/src/component/TDrawer/{TDrawer.css → TDrawer.module.css} +203 -202
- package/src/component/TDrawer/index.jsx +80 -74
- package/src/component/TInput/{TInput.css → TInput.module.css} +67 -80
- package/src/component/TInput/index.jsx +95 -102
- package/src/component/TLayout/TLayout.css +88 -88
- package/src/component/TLayout/index.jsx +77 -77
- package/src/component/TLine/TLine.module.css +52 -0
- package/src/component/TLine/index.jsx +48 -57
- package/src/component/TMark/{TMark.css → TMark.module.css} +6 -6
- package/src/component/TMark/index.jsx +69 -78
- package/src/component/TModal/{TModal.css → TModal.module.css} +109 -108
- package/src/component/TModal/index.jsx +75 -69
- package/src/component/TNotice/{TNotice.css → TNotice.module.css} +50 -52
- package/src/component/TNotice/index.jsx +37 -38
- package/src/component/TNotice/useNotice.jsx +54 -54
- package/src/component/TSearch/{TSearch.css → TSearch.module.css} +80 -90
- package/src/component/TSearch/index.jsx +86 -100
- package/src/component/TSpace/TSpace.module.css +43 -0
- package/src/component/TSpace/index.jsx +60 -60
- package/src/component/TTable/{TTable.css → TTable.module.css} +26 -26
- package/src/component/TTable/index.jsx +73 -77
- package/src/component/TTooltip/TTooltip.module.css +66 -0
- package/src/component/TTooltip/index.jsx +33 -25
- package/src/component/Tango/store.js +105 -105
- package/src/component/Tools/WaterMark/WaterMark.jsx +78 -78
- package/src/component/TButton/TButton.css +0 -270
- package/src/component/TDate/TDate.css +0 -0
- package/src/component/TDatePicker/TDatePicker.css +0 -13
- package/src/component/TLine/TLine.css +0 -54
- package/src/component/TSpace/TSpace.css +0 -43
- package/src/component/TTooltip/TTooltip.css +0 -105
@@ -1,88 +1,88 @@
|
|
1
|
-
/* 公共样式 */
|
2
|
-
html,
|
3
|
-
body {
|
4
|
-
height: 100%;
|
5
|
-
margin: 0;
|
6
|
-
padding: 0;
|
7
|
-
box-sizing: border-box;
|
8
|
-
}
|
9
|
-
|
10
|
-
.ultra {
|
11
|
-
display: flex;
|
12
|
-
flex-direction: column;
|
13
|
-
width: 100%;
|
14
|
-
height: 100%;
|
15
|
-
background-color: #f0f2f5;
|
16
|
-
border-radius: 8px;
|
17
|
-
overflow: hidden;
|
18
|
-
}
|
19
|
-
|
20
|
-
.clay-header {
|
21
|
-
background-color: #96d498;
|
22
|
-
color: #fff;
|
23
|
-
text-align: center;
|
24
|
-
height: 64px;
|
25
|
-
line-height: 64px;
|
26
|
-
}
|
27
|
-
|
28
|
-
.clay-main {
|
29
|
-
display: flex;
|
30
|
-
flex: 1; /* 占据剩余高度 */
|
31
|
-
width: 100%; /* 确保子元素水平分布 */
|
32
|
-
min-height: 120px;
|
33
|
-
display: flex;
|
34
|
-
align-items: center;
|
35
|
-
justify-content: center;
|
36
|
-
background-color: #4caf50;
|
37
|
-
color: #fff;
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
.clay-aside {
|
42
|
-
background-color: #6ccb6f;
|
43
|
-
color: #fff;
|
44
|
-
text-align: center;
|
45
|
-
padding: 16px;
|
46
|
-
min-width: 120px;
|
47
|
-
min-height: 120px;
|
48
|
-
display: flex;
|
49
|
-
align-items: center;
|
50
|
-
justify-content: center;
|
51
|
-
}
|
52
|
-
|
53
|
-
.clay-right {
|
54
|
-
flex: 3;
|
55
|
-
display: flex;
|
56
|
-
flex-direction: column; /* 确保右侧是上下布局 */
|
57
|
-
}
|
58
|
-
|
59
|
-
.clay-content {
|
60
|
-
background-color: #4caf50;
|
61
|
-
color: #fff;
|
62
|
-
flex: 1;
|
63
|
-
text-align: center;
|
64
|
-
padding: 16px;
|
65
|
-
min-height: 120px;
|
66
|
-
display: flex;
|
67
|
-
align-items: center;
|
68
|
-
justify-content: center;
|
69
|
-
|
70
|
-
}
|
71
|
-
|
72
|
-
.clay-footer {
|
73
|
-
background-color: #96d498;
|
74
|
-
color: #fff;
|
75
|
-
text-align: center;
|
76
|
-
height: 64px;
|
77
|
-
line-height: 64px;
|
78
|
-
}
|
79
|
-
|
80
|
-
/* 支持自适应布局 */
|
81
|
-
@media (max-width: 768px) {
|
82
|
-
.ultra {
|
83
|
-
flex-direction: column;
|
84
|
-
}
|
85
|
-
.clay-main {
|
86
|
-
flex-direction: column; /* 主内容区域改为竖向排列 */
|
87
|
-
}
|
88
|
-
}
|
1
|
+
/* 公共样式 */
|
2
|
+
html,
|
3
|
+
body {
|
4
|
+
height: 100%;
|
5
|
+
margin: 0;
|
6
|
+
padding: 0;
|
7
|
+
box-sizing: border-box;
|
8
|
+
}
|
9
|
+
|
10
|
+
.ultra {
|
11
|
+
display: flex;
|
12
|
+
flex-direction: column;
|
13
|
+
width: 100%;
|
14
|
+
height: 100%;
|
15
|
+
background-color: #f0f2f5;
|
16
|
+
border-radius: 8px;
|
17
|
+
overflow: hidden;
|
18
|
+
}
|
19
|
+
|
20
|
+
.clay-header {
|
21
|
+
background-color: #96d498;
|
22
|
+
color: #fff;
|
23
|
+
text-align: center;
|
24
|
+
height: 64px;
|
25
|
+
line-height: 64px;
|
26
|
+
}
|
27
|
+
|
28
|
+
.clay-main {
|
29
|
+
display: flex;
|
30
|
+
flex: 1; /* 占据剩余高度 */
|
31
|
+
width: 100%; /* 确保子元素水平分布 */
|
32
|
+
min-height: 120px;
|
33
|
+
display: flex;
|
34
|
+
align-items: center;
|
35
|
+
justify-content: center;
|
36
|
+
background-color: #4caf50;
|
37
|
+
color: #fff;
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
.clay-aside {
|
42
|
+
background-color: #6ccb6f;
|
43
|
+
color: #fff;
|
44
|
+
text-align: center;
|
45
|
+
padding: 16px;
|
46
|
+
min-width: 120px;
|
47
|
+
min-height: 120px;
|
48
|
+
display: flex;
|
49
|
+
align-items: center;
|
50
|
+
justify-content: center;
|
51
|
+
}
|
52
|
+
|
53
|
+
.clay-right {
|
54
|
+
flex: 3;
|
55
|
+
display: flex;
|
56
|
+
flex-direction: column; /* 确保右侧是上下布局 */
|
57
|
+
}
|
58
|
+
|
59
|
+
.clay-content {
|
60
|
+
background-color: #4caf50;
|
61
|
+
color: #fff;
|
62
|
+
flex: 1;
|
63
|
+
text-align: center;
|
64
|
+
padding: 16px;
|
65
|
+
min-height: 120px;
|
66
|
+
display: flex;
|
67
|
+
align-items: center;
|
68
|
+
justify-content: center;
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
.clay-footer {
|
73
|
+
background-color: #96d498;
|
74
|
+
color: #fff;
|
75
|
+
text-align: center;
|
76
|
+
height: 64px;
|
77
|
+
line-height: 64px;
|
78
|
+
}
|
79
|
+
|
80
|
+
/* 支持自适应布局 */
|
81
|
+
@media (max-width: 768px) {
|
82
|
+
.ultra {
|
83
|
+
flex-direction: column;
|
84
|
+
}
|
85
|
+
.clay-main {
|
86
|
+
flex-direction: column; /* 主内容区域改为竖向排列 */
|
87
|
+
}
|
88
|
+
}
|
@@ -1,77 +1,77 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import PropTypes from "prop-types";
|
3
|
-
import "./TLayout.css";
|
4
|
-
|
5
|
-
// 定义基本组件
|
6
|
-
export const Header = ({ children }) => <header>{children}</header>;
|
7
|
-
export const Aside = ({ children }) => <aside>{children}</aside>;
|
8
|
-
export const Content = ({ children }) => <div>{children}</div>;
|
9
|
-
export const Footer = ({ children }) => <footer>{children}</footer>;
|
10
|
-
|
11
|
-
export default function Layout(props) {
|
12
|
-
const { children, type, className: userClassName = "" } = props;
|
13
|
-
const className = `clay-layout clay-layout-${type} ${userClassName}`;
|
14
|
-
|
15
|
-
return (
|
16
|
-
<div className={className}>
|
17
|
-
{/* 第一种:上中下布局 */}
|
18
|
-
{type === "top-middle-bottom" && (
|
19
|
-
<div className="ultra">
|
20
|
-
<header className="clay-header">{children[0]}</header>
|
21
|
-
<main className="clay-main">{children[1]}</main>
|
22
|
-
<footer className="clay-footer">{children[2]}</footer>
|
23
|
-
</div>
|
24
|
-
)}
|
25
|
-
|
26
|
-
{/* 第二种:上下布局,下部分是左右布局 */}
|
27
|
-
{type === "top-bottom-split" && (
|
28
|
-
<div className="ultra">
|
29
|
-
<header className="clay-header">{children[0]}</header>
|
30
|
-
<main className="clay-main">
|
31
|
-
<aside className="clay-aside">{children[1]}</aside>
|
32
|
-
<div className="clay-content">{children[2]}</div>
|
33
|
-
</main>
|
34
|
-
</div>
|
35
|
-
)}
|
36
|
-
|
37
|
-
{/* 第三种:左右布局,右侧分为上下布局 */}
|
38
|
-
{type === "left-right-top-bottom" && (
|
39
|
-
<>
|
40
|
-
<header className="clay-header">{children[0]}</header>
|
41
|
-
<div className="clay-main">
|
42
|
-
<aside className="clay-aside">{children[1]}</aside>
|
43
|
-
<div className="clay-right">
|
44
|
-
<header className="clay-header">{children[2]}</header>
|
45
|
-
<div className="clay-content">{children[3]}</div>
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
</>
|
49
|
-
)}
|
50
|
-
|
51
|
-
{/* 第四种:左右布局,右侧分为上中下布局 */}
|
52
|
-
{type === "left-right-three-parts" && (
|
53
|
-
<div className="ultra">
|
54
|
-
<aside className="clay-aside">{children[0]}</aside>
|
55
|
-
<div className="clay-right">
|
56
|
-
<header className="clay-header">{children[1]}</header>
|
57
|
-
<main className="clay-main">{children[2]}</main>
|
58
|
-
<footer className="clay-footer">{children[3]}</footer>
|
59
|
-
</div>
|
60
|
-
</div>
|
61
|
-
)}
|
62
|
-
</div>
|
63
|
-
);
|
64
|
-
};
|
65
|
-
|
66
|
-
Layout.propTypes = {
|
67
|
-
children: PropTypes.node.isRequired,
|
68
|
-
className: PropTypes.string, // 添加 className PropTypes
|
69
|
-
|
70
|
-
type: PropTypes.oneOf([
|
71
|
-
"top-middle-bottom",
|
72
|
-
"top-bottom-split",
|
73
|
-
"left-right-top-bottom",
|
74
|
-
"left-right-three-parts",
|
75
|
-
]).isRequired,
|
76
|
-
};
|
77
|
-
|
1
|
+
import React from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import "./TLayout.css";
|
4
|
+
|
5
|
+
// 定义基本组件
|
6
|
+
export const Header = ({ children }) => <header>{children}</header>;
|
7
|
+
export const Aside = ({ children }) => <aside>{children}</aside>;
|
8
|
+
export const Content = ({ children }) => <div>{children}</div>;
|
9
|
+
export const Footer = ({ children }) => <footer>{children}</footer>;
|
10
|
+
|
11
|
+
export default function Layout(props) {
|
12
|
+
const { children, type, className: userClassName = "" } = props;
|
13
|
+
const className = `clay-layout clay-layout-${type} ${userClassName}`;
|
14
|
+
|
15
|
+
return (
|
16
|
+
<div className={className}>
|
17
|
+
{/* 第一种:上中下布局 */}
|
18
|
+
{type === "top-middle-bottom" && (
|
19
|
+
<div className="ultra">
|
20
|
+
<header className="clay-header">{children[0]}</header>
|
21
|
+
<main className="clay-main">{children[1]}</main>
|
22
|
+
<footer className="clay-footer">{children[2]}</footer>
|
23
|
+
</div>
|
24
|
+
)}
|
25
|
+
|
26
|
+
{/* 第二种:上下布局,下部分是左右布局 */}
|
27
|
+
{type === "top-bottom-split" && (
|
28
|
+
<div className="ultra">
|
29
|
+
<header className="clay-header">{children[0]}</header>
|
30
|
+
<main className="clay-main">
|
31
|
+
<aside className="clay-aside">{children[1]}</aside>
|
32
|
+
<div className="clay-content">{children[2]}</div>
|
33
|
+
</main>
|
34
|
+
</div>
|
35
|
+
)}
|
36
|
+
|
37
|
+
{/* 第三种:左右布局,右侧分为上下布局 */}
|
38
|
+
{type === "left-right-top-bottom" && (
|
39
|
+
<>
|
40
|
+
<header className="clay-header">{children[0]}</header>
|
41
|
+
<div className="clay-main">
|
42
|
+
<aside className="clay-aside">{children[1]}</aside>
|
43
|
+
<div className="clay-right">
|
44
|
+
<header className="clay-header">{children[2]}</header>
|
45
|
+
<div className="clay-content">{children[3]}</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
</>
|
49
|
+
)}
|
50
|
+
|
51
|
+
{/* 第四种:左右布局,右侧分为上中下布局 */}
|
52
|
+
{type === "left-right-three-parts" && (
|
53
|
+
<div className="ultra">
|
54
|
+
<aside className="clay-aside">{children[0]}</aside>
|
55
|
+
<div className="clay-right">
|
56
|
+
<header className="clay-header">{children[1]}</header>
|
57
|
+
<main className="clay-main">{children[2]}</main>
|
58
|
+
<footer className="clay-footer">{children[3]}</footer>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
)}
|
62
|
+
</div>
|
63
|
+
);
|
64
|
+
};
|
65
|
+
|
66
|
+
Layout.propTypes = {
|
67
|
+
children: PropTypes.node.isRequired,
|
68
|
+
className: PropTypes.string, // 添加 className PropTypes
|
69
|
+
|
70
|
+
type: PropTypes.oneOf([
|
71
|
+
"top-middle-bottom",
|
72
|
+
"top-bottom-split",
|
73
|
+
"left-right-top-bottom",
|
74
|
+
"left-right-three-parts",
|
75
|
+
]).isRequired,
|
76
|
+
};
|
77
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
.line {
|
2
|
+
display: flex;
|
3
|
+
align-items: center;
|
4
|
+
justify-content: center;
|
5
|
+
position: relative;
|
6
|
+
width: 100%;
|
7
|
+
}
|
8
|
+
|
9
|
+
.lineSmall {
|
10
|
+
margin: 2px 0;
|
11
|
+
}
|
12
|
+
|
13
|
+
.lineMedium {
|
14
|
+
margin: 6px 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.lineLarge {
|
18
|
+
margin: 10px 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.lineHuge {
|
22
|
+
margin: 15px 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
.line::before,
|
26
|
+
.line::after {
|
27
|
+
content: "";
|
28
|
+
flex: 1;
|
29
|
+
height: 1px;
|
30
|
+
background-color: #b2b2b2;
|
31
|
+
}
|
32
|
+
|
33
|
+
.line::before {
|
34
|
+
margin-right: 10px;
|
35
|
+
}
|
36
|
+
|
37
|
+
.line::after {
|
38
|
+
margin-left: 10px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.lineNoText::before,
|
42
|
+
.lineNoText::after {
|
43
|
+
margin: 0;
|
44
|
+
}
|
45
|
+
|
46
|
+
.lineText {
|
47
|
+
padding: 0 5px;
|
48
|
+
color: inherit;
|
49
|
+
background-color: transparent;
|
50
|
+
white-space: nowrap;
|
51
|
+
z-index: 1;
|
52
|
+
}
|
@@ -1,57 +1,48 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
const
|
19
|
-
|
20
|
-
} ${userClassName}
|
21
|
-
|
22
|
-
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
style={combinedStyle} // 应用合并后的内联样式
|
50
|
-
onClick={onClick}
|
51
|
-
className={className}
|
52
|
-
>
|
53
|
-
{children && <div className="line-text">{children}</div>}
|
54
|
-
</div>
|
55
|
-
);
|
56
|
-
};
|
57
|
-
|
1
|
+
import React from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import styles from "./TLine.module.css"; // 使用 CSS Modules
|
4
|
+
import { useTangoStyle } from "../CSSFab/useTangoStyle";
|
5
|
+
|
6
|
+
export default function Line(props) {
|
7
|
+
// 接收属性参数,调整Space样式
|
8
|
+
const {
|
9
|
+
sx = {},
|
10
|
+
style: userStyle = {},
|
11
|
+
className: userClassName = "",
|
12
|
+
onClick,
|
13
|
+
children,
|
14
|
+
size = "medium",
|
15
|
+
} = props;
|
16
|
+
|
17
|
+
const hasText = !!children;
|
18
|
+
const sizeClass = styles[`line${size.charAt(0).toUpperCase() + size.slice(1)}`] || "";
|
19
|
+
const textClass = hasText ? styles.lineHasText : styles.lineNoText;
|
20
|
+
const combinedClassName = `${styles.line} ${sizeClass} ${textClass} ${userClassName}`.trim();
|
21
|
+
|
22
|
+
const sxStyle = useTangoStyle(sx);
|
23
|
+
const combinedStyle = { ...sxStyle, ...userStyle };
|
24
|
+
|
25
|
+
return (
|
26
|
+
<div style={combinedStyle} onClick={onClick} className={combinedClassName}>
|
27
|
+
{hasText && <div className={styles.lineText}>{children}</div>}
|
28
|
+
</div>
|
29
|
+
);
|
30
|
+
};
|
31
|
+
|
32
|
+
TLine.propTypes = {
|
33
|
+
sx: PropTypes.object,
|
34
|
+
size: PropTypes.oneOf(["small", "medium", "large", "huge"]),
|
35
|
+
style: PropTypes.object,
|
36
|
+
onClick: PropTypes.func,
|
37
|
+
className: PropTypes.string,
|
38
|
+
children: PropTypes.node.isRequired,
|
39
|
+
};
|
40
|
+
|
41
|
+
TLine.defaultProps = {
|
42
|
+
sx: {},
|
43
|
+
size: "medium",
|
44
|
+
style: {},
|
45
|
+
onClick: () => {},
|
46
|
+
className: "",
|
47
|
+
};
|
48
|
+
|
@@ -1,6 +1,6 @@
|
|
1
|
-
.mark {
|
2
|
-
width: auto;
|
3
|
-
height: auto;
|
4
|
-
display: inline-block;
|
5
|
-
|
6
|
-
}
|
1
|
+
.mark {
|
2
|
+
width: auto;
|
3
|
+
height: auto;
|
4
|
+
display: inline-block;
|
5
|
+
|
6
|
+
}
|
@@ -1,78 +1,69 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import PropTypes from "prop-types";
|
3
|
-
import "./TMark.css"; //
|
4
|
-
import { useTangoStyle } from "../CSSFab/useTangoStyle";
|
5
|
-
|
6
|
-
export default function Mark(props) {
|
7
|
-
const {
|
8
|
-
sx = {},
|
9
|
-
style: userStyle = {},
|
10
|
-
className: userClassName = "",
|
11
|
-
onClick,
|
12
|
-
children,
|
13
|
-
color = "default",
|
14
|
-
beauty = false, // 是否使用新样式
|
15
|
-
} = props;
|
16
|
-
|
17
|
-
|
18
|
-
const
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
Mark.defaultProps = {
|
71
|
-
color: "default",
|
72
|
-
sx: {},
|
73
|
-
style: {},
|
74
|
-
onClick: () => {},
|
75
|
-
className: "",
|
76
|
-
beauty: false,
|
77
|
-
};
|
78
|
-
|
1
|
+
import React from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import styles from "./TMark.module.css"; // 使用 CSS Modules
|
4
|
+
import { useTangoStyle } from "../CSSFab/useTangoStyle";
|
5
|
+
|
6
|
+
export default function Mark(props) {
|
7
|
+
const {
|
8
|
+
sx = {},
|
9
|
+
style: userStyle = {},
|
10
|
+
className: userClassName = "",
|
11
|
+
onClick,
|
12
|
+
children,
|
13
|
+
color = "default",
|
14
|
+
beauty = false, // 是否使用新样式
|
15
|
+
} = props;
|
16
|
+
const sxStyle = useTangoStyle(sx);
|
17
|
+
|
18
|
+
const backgroundColor = color === "default" ? "#ffe28d" : color;
|
19
|
+
|
20
|
+
const defaultStyle = {
|
21
|
+
width: "auto",
|
22
|
+
height: "auto",
|
23
|
+
display: "inline-block",
|
24
|
+
};
|
25
|
+
|
26
|
+
const newStyle = beauty
|
27
|
+
? {
|
28
|
+
padding: "4px 8px",
|
29
|
+
borderRadius: "4px",
|
30
|
+
}
|
31
|
+
: {};
|
32
|
+
|
33
|
+
const combinedStyle = {
|
34
|
+
backgroundColor,
|
35
|
+
...defaultStyle,
|
36
|
+
...newStyle,
|
37
|
+
...sxStyle,
|
38
|
+
...userStyle,
|
39
|
+
};
|
40
|
+
|
41
|
+
return (
|
42
|
+
<div
|
43
|
+
style={combinedStyle}
|
44
|
+
onClick={onClick}
|
45
|
+
className={`${styles.mark} ${userClassName}`}
|
46
|
+
>
|
47
|
+
{children}
|
48
|
+
</div>
|
49
|
+
);
|
50
|
+
};
|
51
|
+
|
52
|
+
TMark.propTypes = {
|
53
|
+
color: PropTypes.string,
|
54
|
+
sx: PropTypes.object,
|
55
|
+
style: PropTypes.object,
|
56
|
+
onClick: PropTypes.func,
|
57
|
+
className: PropTypes.string,
|
58
|
+
children: PropTypes.node.isRequired,
|
59
|
+
beauty: PropTypes.bool,
|
60
|
+
};
|
61
|
+
|
62
|
+
TMark.defaultProps = {
|
63
|
+
color: "default",
|
64
|
+
sx: {},
|
65
|
+
style: {},
|
66
|
+
onClick: () => {},
|
67
|
+
className: "",
|
68
|
+
beauty: false,
|
69
|
+
};
|