@xaypay/tui 0.0.51 → 0.0.53

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.
@@ -19,7 +19,12 @@ export const Modal = ({
19
19
  return (
20
20
  <div className={`${styles["modal-wrap"]} modal-wrap-rem`} onClick={() => setShow(false)}>
21
21
  {type == "content" ? (
22
- <div className={`${styles["modal-content"]} modal-content-rem`}>
22
+ <div
23
+ className={`${styles["modal-content"]} modal-content-rem`}
24
+ onClick={(e) => {
25
+ e.stopPropagation();
26
+ }}
27
+ >
23
28
  <div className={`${styles["modal-top"]} modal-top-rem`}>
24
29
  <div className={`${styles["modal-title"]} modal-title-rem`}>
25
30
  <Typography variant={TypographyType.p} color="#00236A">{headerText}</Typography>
@@ -34,7 +39,12 @@ export const Modal = ({
34
39
  <div className={`${styles["modal-section"]} modal-section-rem`}>{children}</div>
35
40
  </div>
36
41
  ) : type == "images" ? (
37
- <div className={`${styles["modal-content"]} modal-content-rem`}>
42
+ <div
43
+ className={`${styles["modal-content"]} modal-content-rem`}
44
+ onClick={(e) => {
45
+ e.stopPropagation();
46
+ }}
47
+ >
38
48
  <div
39
49
  className={`${styles["close-btn"]} close-btn-rem`}
40
50
  onClick={() => setShow(false)}
@@ -0,0 +1,110 @@
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 styles from "./tooltip.module.css";
7
+
8
+ export const Tooltip = ({
9
+ type,
10
+ text,
11
+ width,
12
+ color,
13
+ height,
14
+ bgColor,
15
+ fontSize,
16
+ tBgColor,
17
+ className,
18
+ fontFamily,
19
+ borderRadius,
20
+ tBorderRadius
21
+ }) => {
22
+ const tooltipRef = createRef(null);
23
+ const [tooltipWidth, setTooltipWidth] = useState(0);
24
+ const [tooltipHeight, setTooltipHeight] = useState(0);
25
+ const [showTooltip, setShowTooltip] = useState(false);
26
+
27
+ const configStyles = compereConfigs();
28
+ const classProps = classnames(
29
+ styles['tooltip'],
30
+ className
31
+ );
32
+
33
+ useEffect(_ => {
34
+ if (!type && !text) {
35
+ alert('Add type and text on tooltip');
36
+ } else if (!type) {
37
+ alert('Add type on tooltip');
38
+ } else if (!text) {
39
+ alert('Add text on tooltip');
40
+ }
41
+ tooltipRef.current && tooltipRef.current.clientWidth && tooltipRef.current.clientWidth > 0 && setTooltipWidth(tooltipRef.current.clientWidth);
42
+ tooltipRef.current && tooltipRef.current.clientHeight && tooltipRef.current.clientHeight > 0 && setTooltipHeight(tooltipRef.current.clientHeight);
43
+ }, [type, text, tooltipWidth, tooltipRef]);
44
+
45
+ const handleShow = () => {
46
+ setShowTooltip(!showTooltip);
47
+ };
48
+
49
+ return (
50
+ <div
51
+ className={`${styles['tooltip-block']}`}
52
+ style={{
53
+ width: width ? width : configStyles.TOOLTIP.width,
54
+ height: height ? height : configStyles.TOOLTIP.height,
55
+ backgroundColor: bgColor ? bgColor : configStyles.TOOLTIP.bgColor,
56
+ }}
57
+ >
58
+ <div
59
+ ref={tooltipRef}
60
+ className={classProps}
61
+ style={{
62
+ backgroundColor: tBgColor ? tBgColor : configStyles.TOOLTIP.tBgColor,
63
+ borderRadius: tBorderRadius ? tBorderRadius : configStyles.TOOLTIP.tBorderRadius,
64
+ top: type === 'top' ? `calc(-${tooltipHeight + 7}px)` : type === 'bottom' ? 'calc(100% + 7px)' : type === 'left' || type === 'right' ? `calc(50% - ${tooltipHeight / 2}px)` : '0px',
65
+ left: type === 'top' || type === 'bottom' ? `calc(50% - ${tooltipWidth / 2}px)` : type === 'left' ? `-${tooltipWidth + 7}px` : type === 'right' ? 'calc(100% + 7px)' : '0px'
66
+ }}
67
+ >
68
+ <div
69
+ className={`${styles['tooltip-rel']}`}
70
+ >
71
+ <div
72
+ className={`${styles['tooltip-decor']}`}
73
+ style={{
74
+ backgroundColor: tBgColor ? tBgColor : configStyles.TOOLTIP.bgColor,
75
+ left: type === 'top' || type === 'bottom' ? 'calc(50% - 5px)' : type === 'right' ? '-15px' : type === 'left' ? 'calc(100% + 5px)' : '0px',
76
+ top: type === 'top' ? 'calc(100% + 5px)' : type === 'bottom' ? '-15px' : type === 'right' || type === 'left' ? 'calc(50% - 5px)' : '0px'
77
+ }}
78
+ ></div>
79
+ <p
80
+ style={{
81
+ color: color ? color : configStyles.TOOLTIP.color,
82
+ fontSize: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
83
+ lineHeight: fontSize ? fontSize : configStyles.TOOLTIP.fontSize,
84
+ fontFamily: fontFamily ? fontFamily : configStyles.TOOLTIP.fontFamily
85
+ }}
86
+ >
87
+ { text }
88
+ </p>
89
+ </div>
90
+ </div>
91
+
92
+
93
+ </div>
94
+ );
95
+ };
96
+
97
+ Tooltip.propTypes = {
98
+ width: PropTypes.string,
99
+ color: PropTypes.string,
100
+ height: PropTypes.string,
101
+ bgColor: PropTypes.string,
102
+ tBgColor: PropTypes.string,
103
+ fontSize: PropTypes.string,
104
+ className: PropTypes.string,
105
+ fontFamily: PropTypes.string,
106
+ borderRadius: PropTypes.string,
107
+ tBorderRadius: PropTypes.string,
108
+ type: PropTypes.string.isRequired,
109
+ text: PropTypes.string.isRequired,
110
+ };
@@ -0,0 +1,39 @@
1
+ .tooltip {
2
+ position: absolute;
3
+ z-index: 1;
4
+ padding: 10px;
5
+ }
6
+
7
+ .tooltip-rel {
8
+ position: relative;
9
+ display: flex;
10
+ width: auto;
11
+ height: auto;
12
+ min-width: 50px;
13
+ min-height: 20px;
14
+ align-items: center;
15
+ justify-content: center;
16
+ border-radius: 5px;
17
+ -webkit-border-radius: 5px;
18
+ -moz-border-radius: 5px;
19
+ -ms-border-radius: 5px;
20
+ -o-border-radius: 5px;
21
+ }
22
+
23
+ .tooltip-decor {
24
+ position: absolute;
25
+ width: 10px;
26
+ height: 10px;
27
+ z-index: -1;
28
+ border-radius: 2px;
29
+ -webkit-border-radius: 2px;
30
+ -moz-border-radius: 2px;
31
+ -ms-border-radius: 2px;
32
+ -o-border-radius: 2px;
33
+ transform: rotate(45deg);
34
+ -webkit-transform: rotate(45deg);
35
+ -moz-transform: rotate(45deg);
36
+ -ms-transform: rotate(45deg);
37
+ -o-transform: rotate(45deg);
38
+ }
39
+
@@ -0,0 +1,26 @@
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
+ export const Template = (args) => {
11
+ return (
12
+ <div
13
+ style={{
14
+ width: '80px',
15
+ height: '100px',
16
+ position: 'relative',
17
+ backgroundColor: 'red',
18
+ margin: '100px auto'
19
+ }}
20
+ >
21
+ <Tooltip {...args} />
22
+ </div>
23
+ );
24
+ };
25
+
26
+
@@ -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,51 @@ 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
 
19
-
20
-
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
- // );
33
-
34
- const StyledTypograpy = styled(CustomTag)`
35
- ${color ? 'color: '+color+';' : '' }
36
- ${bold ? 'font-weight: bold;' : '' }
37
- `;
18
+ export const Typography = ({
19
+ size,
20
+ weight,
21
+ onClick,
22
+ variant,
23
+ children,
24
+ className,
25
+ ...props
26
+ }) => {
27
+ const [validVariant, setValidVariant] = useState(false);
28
+
29
+ const configStyles = compereConfigs();
30
+ const classProps = classnames(className);
31
+
32
+ useEffect(() => {
33
+ if (!Object.values(TypographyType).includes(variant)) {
34
+ setValidVariant(true);
35
+ }
36
+ }, [variant]);
37
+
38
+ const tagT = React.createElement(
39
+ variant,
40
+ {
41
+ ...props,
42
+ className: classProps,
43
+ style: {
44
+ fontSize: size ? size : configStyles.TYPOGRAPHY['fSize'+variant],
45
+ fontWeight: weight ? weight : configStyles.TYPOGRAPHY['fWeight'+variant]
46
+ },
47
+ onClick: onClick ? onClick : _ => _,
48
+ },
49
+ [children]
50
+ );
38
51
 
39
52
  return (
40
- <StyledTypograpy className={classProps} onClick={onClick}> {children} </StyledTypograpy>
53
+ validVariant ? 'Please set Typography valid variant' : tagT
41
54
  );
42
55
  };
43
56
 
44
57
  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
- }
58
+ size: PropTypes.string,
59
+ weight: PropTypes.string,
60
+ onClick: PropTypes.func,
61
+ className: PropTypes.string,
62
+ variant: PropTypes.oneOf(Object.values(TypographyType)).isRequired,
56
63
  };
@@ -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} size="12px" variant={tag}>{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,3 +1,4 @@
1
+ export * from './components/tooltip';
1
2
  export * from './components/button';
2
3
  export * from './components/typography';
3
4
  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,61 @@
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
+
42
+ },
43
+ TYPOGRAPHY: {
44
+ fSizep: '13px',
45
+ fSizeh1: '70px',
46
+ fSizeh2: '50px',
47
+ fSizeh3: '38px',
48
+ fSizeh4: '24px',
49
+ fSizeh5: '20px',
50
+ fSizeh6: '14px',
51
+ fWeightp: '500',
52
+ fWeighth1: '400',
53
+ fWeighth2: '400',
54
+ fWeighth3: '400',
55
+ fWeighth4: '600',
56
+ fWeighth5: '600',
57
+ fWeighth6: '600',
58
+ fSizespan: '12px',
59
+ fWeightspan: '500',
60
+ }
61
+ };
@@ -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
- }