Skip to content

Commit eb04cf9

Browse files
committed
fix: review comments
1 parent 5fcd0d6 commit eb04cf9

File tree

8 files changed

+48
-36
lines changed

8 files changed

+48
-36
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.16-beta-7",
3+
"version": "0.1.17",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function ClipboardButton({
7575
>
7676
<button
7777
type="button"
78-
className={`dc__outline-none-imp p-0 flex dc__transparent--imp dc__no-border ${rootClassName}`}
78+
className={`dc__outline-none-imp p-0 flex dc__transparent--unstyled dc__no-border ${rootClassName}`}
7979
onMouseEnter={handleEnableTippy}
8080
onMouseLeave={handleDisableTippy}
8181
onClick={handleCopyContent}

src/Common/RJSF/common/FieldRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const FieldRowWithLabel = ({
3636
>
3737
{showLabel && (
3838
<label className="cn-7 fs-13 lh-20 fw-4 flexbox mb-0" htmlFor={id}>
39-
<Tooltip alwaysShowTippyOnHover={!!rawDescription}>
39+
<Tooltip alwaysShowTippyOnHover={!!rawDescription} content={rawDescription}>
4040
<span className={`dc__ellipsis-right ${rawDescription ? 'text-underline-dashed-300' : ''}`}>
4141
{label || DEFAULT_FIELD_TITLE}
4242
</span>

src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { IconButtonProps } from '@rjsf/utils'
1818

19-
import Tooltip from '../../../Tooltip/Tooltip'
19+
import { Tooltip } from '@Common/Tooltip'
2020
import { ReactComponent as PlusIcon } from '../../../../Assets/Icon/ic-add.svg'
2121

2222
export const AddButton = ({
@@ -31,23 +31,17 @@ export const AddButton = ({
3131

3232
return (
3333
<div className="flexbox flex-justify-start">
34-
<Tooltip
35-
showOnTruncate
36-
className="default-tt dc__word-break"
37-
arrow={false}
38-
placement="right"
39-
content={content}
34+
<button
35+
{...props}
36+
type="button"
37+
className="dc__outline-none-imp p-0 dc__transparent flex dc__gap-4 cursor dc__mxw-250"
38+
title="Add"
4039
>
41-
<button
42-
{...props}
43-
type="button"
44-
className="dc__outline-none-imp p-0 dc__transparent flex dc__gap-4 cursor dc__mxw-250"
45-
title="Add"
46-
>
47-
<PlusIcon className="icon-dim-16 fcb-5" />
40+
<PlusIcon className="icon-dim-16 fcb-5" />
41+
<Tooltip showOnTruncate placement="right" content={content}>
4842
<span className="cb-5 fs-13 lh-34 dc__truncate">{content}</span>
49-
</button>
50-
</Tooltip>
43+
</Tooltip>
44+
</button>
5145
</div>
5246
)
5347
}

src/Common/RJSF/templates/TitleField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { Tooltip } from '@Common/Tooltip'
1919

2020
export const TitleField = ({ id, title, required, description }: TitleFieldProps & Partial<Record<'description', string>>) => (
2121
<legend className="fs-13 fw-6 cn-9 lh-20 dc__no-border py-9 mb-0" id={id}>
22-
<Tooltip alwaysShowTippyOnHover={!!description}>
22+
<Tooltip alwaysShowTippyOnHover={!!description} content={description}>
2323
<span className={`${description ? 'text-underline-dashed-300' : ''}`}>{title}</span>
2424
</Tooltip>
2525
{required && <span className="cr-5">&nbsp;*</span>}

src/Common/Tooltip/Tooltip.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import TippyJS from '@tippyjs/react'
33
import { TooltipProps } from './types'
44

55
const Tooltip = ({
6-
showOnTruncate = false,
76
alwaysShowTippyOnHover = false,
7+
showOnTruncate = !alwaysShowTippyOnHover,
8+
wordBreak = true,
89
children: child,
910
...rest
1011
}: TooltipProps) => {
1112
const [isTextTruncated, setIsTextTruncated] = useState(false)
1213

1314
const refCallback = useCallback((node: HTMLDivElement) => {
1415
if (node) {
16+
// NOTE: for line-clamp we need to check scrollHeight against clientHeight since orientation
17+
// is set to vertical through -webkit-box-orient prop that is needed for line-clamp to work
18+
// see: https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp
1519
setIsTextTruncated(node.scrollWidth > node.clientWidth || node.scrollHeight > node.clientHeight)
1620
}
1721
}, [])
@@ -23,7 +27,7 @@ const Tooltip = ({
2327
arrow={false}
2428
placement="top"
2529
{...rest}
26-
className={`default-tt dc__word-break-all dc__mxw-200 ${rest.className}`}
30+
className={`default-tt ${wordBreak ? 'dc__word-break-all' : ''} dc__mxw-200 ${rest.className}`}
2731
>
2832
{cloneElement(child, { ...child.props, ref: refCallback })}
2933
</TippyJS>

src/Common/Tooltip/types.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { TippyProps } from '@tippyjs/react'
22

3-
export interface TooltipProps extends TippyProps {
4-
/**
5-
* If true, show tippy on truncate
6-
* @default false
7-
*/
8-
showOnTruncate?: boolean
9-
/**
10-
* If true, wrap with tippy irrespective of other options
11-
* @default false
12-
*/
13-
alwaysShowTippyOnHover?: boolean
14-
}
3+
type BaseTooltipProps =
4+
| {
5+
showOnTruncate?: boolean
6+
alwaysShowTippyOnHover?: never
7+
}
8+
| {
9+
/**
10+
* If true, show tippy on truncate
11+
* @default true
12+
*/
13+
showOnTruncate?: never
14+
/**
15+
* If true, wrap with tippy irrespective of other options
16+
* @default false
17+
*/
18+
alwaysShowTippyOnHover?: boolean
19+
}
20+
21+
export type TooltipProps = BaseTooltipProps &
22+
TippyProps & {
23+
/**
24+
* If true, apply dc__word-break-all
25+
* @default true
26+
*/
27+
wordBreak?: boolean
28+
}

0 commit comments

Comments
 (0)