tango-ui-cw 0.0.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/README.md +1 -0
- package/dist/index.js +30 -0
- package/dist/index.mjs +661 -0
- package/package.json +37 -0
- package/src/component/CSSFab/useTangoStyle.jsx +182 -0
- package/src/component/MaterialButton/MaterialButton.css +64 -0
- package/src/component/MaterialButton/index.jsx +58 -0
- package/src/component/MaterialInput/MaterialInput.css +33 -0
- package/src/component/MaterialInput/index.jsx +29 -0
- package/src/component/TButton/TButton.css +270 -0
- package/src/component/TButton/index.jsx +74 -0
- package/src/component/TColorPicker/TColorPicker.css +24 -0
- package/src/component/TColorPicker/index.jsx +106 -0
- package/src/component/TDate/TDate.css +0 -0
- package/src/component/TDate/index.jsx +148 -0
- package/src/component/TDatePicker/TDatePicker.css +13 -0
- package/src/component/TDatePicker/index.jsx +60 -0
- package/src/component/TDrawer/TDrawer.css +202 -0
- package/src/component/TDrawer/index.jsx +74 -0
- package/src/component/TInput/TInput.css +80 -0
- package/src/component/TInput/index.jsx +102 -0
- package/src/component/TLayout/TLayout.css +88 -0
- package/src/component/TLayout/index.jsx +77 -0
- package/src/component/TLine/TLine.css +54 -0
- package/src/component/TLine/index.jsx +57 -0
- package/src/component/TMark/TMark.css +6 -0
- package/src/component/TMark/index.jsx +78 -0
- package/src/component/TModal/TModal.css +108 -0
- package/src/component/TModal/index.jsx +69 -0
- package/src/component/TNotice/TNotice.css +52 -0
- package/src/component/TNotice/index.jsx +38 -0
- package/src/component/TNotice/useNotice.jsx +54 -0
- package/src/component/TSearch/TSearch.css +90 -0
- package/src/component/TSearch/index.jsx +100 -0
- package/src/component/TSpace/TSpace.css +43 -0
- package/src/component/TSpace/index.jsx +60 -0
- package/src/component/TTable/TTable.css +26 -0
- package/src/component/TTable/index.jsx +77 -0
- package/src/component/TTooltip/TTooltip.css +105 -0
- package/src/component/TTooltip/index.jsx +25 -0
- package/src/component/Tango/store.js +105 -0
- package/src/component/Tools/WaterMark/WaterMark.jsx +78 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
.color-picker {
|
2
|
+
width: 35px;
|
3
|
+
height: 35px;
|
4
|
+
/* border-radius:10px; */
|
5
|
+
padding: 0px 1px;
|
6
|
+
background: white;
|
7
|
+
}
|
8
|
+
|
9
|
+
.color-picker-disabled {
|
10
|
+
cursor: not-allowed;
|
11
|
+
}
|
12
|
+
|
13
|
+
.color-picker-wrapper {
|
14
|
+
display: flex;
|
15
|
+
align-items: center;
|
16
|
+
gap: 10px;
|
17
|
+
}
|
18
|
+
|
19
|
+
.color-text {
|
20
|
+
display: flex;
|
21
|
+
flex-direction: column;
|
22
|
+
font-size: 12px;
|
23
|
+
color: #555;
|
24
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
// 封装的 ColorPicker 组件
|
2
|
+
import React, { useState } from "react";
|
3
|
+
import PropTypes from "prop-types";
|
4
|
+
import "./TColorPicker.css";
|
5
|
+
import { useTangoStyle } from "../CSSFab/useTangoStyle";
|
6
|
+
|
7
|
+
export default function ColorPicker(props) {
|
8
|
+
const {
|
9
|
+
sx = {},
|
10
|
+
style: userStyle = {},
|
11
|
+
className: userClassName = "",
|
12
|
+
disabled,
|
13
|
+
onChange,
|
14
|
+
showText
|
15
|
+
} = props;
|
16
|
+
|
17
|
+
const [color, setColor] = useState("#4caf50");
|
18
|
+
|
19
|
+
const handleChange = (e) => {
|
20
|
+
const value = e.target.value;
|
21
|
+
setColor(value);
|
22
|
+
if (onChange) onChange(value);
|
23
|
+
};
|
24
|
+
|
25
|
+
const className = `color-picker ${disabled ? "color-picker-disabled" : ""} ${userClassName}`;
|
26
|
+
|
27
|
+
const sxStyle = useTangoStyle(sx);
|
28
|
+
const combinedStyle = { ...sxStyle, ...userStyle };
|
29
|
+
|
30
|
+
ColorPicker.propTypes = {
|
31
|
+
sx: PropTypes.object,
|
32
|
+
style: PropTypes.object,
|
33
|
+
className: PropTypes.string,
|
34
|
+
disabled: PropTypes.bool,
|
35
|
+
onChange: PropTypes.func,
|
36
|
+
showText: PropTypes.bool,
|
37
|
+
};
|
38
|
+
|
39
|
+
ColorPicker.defaultProps = {
|
40
|
+
sx: {},
|
41
|
+
style: {},
|
42
|
+
className: "",
|
43
|
+
disabled: false,
|
44
|
+
onChange: () => {},
|
45
|
+
showText: false,
|
46
|
+
};
|
47
|
+
|
48
|
+
const hexToRgb = (hex) => {
|
49
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
50
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
51
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
52
|
+
return `rgb(${r}, ${g}, ${b})`;
|
53
|
+
};
|
54
|
+
|
55
|
+
const hexToHsl = (hex) => {
|
56
|
+
let r = parseInt(hex.slice(1, 3), 16) / 255;
|
57
|
+
let g = parseInt(hex.slice(3, 5), 16) / 255;
|
58
|
+
let b = parseInt(hex.slice(5, 7), 16) / 255;
|
59
|
+
let max = Math.max(r, g, b),
|
60
|
+
min = Math.min(r, g, b);
|
61
|
+
let h, s, l = (max + min) / 2;
|
62
|
+
|
63
|
+
if (max === min) {
|
64
|
+
h = s = 0; // achromatic
|
65
|
+
} else {
|
66
|
+
let d = max - min;
|
67
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
68
|
+
switch (max) {
|
69
|
+
case r:
|
70
|
+
h = ((g - b) / d + (g < b ? 6 : 0));
|
71
|
+
break;
|
72
|
+
case g:
|
73
|
+
h = ((b - r) / d + 2);
|
74
|
+
break;
|
75
|
+
case b:
|
76
|
+
h = ((r - g) / d + 4);
|
77
|
+
break;
|
78
|
+
}
|
79
|
+
h /= 6;
|
80
|
+
}
|
81
|
+
|
82
|
+
return `hsl(${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%)`;
|
83
|
+
};
|
84
|
+
|
85
|
+
|
86
|
+
return (
|
87
|
+
<div className="color-picker-wrapper" style={combinedStyle}>
|
88
|
+
<input
|
89
|
+
type="color"
|
90
|
+
value={color}
|
91
|
+
onChange={handleChange}
|
92
|
+
className={className}
|
93
|
+
disabled={disabled}
|
94
|
+
/>
|
95
|
+
{showText && (
|
96
|
+
<div className="color-text">
|
97
|
+
<div>{color.toUpperCase()}</div>
|
98
|
+
<div>{hexToRgb(color)}</div>
|
99
|
+
<div>{hexToHsl(color)}</div>
|
100
|
+
</div>
|
101
|
+
)}
|
102
|
+
</div>
|
103
|
+
);
|
104
|
+
|
105
|
+
};
|
106
|
+
|
File without changes
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import "./TDate.css";
|
4
|
+
import { useTangoStyle } from "../CSSFab/useTangoStyle"; // 导入 useFastStyle 函数
|
5
|
+
|
6
|
+
export default function Date(props) {
|
7
|
+
const { type, single, sx = {}, style: userStyle = {}, en } = props;
|
8
|
+
|
9
|
+
// 用于接收 sx 属性设置的样式
|
10
|
+
const sxStyle = useTangoStyle(sx);
|
11
|
+
|
12
|
+
// 合并 sx 和 style,确保 style 优先级更高
|
13
|
+
const combinedStyle = { ...sxStyle, ...userStyle };
|
14
|
+
|
15
|
+
Date.propTypes = {
|
16
|
+
type: PropTypes.oneOf([
|
17
|
+
"line",
|
18
|
+
"full",
|
19
|
+
"full-line",
|
20
|
+
"year-week",
|
21
|
+
"year-week-line",
|
22
|
+
"week-time",
|
23
|
+
"no-s",
|
24
|
+
"no-s-line",
|
25
|
+
"us-full",
|
26
|
+
"us-full-line",
|
27
|
+
]),
|
28
|
+
single: PropTypes.bool, // 控制显示“周”或“星期”
|
29
|
+
sx: PropTypes.object, // 自定义样式对象
|
30
|
+
style: PropTypes.object, // 用户传入的 style 属性
|
31
|
+
en: PropTypes.bool, // 控制英文格式
|
32
|
+
};
|
33
|
+
|
34
|
+
Date.defaultProps = {
|
35
|
+
type: undefined, // 默认无 type 的格式
|
36
|
+
single: false, // 默认显示 "星期"
|
37
|
+
sx: {},
|
38
|
+
style: {},
|
39
|
+
en: false, // 默认不使用英文
|
40
|
+
};
|
41
|
+
|
42
|
+
// 各类时间格式
|
43
|
+
const formatDate = (type) => {
|
44
|
+
const date = new Date();
|
45
|
+
let locale = en ? "en-US" : "zh-CN";
|
46
|
+
let formattedWeekday = date.toLocaleString(locale, { weekday: "long" });
|
47
|
+
|
48
|
+
// 如果 single 为 true,替换 "星期" 为 "周",英文模式不需要转换
|
49
|
+
if (!en && single) {
|
50
|
+
formattedWeekday = formattedWeekday.replace("星期", "周");
|
51
|
+
}
|
52
|
+
|
53
|
+
switch (type) {
|
54
|
+
case "line":
|
55
|
+
return date.toLocaleDateString(locale, {
|
56
|
+
year: "numeric",
|
57
|
+
month: "2-digit",
|
58
|
+
day: "2-digit",
|
59
|
+
}).replaceAll("/", "-");
|
60
|
+
case "full":
|
61
|
+
return `${date.toLocaleDateString(locale, {
|
62
|
+
year: "numeric",
|
63
|
+
month: "2-digit",
|
64
|
+
day: "2-digit",
|
65
|
+
})} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
66
|
+
hour: "2-digit",
|
67
|
+
minute: "2-digit",
|
68
|
+
second: "2-digit",
|
69
|
+
})}`;
|
70
|
+
case "full-line":
|
71
|
+
return `${date.toLocaleDateString(locale, {
|
72
|
+
year: "numeric",
|
73
|
+
month: "2-digit",
|
74
|
+
day: "2-digit",
|
75
|
+
}).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
76
|
+
hour: "2-digit",
|
77
|
+
minute: "2-digit",
|
78
|
+
second: "2-digit",
|
79
|
+
})}`;
|
80
|
+
case "year-week":
|
81
|
+
return `${date.toLocaleDateString(locale, {
|
82
|
+
year: "numeric",
|
83
|
+
month: "2-digit",
|
84
|
+
day: "2-digit",
|
85
|
+
})} ${formattedWeekday}`;
|
86
|
+
case "year-week-line":
|
87
|
+
return `${date.toLocaleDateString(locale, {
|
88
|
+
year: "numeric",
|
89
|
+
month: "2-digit",
|
90
|
+
day: "2-digit",
|
91
|
+
}).replaceAll("/", "-")} ${formattedWeekday}`;
|
92
|
+
case "week-time":
|
93
|
+
return `${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
94
|
+
hour: "2-digit",
|
95
|
+
minute: "2-digit",
|
96
|
+
second: "2-digit",
|
97
|
+
})}`;
|
98
|
+
case "no-s":
|
99
|
+
return `${date.toLocaleDateString(locale, {
|
100
|
+
year: "numeric",
|
101
|
+
month: "2-digit",
|
102
|
+
day: "2-digit",
|
103
|
+
})} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
104
|
+
hour: "2-digit",
|
105
|
+
minute: "2-digit",
|
106
|
+
})}`;
|
107
|
+
case "no-s-line":
|
108
|
+
return `${date.toLocaleDateString(locale, {
|
109
|
+
year: "numeric",
|
110
|
+
month: "2-digit",
|
111
|
+
day: "2-digit",
|
112
|
+
}).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
113
|
+
hour: "2-digit",
|
114
|
+
minute: "2-digit",
|
115
|
+
})}`;
|
116
|
+
case "us-full":
|
117
|
+
return `${date.toLocaleDateString("en-US", {
|
118
|
+
year: "numeric",
|
119
|
+
month: "2-digit",
|
120
|
+
day: "2-digit",
|
121
|
+
})} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
122
|
+
hour: "2-digit",
|
123
|
+
minute: "2-digit",
|
124
|
+
second: "2-digit",
|
125
|
+
})}`;
|
126
|
+
case "us-full-line":
|
127
|
+
return `${date.toLocaleDateString("en-US", {
|
128
|
+
year: "numeric",
|
129
|
+
month: "2-digit",
|
130
|
+
day: "2-digit",
|
131
|
+
}).replaceAll("/", "-")} ${formattedWeekday} ${date.toLocaleTimeString(locale, {
|
132
|
+
hour: "2-digit",
|
133
|
+
minute: "2-digit",
|
134
|
+
second: "2-digit",
|
135
|
+
})}`;
|
136
|
+
default:
|
137
|
+
// 默认格式 年/月/日
|
138
|
+
return date.toLocaleDateString(locale, {
|
139
|
+
year: "numeric",
|
140
|
+
month: "2-digit",
|
141
|
+
day: "2-digit",
|
142
|
+
});
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
return <div style={combinedStyle}>{formatDate(type)}</div>;
|
147
|
+
};
|
148
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import "./TDatePicker.css";
|
4
|
+
import { useTangoStyle } from "../CSSFab/useTangoStyle";
|
5
|
+
|
6
|
+
export default function DatePicker(props) {
|
7
|
+
const {
|
8
|
+
sx = {},
|
9
|
+
style: userStyle = {},
|
10
|
+
className: userClassName = "",
|
11
|
+
disabled,
|
12
|
+
onChange,
|
13
|
+
time,
|
14
|
+
} = props;
|
15
|
+
|
16
|
+
const [value, setValue] = useState("");
|
17
|
+
|
18
|
+
const handleChange = (e) => {
|
19
|
+
const val = e.target.value;
|
20
|
+
setValue(val);
|
21
|
+
if (onChange) onChange(val);
|
22
|
+
};
|
23
|
+
|
24
|
+
const inputType = time ? "datetime-local" : "date";
|
25
|
+
|
26
|
+
const className = `date-picker ${disabled ? "date-picker-disabled" : ""} ${userClassName}`;
|
27
|
+
|
28
|
+
const sxStyle = useTangoStyle(sx);
|
29
|
+
const combinedStyle = { ...sxStyle, ...userStyle };
|
30
|
+
|
31
|
+
return (
|
32
|
+
<input
|
33
|
+
type={inputType}
|
34
|
+
value={value}
|
35
|
+
onChange={handleChange}
|
36
|
+
className={className}
|
37
|
+
style={combinedStyle}
|
38
|
+
disabled={disabled}
|
39
|
+
/>
|
40
|
+
);
|
41
|
+
};
|
42
|
+
|
43
|
+
DatePicker.propTypes = {
|
44
|
+
sx: PropTypes.object,
|
45
|
+
style: PropTypes.object,
|
46
|
+
className: PropTypes.string,
|
47
|
+
disabled: PropTypes.bool,
|
48
|
+
onChange: PropTypes.func,
|
49
|
+
time: PropTypes.bool, // 是否启用时间选择
|
50
|
+
};
|
51
|
+
|
52
|
+
DatePicker.defaultProps = {
|
53
|
+
sx: {},
|
54
|
+
style: {},
|
55
|
+
className: "",
|
56
|
+
disabled: false,
|
57
|
+
onChange: () => {},
|
58
|
+
time: false,
|
59
|
+
};
|
60
|
+
|
@@ -0,0 +1,202 @@
|
|
1
|
+
.drawer-overlay {
|
2
|
+
position: fixed;
|
3
|
+
top: 0;
|
4
|
+
left: 0;
|
5
|
+
width: 100vw;
|
6
|
+
height: 100vh;
|
7
|
+
background-color: rgba(0, 0, 0, 0.5);
|
8
|
+
z-index: 999;
|
9
|
+
display: flex;
|
10
|
+
justify-content: flex-end;
|
11
|
+
}
|
12
|
+
|
13
|
+
.drawer-container {
|
14
|
+
background-color: #fff;
|
15
|
+
padding: 20px;
|
16
|
+
width: 320px;
|
17
|
+
height:100vh;
|
18
|
+
position: relative;
|
19
|
+
}
|
20
|
+
|
21
|
+
.drawer-header {
|
22
|
+
font-size: 18px;
|
23
|
+
font-weight: bold;
|
24
|
+
margin-bottom: 16px;
|
25
|
+
display: flex;
|
26
|
+
justify-content: space-between;
|
27
|
+
}
|
28
|
+
|
29
|
+
.drawer-content {
|
30
|
+
margin-bottom: 24px;
|
31
|
+
}
|
32
|
+
|
33
|
+
.drawer-footer {
|
34
|
+
position: absolute;
|
35
|
+
bottom: 0;
|
36
|
+
right: 0; /* 确保按钮贴靠右侧 */
|
37
|
+
display: flex;
|
38
|
+
gap: 10px; /* 按钮间隔 */
|
39
|
+
padding: 10px 20px;
|
40
|
+
background-color: #fff;
|
41
|
+
}
|
42
|
+
|
43
|
+
.drawer-closeBtn {
|
44
|
+
background-image: url('../../assets/关闭.png');
|
45
|
+
width: 15px;
|
46
|
+
height: 15px;
|
47
|
+
background-size: 100% 100%;
|
48
|
+
cursor: pointer;
|
49
|
+
}
|
50
|
+
/* Drawer 位置 */
|
51
|
+
.drawer-right {
|
52
|
+
height: 100vh;
|
53
|
+
width: 320px;
|
54
|
+
position: fixed;
|
55
|
+
top: 0;
|
56
|
+
right: 0;
|
57
|
+
}
|
58
|
+
|
59
|
+
.drawer-left {
|
60
|
+
height: 100vh;
|
61
|
+
width: 320px;
|
62
|
+
position: fixed;
|
63
|
+
top: 0;
|
64
|
+
left: 0;
|
65
|
+
}
|
66
|
+
|
67
|
+
.drawer-top {
|
68
|
+
height: 300px;
|
69
|
+
width: 100vw;
|
70
|
+
position: fixed;
|
71
|
+
top: 0;
|
72
|
+
left: 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
.drawer-bottom {
|
76
|
+
height: 300px;
|
77
|
+
width: 100vw;
|
78
|
+
position: fixed;
|
79
|
+
bottom: 0;
|
80
|
+
left: 0;
|
81
|
+
}
|
82
|
+
|
83
|
+
/* 动画 */
|
84
|
+
@keyframes come-in-right {
|
85
|
+
from {
|
86
|
+
transform: translateX(100%);
|
87
|
+
opacity: 0;
|
88
|
+
}
|
89
|
+
to {
|
90
|
+
transform: translateX(0);
|
91
|
+
opacity: 1;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
@keyframes come-out-right {
|
96
|
+
from {
|
97
|
+
transform: translateX(0);
|
98
|
+
opacity: 1;
|
99
|
+
}
|
100
|
+
to {
|
101
|
+
transform: translateX(100%);
|
102
|
+
opacity: 0;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
@keyframes come-in-left {
|
107
|
+
from {
|
108
|
+
transform: translateX(-100%);
|
109
|
+
opacity: 0;
|
110
|
+
}
|
111
|
+
to {
|
112
|
+
transform: translateX(0);
|
113
|
+
opacity: 1;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
@keyframes come-out-left {
|
118
|
+
from {
|
119
|
+
transform: translateX(0);
|
120
|
+
opacity: 1;
|
121
|
+
}
|
122
|
+
to {
|
123
|
+
transform: translateX(-100%);
|
124
|
+
opacity: 0;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
@keyframes come-in-top {
|
129
|
+
from {
|
130
|
+
transform: translateY(-100%);
|
131
|
+
opacity: 0;
|
132
|
+
}
|
133
|
+
to {
|
134
|
+
transform: translateY(0);
|
135
|
+
opacity: 1;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
@keyframes come-out-top {
|
140
|
+
from {
|
141
|
+
transform: translateY(0);
|
142
|
+
opacity: 1;
|
143
|
+
}
|
144
|
+
to {
|
145
|
+
transform: translateY(-100%);
|
146
|
+
opacity: 0;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
@keyframes come-in-bottom {
|
151
|
+
from {
|
152
|
+
transform: translateY(100%);
|
153
|
+
opacity: 0;
|
154
|
+
}
|
155
|
+
to {
|
156
|
+
transform: translateY(0);
|
157
|
+
opacity: 1;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
@keyframes come-out-bottom {
|
162
|
+
from {
|
163
|
+
transform: translateY(0);
|
164
|
+
opacity: 1;
|
165
|
+
}
|
166
|
+
to {
|
167
|
+
transform: translateY(100%);
|
168
|
+
opacity: 0;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
.come-in-right {
|
173
|
+
animation: come-in-right 0.3s ease-in-out;
|
174
|
+
}
|
175
|
+
|
176
|
+
.come-out-right {
|
177
|
+
animation: come-out-right 0.3s ease-in-out;
|
178
|
+
}
|
179
|
+
|
180
|
+
.come-in-left {
|
181
|
+
animation: come-in-left 0.3s ease-in-out;
|
182
|
+
}
|
183
|
+
|
184
|
+
.come-out-left {
|
185
|
+
animation: come-out-left 0.3s ease-in-out;
|
186
|
+
}
|
187
|
+
|
188
|
+
.come-in-top {
|
189
|
+
animation: come-in-top 0.3s ease-in-out;
|
190
|
+
}
|
191
|
+
|
192
|
+
.come-out-top {
|
193
|
+
animation: come-out-top 0.3s ease-in-out;
|
194
|
+
}
|
195
|
+
|
196
|
+
.come-in-bottom {
|
197
|
+
animation: come-in-bottom 0.3s ease-in-out;
|
198
|
+
}
|
199
|
+
|
200
|
+
.come-out-bottom {
|
201
|
+
animation: come-out-bottom 0.3s ease-in-out;
|
202
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import "./TDrawer.css";
|
4
|
+
import TButton from "../TButton/index";
|
5
|
+
|
6
|
+
export default function Drawer(props) {
|
7
|
+
const { children, title, onText, cancelText, open, onClose, type } = props;
|
8
|
+
const [showAnimation, setShowAnimation] = useState(false);
|
9
|
+
const [closing, setClosing] = useState(false);
|
10
|
+
|
11
|
+
Drawer.propTypes = {
|
12
|
+
children: PropTypes.node.isRequired,
|
13
|
+
title: PropTypes.string,
|
14
|
+
onText: PropTypes.string,
|
15
|
+
cancelText: PropTypes.string,
|
16
|
+
open: PropTypes.bool,
|
17
|
+
onClose: PropTypes.func,
|
18
|
+
type: PropTypes.oneOf(["top", "bottom", "left", "right"]),
|
19
|
+
};
|
20
|
+
|
21
|
+
Drawer.defaultProps = {
|
22
|
+
title: "基础标题",
|
23
|
+
onText: "确定",
|
24
|
+
cancelText: "取消",
|
25
|
+
open: false,
|
26
|
+
onClose: () => {},
|
27
|
+
type: "right",
|
28
|
+
};
|
29
|
+
|
30
|
+
useEffect(() => {
|
31
|
+
if (open) {
|
32
|
+
setShowAnimation(true);
|
33
|
+
setClosing(false);
|
34
|
+
} else if (showAnimation) {
|
35
|
+
setClosing(true);
|
36
|
+
setTimeout(() => {
|
37
|
+
setShowAnimation(false);
|
38
|
+
setClosing(false);
|
39
|
+
}, 300);
|
40
|
+
}
|
41
|
+
}, [open]);
|
42
|
+
|
43
|
+
function ok() {
|
44
|
+
console.log("确定按钮");
|
45
|
+
if (onClose) onClose();
|
46
|
+
}
|
47
|
+
|
48
|
+
return (
|
49
|
+
<>
|
50
|
+
{showAnimation && (
|
51
|
+
<div className={`drawer-overlay ${closing ? "fade-out" : "fade-in"}`}>
|
52
|
+
<div
|
53
|
+
className={`drawer-container drawer-${type} ${
|
54
|
+
closing ? `come-out-${type}` : `come-in-${type}`
|
55
|
+
}`}
|
56
|
+
>
|
57
|
+
<div className="drawer-header">
|
58
|
+
<h3>{title}</h3>
|
59
|
+
<div className="drawer-closeBtn" onClick={onClose}></div>
|
60
|
+
</div>
|
61
|
+
<div className="drawer-content">{children}</div>
|
62
|
+
<div className="drawer-footer">
|
63
|
+
<TButton type="success" onClick={ok}>
|
64
|
+
{onText}
|
65
|
+
</TButton>
|
66
|
+
<TButton onClick={onClose}>{cancelText}</TButton>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
)}
|
71
|
+
</>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
.input {
|
2
|
+
width: 300px;
|
3
|
+
height: 40px;
|
4
|
+
border-radius: 8px;
|
5
|
+
border: 1px solid #ccc;
|
6
|
+
padding: 8px 12px;
|
7
|
+
font-size: 14px;
|
8
|
+
color: black;
|
9
|
+
outline: none;
|
10
|
+
transition: all 0.3s ease;
|
11
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
12
|
+
background-color: #fff;
|
13
|
+
}
|
14
|
+
|
15
|
+
.input:hover {
|
16
|
+
border-color: #888;
|
17
|
+
}
|
18
|
+
|
19
|
+
.input:focus {
|
20
|
+
border-color: #4caf50; /* Modern blue accent */
|
21
|
+
box-shadow: 0 0 5px rgba(0, 120, 212, 0.5); /* Subtle glow on focus */
|
22
|
+
}
|
23
|
+
|
24
|
+
.input-small {
|
25
|
+
height: 32px;
|
26
|
+
font-size: 12px;
|
27
|
+
padding: 6px 10px;
|
28
|
+
}
|
29
|
+
|
30
|
+
.input-medium {
|
31
|
+
height: 40px;
|
32
|
+
font-size: 14px;
|
33
|
+
}
|
34
|
+
|
35
|
+
.input-large {
|
36
|
+
height: 48px;
|
37
|
+
font-size: 16px;
|
38
|
+
padding: 10px 14px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.input-huge {
|
42
|
+
height: 56px;
|
43
|
+
font-size: 18px;
|
44
|
+
padding: 12px 16px;
|
45
|
+
}
|
46
|
+
|
47
|
+
.input-disabled {
|
48
|
+
background-color: #f5f5f5;
|
49
|
+
color: #999;
|
50
|
+
border-color: #ddd;
|
51
|
+
cursor: not-allowed;
|
52
|
+
box-shadow: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
.input-textarea {
|
56
|
+
min-height: 32px;
|
57
|
+
font-size: 14px;
|
58
|
+
}
|
59
|
+
|
60
|
+
.input-error {
|
61
|
+
border-color: #d93025;
|
62
|
+
background-color: #fef2f2;
|
63
|
+
color: #d93025;
|
64
|
+
}
|
65
|
+
|
66
|
+
.input-error:focus {
|
67
|
+
box-shadow: 0 0 5px rgba(217, 48, 37, 0.5);
|
68
|
+
}
|
69
|
+
/* .search-button {
|
70
|
+
position: absolute;
|
71
|
+
right: 10px;
|
72
|
+
top: 0%;
|
73
|
+
transform: translateY(-50%);
|
74
|
+
padding: 5px 10px;
|
75
|
+
background: #007bff;
|
76
|
+
color: #fff;
|
77
|
+
border: none;
|
78
|
+
border-radius: 4px;
|
79
|
+
cursor: pointer;
|
80
|
+
} */
|