@xaypay/tui 0.0.55 → 0.0.56
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.es.js +85 -74
- package/dist/index.js +85 -74
- package/package.json +2 -1
- package/rollup.config.js +2 -0
- package/src/components/autocomplate/index.js +22 -17
- package/src/components/button/index.js +8 -8
- package/src/components/input/index.js +14 -18
- package/src/components/table/index.js +1 -1
- package/src/components/tooltip/index.js +37 -34
- package/src/components/tooltip/tooltip.module.css +2 -2
- package/src/components/tooltip/tooltip.stories.js +3 -2
- package/src/components/typography/index.js +6 -2
- package/src/stories/Introduction.stories.mdx +10 -0
- package/src/stories/configuration.stories.mdx +20 -3
- package/src/stories/static/button-usage.png +0 -0
- package/src/stories/usage.stories.mdx +128 -0
- package/src/utils/index.js +1 -0
- package/tui.config.js +15 -5
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { compereConfigs } from "./../../utils";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import ReactInfoIcon from './../../assets/icons/tooltip.svg';
|
|
7
7
|
|
|
8
8
|
import styles from "./tooltip.module.css";
|
|
9
9
|
|
|
@@ -12,19 +12,20 @@ export const Tooltip = ({
|
|
|
12
12
|
text,
|
|
13
13
|
width,
|
|
14
14
|
color,
|
|
15
|
-
tIcon,
|
|
16
15
|
height,
|
|
17
|
-
|
|
16
|
+
radius,
|
|
18
17
|
fontSize,
|
|
19
|
-
tBgColor,
|
|
20
18
|
className,
|
|
21
19
|
fontFamily,
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
tooltipIcon,
|
|
21
|
+
tooltipWidth,
|
|
22
|
+
tooltipRadius,
|
|
23
|
+
backgroundColor,
|
|
24
|
+
tooltipBackgroundColor
|
|
24
25
|
}) => {
|
|
25
26
|
const tooltipRef = createRef(null);
|
|
26
|
-
const [
|
|
27
|
-
const [
|
|
27
|
+
const [checkTooltipWidth, setCheckTooltipWidth] = useState(0);
|
|
28
|
+
const [checkTooltipHeight, setCheckTooltipHeight] = useState(0);
|
|
28
29
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
29
30
|
|
|
30
31
|
const configStyles = compereConfigs();
|
|
@@ -33,29 +34,26 @@ export const Tooltip = ({
|
|
|
33
34
|
className
|
|
34
35
|
);
|
|
35
36
|
|
|
36
|
-
useEffect(_ => {
|
|
37
|
-
if (!type && !text) {
|
|
38
|
-
alert('Add type and text on tooltip');
|
|
39
|
-
} else if (!type) {
|
|
40
|
-
alert('Add type on tooltip');
|
|
41
|
-
} else if (!text) {
|
|
42
|
-
alert('Add text on tooltip');
|
|
43
|
-
}
|
|
44
|
-
tooltipRef.current && tooltipRef.current.clientWidth && tooltipRef.current.clientWidth > 0 && setTooltipWidth(tooltipRef.current.clientWidth);
|
|
45
|
-
tooltipRef.current && tooltipRef.current.clientHeight && tooltipRef.current.clientHeight > 0 && setTooltipHeight(tooltipRef.current.clientHeight);
|
|
46
|
-
}, [type, text, tooltipWidth, tooltipRef]);
|
|
47
|
-
|
|
48
37
|
const handleShow = () => {
|
|
49
38
|
setShowTooltip(!showTooltip);
|
|
50
39
|
};
|
|
51
40
|
|
|
41
|
+
useEffect(_ => {
|
|
42
|
+
if (!text) {
|
|
43
|
+
alert('Add text on tooltip');
|
|
44
|
+
}
|
|
45
|
+
tooltipRef.current && tooltipRef.current.clientWidth && tooltipRef.current.clientWidth > 0 && setCheckTooltipWidth(tooltipRef.current.clientWidth);
|
|
46
|
+
tooltipRef.current && tooltipRef.current.clientHeight && tooltipRef.current.clientHeight > 0 && setCheckTooltipHeight(tooltipRef.current.clientHeight);
|
|
47
|
+
}, [text, tooltipRef, checkTooltipWidth, checkTooltipHeight]);
|
|
48
|
+
|
|
52
49
|
return (
|
|
53
50
|
<div
|
|
54
51
|
className={`${styles['tooltip-block']}`}
|
|
55
52
|
style={{
|
|
56
53
|
width: width ? width : configStyles.TOOLTIP.width,
|
|
57
54
|
height: height ? height : configStyles.TOOLTIP.height,
|
|
58
|
-
|
|
55
|
+
borderRadius: radius ? radius : configStyles.TOOLTIP.radius,
|
|
56
|
+
backgroundColor: backgroundColor ? backgroundColor : configStyles.TOOLTIP.backgroundColor,
|
|
59
57
|
}}
|
|
60
58
|
>
|
|
61
59
|
{
|
|
@@ -64,10 +62,11 @@ export const Tooltip = ({
|
|
|
64
62
|
ref={tooltipRef}
|
|
65
63
|
className={classProps}
|
|
66
64
|
style={{
|
|
67
|
-
|
|
68
|
-
borderRadius:
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
width: tooltipWidth ? tooltipWidth : configStyles.TOOLTIP.tooltipWidth,
|
|
66
|
+
borderRadius: tooltipRadius ? tooltipRadius : configStyles.TOOLTIP.tooltipRadius,
|
|
67
|
+
backgroundColor: tooltipBackgroundColor ? tooltipBackgroundColor : configStyles.TOOLTIP.tooltipBackgroundColor,
|
|
68
|
+
top: type === 'top' ? `calc(-${checkTooltipHeight + 7}px)` : type === 'bottom' ? 'calc(100% + 7px)' : type === 'left' || type === 'right' ? `calc(50% - ${checkTooltipHeight / 2}px)` : '0px',
|
|
69
|
+
left: type === 'top' || type === 'bottom' ? `calc(50% - ${checkTooltipWidth / 2}px)` : type === 'left' ? `-${checkTooltipWidth + 7}px` : type === 'right' ? 'calc(100% + 7px)' : '0px'
|
|
71
70
|
}}
|
|
72
71
|
>
|
|
73
72
|
<div
|
|
@@ -76,7 +75,7 @@ export const Tooltip = ({
|
|
|
76
75
|
<div
|
|
77
76
|
className={`${styles['tooltip-decor']}`}
|
|
78
77
|
style={{
|
|
79
|
-
backgroundColor:
|
|
78
|
+
backgroundColor: tooltipBackgroundColor ? tooltipBackgroundColor : configStyles.TOOLTIP.tooltipBackgroundColor,
|
|
80
79
|
left: type === 'top' || type === 'bottom' ? 'calc(50% - 5px)' : type === 'right' ? '-15px' : type === 'left' ? 'calc(100% + 5px)' : '0px',
|
|
81
80
|
top: type === 'top' ? 'calc(100% + 5px)' : type === 'bottom' ? '-15px' : type === 'right' || type === 'left' ? 'calc(50% - 5px)' : '0px'
|
|
82
81
|
}}
|
|
@@ -85,7 +84,6 @@ export const Tooltip = ({
|
|
|
85
84
|
style={{
|
|
86
85
|
color: color ? color : configStyles.TOOLTIP.color,
|
|
87
86
|
fontSize: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
|
|
88
|
-
lineHeight: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
|
|
89
87
|
fontFamily: fontFamily ? fontFamily : configStyles.TOOLTIP.fontFamily
|
|
90
88
|
}}
|
|
91
89
|
>
|
|
@@ -97,24 +95,29 @@ export const Tooltip = ({
|
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
<div style={{cursor: 'pointer'}} onClick={handleShow}>
|
|
100
|
-
{
|
|
98
|
+
{tooltipIcon && tooltipIcon[0] ? tooltipIcon[0] : <img src={ReactInfoIcon} />}
|
|
101
99
|
</div>
|
|
102
100
|
</div>
|
|
103
101
|
);
|
|
104
102
|
};
|
|
105
103
|
|
|
106
104
|
Tooltip.propTypes = {
|
|
105
|
+
type: PropTypes.string,
|
|
107
106
|
width: PropTypes.string,
|
|
108
107
|
color: PropTypes.string,
|
|
109
|
-
tIcon: PropTypes.element,
|
|
110
108
|
height: PropTypes.string,
|
|
111
|
-
|
|
112
|
-
tBgColor: PropTypes.string,
|
|
109
|
+
radius: PropTypes.string,
|
|
113
110
|
fontSize: PropTypes.string,
|
|
114
111
|
className: PropTypes.string,
|
|
115
112
|
fontFamily: PropTypes.string,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
type: PropTypes.string.isRequired,
|
|
113
|
+
tooltipWidth: PropTypes.string,
|
|
114
|
+
tooltipRadius: PropTypes.string,
|
|
119
115
|
text: PropTypes.string.isRequired,
|
|
116
|
+
backgroundColor: PropTypes.string,
|
|
117
|
+
tooltipBackgroundColor: PropTypes.string,
|
|
118
|
+
tooltipIcon: PropTypes.arrayOf(PropTypes.element)
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
Tooltip.defaultProps = {
|
|
122
|
+
type: 'top'
|
|
120
123
|
};
|
|
@@ -128,5 +128,9 @@ Typography.propTypes = {
|
|
|
128
128
|
colorHover: PropTypes.string,
|
|
129
129
|
textTransform: PropTypes.string,
|
|
130
130
|
textDecoration: PropTypes.string,
|
|
131
|
-
variant: PropTypes.oneOf(Object.values(TypographyType))
|
|
132
|
-
};
|
|
131
|
+
variant: PropTypes.oneOf(Object.values(TypographyType)),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
Typography.defaultProps = {
|
|
135
|
+
variant: 'p'
|
|
136
|
+
};
|
|
@@ -159,6 +159,16 @@ TUI is fully configurable. You can change color, size, border and etc... Yes. Yo
|
|
|
159
159
|
</a>
|
|
160
160
|
</div>
|
|
161
161
|
|
|
162
|
+
<div className="link-list">
|
|
163
|
+
<a className="link-item" href="../?path=/docs/intro-usage--page">
|
|
164
|
+
<img src={Code} alt="code" />
|
|
165
|
+
<span>
|
|
166
|
+
<strong>TUI usage</strong>
|
|
167
|
+
Configure, customize, and extend
|
|
168
|
+
</span>
|
|
169
|
+
</a>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
162
172
|
<!--
|
|
163
173
|
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
|
|
164
174
|
<img src={Direction} alt="direction" />
|
|
@@ -139,10 +139,10 @@ import StackAlt from './assets/stackalt.svg';
|
|
|
139
139
|
padding: '12px 20px', // for padding
|
|
140
140
|
textTransform: 'none', // for text transform
|
|
141
141
|
boxSizing: 'border-box', // for box sizing
|
|
142
|
-
bgColor: 'rgba(0, 35, 106, 1)', // for background color
|
|
143
142
|
disabledColor: 'rgba(60, 57, 62, 1)', // for color in disabled mode
|
|
143
|
+
backgroundColor: 'rgba(0, 35, 106, 1)', // for background color
|
|
144
144
|
disabledLineColor: 'rgba(60, 57, 62, 1)', // for border color (outline) in disabled mode
|
|
145
|
-
|
|
145
|
+
disabledBackgroundColor: 'rgba(238, 238, 238, 1)', // for background color in disabled mode
|
|
146
146
|
transition: 'background-color 240ms, color 240ms', // for transition
|
|
147
147
|
},
|
|
148
148
|
```
|
|
@@ -157,7 +157,6 @@ import StackAlt from './assets/stackalt.svg';
|
|
|
157
157
|
radius: '0px', // for input and also (if there exist left or right icons) icons block border-radius
|
|
158
158
|
className: '', // for input classname (you can set custom class for your custom css)
|
|
159
159
|
height: '46px', // for height
|
|
160
|
-
tooltip: false, // for tooltip
|
|
161
160
|
required: false, // for showing required mark on label (it meens input is required)
|
|
162
161
|
disabled: false, // for disabled
|
|
163
162
|
errorLeft: '0px', // for error message position from left (work when errorPosition prop is 'absolute')
|
|
@@ -188,6 +187,24 @@ import StackAlt from './assets/stackalt.svg';
|
|
|
188
187
|
}
|
|
189
188
|
```
|
|
190
189
|
|
|
190
|
+
### Tooltip
|
|
191
|
+
```
|
|
192
|
+
{
|
|
193
|
+
type: 'top', // for tooltip type (top, right, bottom, left)
|
|
194
|
+
width: '46px', // for tooltip parent block width
|
|
195
|
+
radius: '0px', // for tooltip parent block border radius
|
|
196
|
+
className: '', // for tooltip className (maybe you want to add your custom class for your custom css)
|
|
197
|
+
color: 'white', // for tooltip color
|
|
198
|
+
height: '46px', // for tooltip parent block height
|
|
199
|
+
fontSize: '14px', // for tooltip font size
|
|
200
|
+
tooltipRadius: '3px', // for tooltip border radius
|
|
201
|
+
tooltipWidth: '100px', // for tooltip width
|
|
202
|
+
backgroundColor: 'transparent', // for tooltip parent block background color (maybe you want to see it)
|
|
203
|
+
fontFamily: 'Arial, sans-serif', // for tooltip font family
|
|
204
|
+
tooltipBackgroundColor: '#03a9f4' // for tooltip backgrond color
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
191
208
|
### Typography
|
|
192
209
|
|
|
193
210
|
```
|
|
Binary file
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs';
|
|
2
|
+
import Code from './assets/code-brackets.svg';
|
|
3
|
+
import Colors from './assets/colors.svg';
|
|
4
|
+
import Comments from './assets/comments.svg';
|
|
5
|
+
import Direction from './assets/direction.svg';
|
|
6
|
+
import Flow from './assets/flow.svg';
|
|
7
|
+
import Plugin from './assets/plugin.svg';
|
|
8
|
+
import Repo from './assets/repo.svg';
|
|
9
|
+
import StackAlt from './assets/stackalt.svg';
|
|
10
|
+
|
|
11
|
+
import buttonImage from './static/button-usage.png';
|
|
12
|
+
|
|
13
|
+
<Meta title="Intro/Usage" />
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
{`
|
|
17
|
+
.subheading {
|
|
18
|
+
--mediumdark: '#999999';
|
|
19
|
+
font-weight: 900;
|
|
20
|
+
font-size: 13px;
|
|
21
|
+
color: #999;
|
|
22
|
+
letter-spacing: 6px;
|
|
23
|
+
line-height: 24px;
|
|
24
|
+
text-transform: uppercase;
|
|
25
|
+
margin-bottom: 12px;
|
|
26
|
+
margin-top: 40px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sbdocs-content {
|
|
30
|
+
max-width: 80% !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.link-list {
|
|
34
|
+
display: grid;
|
|
35
|
+
grid-template-columns: 1fr;
|
|
36
|
+
grid-template-rows: 1fr 1fr;
|
|
37
|
+
row-gap: 10px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@media (min-width: 620px) {
|
|
41
|
+
.link-list {
|
|
42
|
+
row-gap: 20px;
|
|
43
|
+
column-gap: 20px;
|
|
44
|
+
grid-template-columns: 1fr 1fr;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media all and (-ms-high-contrast:none) {
|
|
49
|
+
.link-list {
|
|
50
|
+
display: -ms-grid;
|
|
51
|
+
-ms-grid-columns: 1fr 1fr;
|
|
52
|
+
-ms-grid-rows: 1fr 1fr;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.link-item {
|
|
57
|
+
display: block;
|
|
58
|
+
padding: 20px 30px 20px 15px;
|
|
59
|
+
border: 1px solid #00000010;
|
|
60
|
+
border-radius: 5px;
|
|
61
|
+
transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
|
|
62
|
+
color: #333333;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: flex-start;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.link-item:hover {
|
|
68
|
+
border-color: #1EA7FD50;
|
|
69
|
+
transform: translate3d(0, -3px, 0);
|
|
70
|
+
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.link-item:active {
|
|
74
|
+
border-color: #1EA7FD;
|
|
75
|
+
transform: translate3d(0, 0, 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.link-item strong {
|
|
79
|
+
font-weight: 700;
|
|
80
|
+
display: block;
|
|
81
|
+
margin-bottom: 2px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.link-item img {
|
|
85
|
+
height: 40px;
|
|
86
|
+
width: 40px;
|
|
87
|
+
margin-right: 15px;
|
|
88
|
+
flex: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.link-item span {
|
|
92
|
+
font-size: 14px;
|
|
93
|
+
line-height: 20px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.tip {
|
|
97
|
+
display: inline-block;
|
|
98
|
+
border-radius: 1em;
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
line-height: 12px;
|
|
101
|
+
font-weight: 700;
|
|
102
|
+
background: #E7FDD8;
|
|
103
|
+
color: #66BF3C;
|
|
104
|
+
padding: 4px 12px;
|
|
105
|
+
margin-right: 10px;
|
|
106
|
+
vertical-align: top;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.tip-wrapper {
|
|
110
|
+
font-size: 13px;
|
|
111
|
+
line-height: 20px;
|
|
112
|
+
margin-top: 40px;
|
|
113
|
+
margin-bottom: 40px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.tip-wrapper code {
|
|
117
|
+
font-size: 12px;
|
|
118
|
+
display: inline-block;
|
|
119
|
+
}
|
|
120
|
+
`}
|
|
121
|
+
</style>
|
|
122
|
+
|
|
123
|
+
# Usage
|
|
124
|
+
|
|
125
|
+
### Button
|
|
126
|
+
|
|
127
|
+
<img src={buttonImage} alt="button image" />
|
|
128
|
+
|
package/src/utils/index.js
CHANGED
package/tui.config.js
CHANGED
|
@@ -16,10 +16,10 @@ module.exports = {
|
|
|
16
16
|
padding: '12px 20px', // for padding
|
|
17
17
|
textTransform: 'none', // for text transform
|
|
18
18
|
boxSizing: 'border-box', // for box sizing
|
|
19
|
-
bgColor: 'rgba(0, 35, 106, 1)', // for background color
|
|
20
19
|
disabledColor: 'rgba(60, 57, 62, 1)', // for color in disabled mode
|
|
20
|
+
backgroundColor: 'rgba(0, 35, 106, 1)', // for background color
|
|
21
21
|
disabledLineColor: 'rgba(60, 57, 62, 1)', // for border color (outline) in disabled mode
|
|
22
|
-
|
|
22
|
+
disabledBackgroundColor: 'rgba(238, 238, 238, 1)', // for background color in disabled mode
|
|
23
23
|
transition: 'background-color 240ms, color 240ms', // for transition
|
|
24
24
|
},
|
|
25
25
|
// default properties for <Input /> component
|
|
@@ -30,7 +30,6 @@ module.exports = {
|
|
|
30
30
|
radius: '0px', // for input and also (if there exist left or right icons) icons block border-radius
|
|
31
31
|
className: '', // for input classname (you can set custom class for your custom css)
|
|
32
32
|
height: '46px', // for height
|
|
33
|
-
tooltip: false, // for tooltip
|
|
34
33
|
required: false, // for showing required mark on label (it meens input is required)
|
|
35
34
|
disabled: false, // for disabled
|
|
36
35
|
errorLeft: '0px', // for error message position from left (work when errorPosition prop is 'absolute')
|
|
@@ -59,9 +58,20 @@ module.exports = {
|
|
|
59
58
|
errorAnimationDuration: '240ms', // for animation duration (when have error message and errorAnimation prop is true)
|
|
60
59
|
boxShadowHover: '0 0 0 2px #3c393e', // for border size and color in hover mode (set if you want to change it)
|
|
61
60
|
},
|
|
61
|
+
// default properties for <Tooltip /> component
|
|
62
62
|
TOOLTIP: {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
type: 'top', // for tooltip type (top, right, bottom, left)
|
|
64
|
+
width: '46px', // for tooltip parent block width
|
|
65
|
+
radius: '0px', // for tooltip parent block border radius
|
|
66
|
+
className: '', // for tooltip className (maybe you want to add your custom class for your custom css)
|
|
67
|
+
color: 'white', // for tooltip color
|
|
68
|
+
height: '46px', // for tooltip parent block height
|
|
69
|
+
fontSize: '14px', // for tooltip font size
|
|
70
|
+
tooltipRadius: '3px', // for tooltip border radius
|
|
71
|
+
tooltipWidth: '100px', // for tooltip width
|
|
72
|
+
backgroundColor: 'transparent', // for tooltip parent block background color (maybe you want to see it)
|
|
73
|
+
fontFamily: 'Arial, sans-serif', // for tooltip font family
|
|
74
|
+
tooltipBackgroundColor: '#03a9f4' // for tooltip backgrond color
|
|
65
75
|
},
|
|
66
76
|
// default properties for <Typography /> component
|
|
67
77
|
TYPOGRAPHY: {
|