odaptos_design_system 2.0.1 → 2.0.2
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/Atoms/Typography/Text.d.ts +2 -1
- package/dist/odaptos_design_system.cjs.development.js +21 -2
- package/dist/odaptos_design_system.cjs.development.js.map +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js.map +1 -1
- package/dist/odaptos_design_system.esm.js +21 -2
- package/dist/odaptos_design_system.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Atoms/Tag/Tag.tsx +45 -23
- package/src/Atoms/Typography/Text.tsx +3 -0
package/package.json
CHANGED
package/src/Atoms/Tag/Tag.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, useEffect, useState } from 'react';
|
|
2
2
|
import styles from './Tag.modules.scss';
|
|
3
|
-
import { Text } from '../..';
|
|
3
|
+
import { Text, Tooltip } from '../..';
|
|
4
4
|
import { colord, extend } from 'colord';
|
|
5
5
|
import mixPlugin from 'colord/plugins/mix';
|
|
6
6
|
import { getReadableTextColor } from '../../utils/getReadableTextColor';
|
|
@@ -82,31 +82,53 @@ export const Tag = ({
|
|
|
82
82
|
else return 'sm';
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
const [isEllipsisActive, setIsEllipsisActive] = useState(false);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const checkEllipsis = () => {
|
|
89
|
+
const element = document.querySelector('#tag_text') as HTMLElement;
|
|
90
|
+
if (element) {
|
|
91
|
+
setIsEllipsisActive(element.scrollWidth > element.clientWidth);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
checkEllipsis();
|
|
96
|
+
window.addEventListener('resize', checkEllipsis);
|
|
97
|
+
return () => window.removeEventListener('resize', checkEllipsis);
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
85
100
|
return (
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
className
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{(amountNumber || amountNumber === 0) && (
|
|
101
|
+
<Tooltip tooltipDescription={text} arrow isTooltipActive={isEllipsisActive}>
|
|
102
|
+
<div
|
|
103
|
+
{...props}
|
|
104
|
+
style={{ backgroundColor: customColor }}
|
|
105
|
+
className={`${styles.tag} ${getTagStatus()} ${getTagSize()} ${
|
|
106
|
+
className ?? ''
|
|
107
|
+
} ${canBeRemoved && styles.canBeRemoved}`}
|
|
108
|
+
>
|
|
109
|
+
{iconLeft &&
|
|
110
|
+
React.cloneElement(iconLeft, {
|
|
111
|
+
style: { fill: getTextColor(), stroke: getTextColor() },
|
|
112
|
+
})}
|
|
99
113
|
<Text
|
|
100
|
-
|
|
101
|
-
weight="bold"
|
|
114
|
+
id="tag_text"
|
|
102
115
|
size={getTextSize()}
|
|
116
|
+
text={text}
|
|
103
117
|
color={getTextColor()}
|
|
104
118
|
/>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
{(amountNumber || amountNumber === 0) && (
|
|
120
|
+
<Text
|
|
121
|
+
text={`${amountNumber}`}
|
|
122
|
+
weight="bold"
|
|
123
|
+
size={getTextSize()}
|
|
124
|
+
color={getTextColor()}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
{iconRight &&
|
|
128
|
+
React.cloneElement(iconRight, {
|
|
129
|
+
style: { fill: getTextColor(), stroke: getTextColor() },
|
|
130
|
+
})}
|
|
131
|
+
</div>
|
|
132
|
+
</Tooltip>
|
|
111
133
|
);
|
|
112
134
|
};
|
|
@@ -11,6 +11,7 @@ interface TextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
|
11
11
|
textDecoration?: 'underline' | 'line-through';
|
|
12
12
|
className?: string;
|
|
13
13
|
required?: boolean;
|
|
14
|
+
id?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/** This text should be use to display basic text
|
|
@@ -25,6 +26,7 @@ export const Text = ({
|
|
|
25
26
|
textDecoration,
|
|
26
27
|
className,
|
|
27
28
|
required,
|
|
29
|
+
id,
|
|
28
30
|
...props
|
|
29
31
|
}: TextProps) => {
|
|
30
32
|
const getTextSize = (): string => {
|
|
@@ -53,6 +55,7 @@ export const Text = ({
|
|
|
53
55
|
return (
|
|
54
56
|
<p
|
|
55
57
|
{...props}
|
|
58
|
+
id={id}
|
|
56
59
|
style={{ color: color }}
|
|
57
60
|
className={`${styles.text} ${
|
|
58
61
|
italic ? styles.text_italic : ''
|