@xaypay/tui 0.0.52 → 0.0.54

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.
@@ -0,0 +1,120 @@
1
+ import React, { useState, useEffect, createRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classnames from 'classnames';
4
+ import { compereConfigs } from "./../../utils";
5
+
6
+ // import ReactInfoIcon from './../../assets/icons/tooltip.svg';
7
+
8
+ import styles from "./tooltip.module.css";
9
+
10
+ export const Tooltip = ({
11
+ type,
12
+ text,
13
+ width,
14
+ color,
15
+ tIcon,
16
+ height,
17
+ bgColor,
18
+ fontSize,
19
+ tBgColor,
20
+ className,
21
+ fontFamily,
22
+ borderRadius,
23
+ tBorderRadius
24
+ }) => {
25
+ const tooltipRef = createRef(null);
26
+ const [tooltipWidth, setTooltipWidth] = useState(0);
27
+ const [tooltipHeight, setTooltipHeight] = useState(0);
28
+ const [showTooltip, setShowTooltip] = useState(false);
29
+
30
+ const configStyles = compereConfigs();
31
+ const classProps = classnames(
32
+ styles['tooltip'],
33
+ className
34
+ );
35
+
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
+ const handleShow = () => {
49
+ setShowTooltip(!showTooltip);
50
+ };
51
+
52
+ return (
53
+ <div
54
+ className={`${styles['tooltip-block']}`}
55
+ style={{
56
+ width: width ? width : configStyles.TOOLTIP.width,
57
+ height: height ? height : configStyles.TOOLTIP.height,
58
+ backgroundColor: bgColor ? bgColor : configStyles.TOOLTIP.bgColor,
59
+ }}
60
+ >
61
+ {
62
+ showTooltip ?
63
+ <div
64
+ ref={tooltipRef}
65
+ className={classProps}
66
+ style={{
67
+ backgroundColor: tBgColor ? tBgColor : configStyles.TOOLTIP.tBgColor,
68
+ borderRadius: tBorderRadius ? tBorderRadius : configStyles.TOOLTIP.tBorderRadius,
69
+ top: type === 'top' ? `calc(-${tooltipHeight + 7}px)` : type === 'bottom' ? 'calc(100% + 7px)' : type === 'left' || type === 'right' ? `calc(50% - ${tooltipHeight / 2}px)` : '0px',
70
+ left: type === 'top' || type === 'bottom' ? `calc(50% - ${tooltipWidth / 2}px)` : type === 'left' ? `-${tooltipWidth + 7}px` : type === 'right' ? 'calc(100% + 7px)' : '0px'
71
+ }}
72
+ >
73
+ <div
74
+ className={`${styles['tooltip-rel']}`}
75
+ >
76
+ <div
77
+ className={`${styles['tooltip-decor']}`}
78
+ style={{
79
+ backgroundColor: tBgColor ? tBgColor : configStyles.TOOLTIP.bgColor,
80
+ left: type === 'top' || type === 'bottom' ? 'calc(50% - 5px)' : type === 'right' ? '-15px' : type === 'left' ? 'calc(100% + 5px)' : '0px',
81
+ top: type === 'top' ? 'calc(100% + 5px)' : type === 'bottom' ? '-15px' : type === 'right' || type === 'left' ? 'calc(50% - 5px)' : '0px'
82
+ }}
83
+ ></div>
84
+ <p
85
+ style={{
86
+ color: color ? color : configStyles.TOOLTIP.color,
87
+ fontSize: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
88
+ lineHeight: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
89
+ fontFamily: fontFamily ? fontFamily : configStyles.TOOLTIP.fontFamily
90
+ }}
91
+ >
92
+ { text }
93
+ </p>
94
+ </div>
95
+ </div>
96
+ : ''
97
+ }
98
+
99
+ <div style={{cursor: 'pointer'}} onClick={handleShow}>
100
+ {/* {tIcon ? tIcon : <img src={ReactInfoIcon} alt="ReactInfoIcon" />} */}
101
+ </div>
102
+ </div>
103
+ );
104
+ };
105
+
106
+ Tooltip.propTypes = {
107
+ width: PropTypes.string,
108
+ color: PropTypes.string,
109
+ tIcon: PropTypes.element,
110
+ height: PropTypes.string,
111
+ bgColor: PropTypes.string,
112
+ tBgColor: PropTypes.string,
113
+ fontSize: PropTypes.string,
114
+ className: PropTypes.string,
115
+ fontFamily: PropTypes.string,
116
+ borderRadius: PropTypes.string,
117
+ tBorderRadius: PropTypes.string,
118
+ type: PropTypes.string.isRequired,
119
+ text: PropTypes.string.isRequired,
120
+ };
@@ -0,0 +1,46 @@
1
+ .tooltip-block {
2
+ position: relative;
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ }
7
+
8
+ .tooltip {
9
+ position: absolute;
10
+ z-index: 1;
11
+ padding: 10px;
12
+ }
13
+
14
+ .tooltip-rel {
15
+ position: relative;
16
+ display: flex;
17
+ width: auto;
18
+ height: auto;
19
+ min-width: 50px;
20
+ min-height: 20px;
21
+ align-items: center;
22
+ justify-content: center;
23
+ border-radius: 5px;
24
+ -webkit-border-radius: 5px;
25
+ -moz-border-radius: 5px;
26
+ -ms-border-radius: 5px;
27
+ -o-border-radius: 5px;
28
+ }
29
+
30
+ .tooltip-decor {
31
+ position: absolute;
32
+ width: 10px;
33
+ height: 10px;
34
+ z-index: -1;
35
+ border-radius: 2px;
36
+ -webkit-border-radius: 2px;
37
+ -moz-border-radius: 2px;
38
+ -ms-border-radius: 2px;
39
+ -o-border-radius: 2px;
40
+ transform: rotate(45deg);
41
+ -webkit-transform: rotate(45deg);
42
+ -moz-transform: rotate(45deg);
43
+ -ms-transform: rotate(45deg);
44
+ -o-transform: rotate(45deg);
45
+ }
46
+
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+
3
+ import { Tooltip } from './index';
4
+
5
+ export default {
6
+ component: Tooltip,
7
+ title: "Components/Tooltip",
8
+ };
9
+
10
+ const Template = (args) => {
11
+ return (
12
+ <div
13
+ style={{
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ height: 'calc(100vh - 32px)'
18
+ }}
19
+ >
20
+ <Tooltip {...args} />
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export const Default = Template.bind({});
26
+ Default.args = {
27
+ type: 'bottom',
28
+ text: 'new tooltip'
29
+ }
30
+
@@ -1,10 +1,11 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
- import styles from './typography.module.css';
5
- import styled from "styled-components";
4
+
5
+ import { compereConfigs } from "./../../utils";
6
6
 
7
7
  export const TypographyType = {
8
+ p: 'p',
8
9
  h1: 'h1',
9
10
  h2: 'h2',
10
11
  h3: 'h3',
@@ -12,45 +13,65 @@ export const TypographyType = {
12
13
  h5: 'h5',
13
14
  h6: 'h6',
14
15
  span: 'span',
15
- p: 'p',
16
- i: 'i',
17
16
  };
18
17
 
18
+ export const Typography = ({
19
+ size,
20
+ color,
21
+ weight,
22
+ onClick,
23
+ variant,
24
+ children,
25
+ className,
26
+ ...props
27
+ }) => {
28
+ const configStyles = compereConfigs();
29
+ const classProps = classnames(className);
19
30
 
31
+ const [validVariant, setValidVariant] = useState(false);
32
+ const [style, setStyle] = useState({
33
+ fontSize: size ? size : configStyles.TYPOGRAPHY['fSize'+variant],
34
+ fontWeight: weight ? weight : configStyles.TYPOGRAPHY['fWeight'+variant]
35
+ });
20
36
 
21
- export const Typography = ({onClick, variant, className, color, bold, children, ...props }) => {
22
- const classProps = classnames(className,'sizes-rem',bold ? 'bold': '');
23
- const CustomTag = variant;
24
-
25
- // const Tag = ({ className, children }) => (
26
- // <CustomTag
27
- // className={className}
28
- // {...props}
29
- // >
30
- // {children}
31
- // </CustomTag>
32
- // );
37
+ useEffect(() => {
38
+ if (!Object.values(TypographyType).includes(variant)) {
39
+ setValidVariant(true);
40
+ }
41
+ }, [variant]);
33
42
 
34
- const StyledTypograpy = styled(CustomTag)`
35
- ${color ? 'color: '+color+';' : '' }
36
- ${bold ? 'font-weight: bold;' : '' }
37
- `;
43
+ useEffect(() => {
44
+ if (color) {
45
+ setStyle(prev => {
46
+ return {
47
+ ...prev,
48
+ color: color
49
+ }
50
+ })
51
+ }
52
+ }, [color]);
53
+
54
+ const tagT = React.createElement(
55
+ variant,
56
+ {
57
+ style,
58
+ ...props,
59
+ className: classProps,
60
+ onClick: onClick ? onClick : _ => _,
61
+ },
62
+ [children]
63
+ );
38
64
 
39
65
  return (
40
- <StyledTypograpy className={classProps} onClick={onClick}> {children} </StyledTypograpy>
66
+ validVariant ? 'Please set Typography valid variant' : tagT
41
67
  );
42
68
  };
43
69
 
44
70
  Typography.propTypes = {
45
- variant: PropTypes.oneOf(Object.values(TypographyType)),
46
- className: PropTypes.string,
47
- bold: PropTypes.bool,
48
- color: PropTypes.string,
49
- onClick: PropTypes.func
50
- };
51
-
52
- Typography.defaultProps = {
53
- variant: 'h1',
54
- onClick: ()=> {
55
- }
71
+ size: PropTypes.string,
72
+ color: PropTypes.string,
73
+ weight: PropTypes.string,
74
+ onClick: PropTypes.func,
75
+ className: PropTypes.string,
76
+ variant: PropTypes.oneOf(Object.values(TypographyType)).isRequired,
56
77
  };
@@ -1,4 +1,4 @@
1
- h1 {
1
+ /* h1 {
2
2
  text-transform: uppercase;
3
3
  font-size: 70px;
4
4
  line-height: 78px;
@@ -54,9 +54,4 @@ span {
54
54
  line-height: 16px;
55
55
  font-weight: 500;
56
56
  color: #3C393E;
57
- }
58
-
59
- i {
60
- font-family: icomoon;
61
- font-style: inherit;
62
- }
57
+ } */
@@ -8,24 +8,11 @@ export default {
8
8
 
9
9
  const staticTag = ['h1','h2','h3','h4','h5','h6','span','p']
10
10
 
11
- const Template = (args) => <>
12
- <Typography {...args} >Dynamic Typography</Typography>
11
+ export const Template = (args) => <>
12
+ <Typography {...args} variant="h1">Dynamic Typography</Typography>
13
13
  {
14
14
  staticTag.map((tag,key) => {
15
- return <Typography key={key} variant={tag} >{tag}</Typography>;
15
+ return <Typography key={key} variant={tag} color={"#" + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0').toUpperCase()}>{tag}</Typography>;
16
16
  })
17
17
  }
18
- {/* <Typography variant="h1" >Test</Typography>
19
- <Typography variant="h1" >Test</Typography>
20
- <Typography variant="h1" >Test</Typography>
21
- <Typography variant="h1" >Test</Typography>
22
- <Typography variant="h1" >Test</Typography>
23
- <Typography variant="h1" >Test</Typography> */}
24
18
  </>;
25
-
26
- export const Default = Template.bind({});
27
- Default.args = {
28
- variant: 'h1',
29
- onClick: ()=> {
30
- }
31
- };
package/src/index.js CHANGED
@@ -1,14 +1,15 @@
1
- export * from './components/button';
2
- export * from './components/typography';
3
- export * from './components/autocomplate';
4
- export * from './components/checkbox';
5
- export * from './components/icon/Icon';
1
+ export * from './components/file';
2
+ export * from './components/table';
3
+ export * from './components/modal';
6
4
  export * from './components/input';
7
- export * from './components/pagination';
8
5
  export * from './components/radio';
6
+ export * from './components/button';
7
+ export * from './components/select';
8
+ export * from './components/tooltip';
9
9
  export * from './components/captcha';
10
10
  export * from './components/stepper';
11
- export * from './components/select';
12
- export * from './components/file';
13
- export * from './components/modal';
14
- export * from './components/table';
11
+ export * from './components/checkbox';
12
+ export * from './components/icon/Icon';
13
+ export * from './components/typography';
14
+ export * from './components/pagination';
15
+ export * from './components/autocomplate';
@@ -0,0 +1,21 @@
1
+ const _ = require('lodash');
2
+
3
+ export const compereConfigs = () => {
4
+ let projectConfig = {};
5
+ let packageConfig = {};
6
+
7
+ try {
8
+ packageConfig = require('../tui.config.js');
9
+ } catch (error) {
10
+ // console.log(error, 'Package: tui.config.js file is not define');
11
+ }
12
+
13
+ try {
14
+ projectConfig = require('../../../../tui.config.js');
15
+ } catch (error) {
16
+ projectConfig = {};
17
+ // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
18
+ }
19
+
20
+ return _.merge(packageConfig, projectConfig);
21
+ };
package/tui.config.js ADDED
@@ -0,0 +1,62 @@
1
+ module.exports = {
2
+ BUTTON: {
3
+ width: '100%',
4
+ type: 'button',
5
+ height: '46px',
6
+ color: 'white',
7
+ border: 'none',
8
+ disabled: false,
9
+ fontSize: '16px',
10
+ cursor: 'pointer',
11
+ borderRadius: '6px',
12
+ contentWidth: false,
13
+ padding: '12px 20px',
14
+ boxSizing: 'border-box',
15
+ bgColor: 'rgba(0, 35, 106, 1)',
16
+ disabledThemeColor: 'rgba(60, 57, 62, 1)',
17
+ disabledThemeLineColor: 'rgba(60, 57, 62, 1)',
18
+ disabledThemeBgColor: 'rgba(238, 238, 238, 1)',
19
+ transition: 'background-color 240ms, color 240ms'
20
+ },
21
+ INPUT: {
22
+ type: 'text',
23
+ width: '100%',
24
+ radius: '6px',
25
+ height: '46px',
26
+ required: false,
27
+ disabled: false,
28
+ fontSize: '16px',
29
+ bgColor: 'white',
30
+ iconWidth: '64px',
31
+ autoComplete: 'off',
32
+ tooltipLeft: '-73px',
33
+ padding: '12px 15px',
34
+ boxSizing: 'border-box',
35
+ color: 'rgb(60, 57, 62)',
36
+ tooltipTop: 'calc(-50% - 30px)',
37
+ boxShadow: '0 0 0 2px #d1d1d1',
38
+ boxShadowHover: '0 0 0 2px #3c393e'
39
+ },
40
+ TOOLTIP: {
41
+ width: '46px',
42
+ height: '46px'
43
+ },
44
+ TYPOGRAPHY: {
45
+ fSizep: '13px',
46
+ fSizeh1: '70px',
47
+ fSizeh2: '50px',
48
+ fSizeh3: '38px',
49
+ fSizeh4: '24px',
50
+ fSizeh5: '20px',
51
+ fSizeh6: '14px',
52
+ fWeightp: '500',
53
+ fWeighth1: '400',
54
+ fWeighth2: '400',
55
+ fWeighth3: '400',
56
+ fWeighth4: '600',
57
+ fWeighth5: '600',
58
+ fWeighth6: '600',
59
+ fSizespan: '12px',
60
+ fWeightspan: '500',
61
+ }
62
+ };
@@ -1,66 +0,0 @@
1
- .btn {
2
- text-transform: none;
3
- font-size: 16px;
4
- line-height: 20px;
5
- padding: 12px 20px;
6
- border-radius: 6px;
7
- border: none;
8
- outline: none;
9
- box-sizing: border-box;
10
- transition: background-color 240ms, color 240ms;
11
- overflow: hidden;
12
- cursor: pointer;
13
- min-height: 46px;
14
- max-height: 46px;
15
- }
16
-
17
- .btn.full-size {
18
- width: 100%;
19
- }
20
-
21
- .btn.content-size {
22
- width: auto;
23
- }
24
-
25
- .btn.size-default {
26
-
27
- }
28
-
29
- .btn.type-filled {
30
- background-color: rgba(0, 35, 106, 1);
31
- color: rgba(255, 255, 255, 1);
32
- }
33
-
34
- .btn.type-filled:hover {
35
- background-color: rgba(0, 23, 69, 1);
36
- }
37
-
38
- .btn.type-filled:disabled {
39
- background-color: rgba(238, 238, 238, 1);
40
- color: rgba(60, 57, 62, 1);
41
- pointer-events: none;
42
- }
43
-
44
- .btn.type-filled.with-icon {
45
-
46
- }
47
-
48
- .btn.type-outline {
49
- background-color: rgba(255, 255, 255, 1);
50
- box-shadow: 0 0 0 2px rgba(0, 35, 106, 1) inset;
51
- }
52
-
53
- .btn.type-outline:hover {
54
- color: rgba(255, 255, 255, 1);
55
- background-color: rgba(0, 23, 69, 1);
56
- }
57
-
58
- .btn.type-outline:disabled {
59
- color: rgba(60, 57, 62, 1);
60
- box-shadow: 0 0 0 2px rgba(238, 238, 238, 1) inset;
61
- pointer-events: none;
62
- }
63
-
64
- .btn.type-outline.with-icon {
65
-
66
- }