-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
90a9350
commit ae4d20a
Showing
18 changed files
with
1,083 additions
and
527 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ export default { | |
'color', | ||
'framer-motion', | ||
'fuse.js', | ||
'jsonpath-plus', | ||
'lodash', | ||
'moment', | ||
'react', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { createUseStyles } from 'react-jss' | ||
import { Tooltip } from 'components/Tooltip' | ||
import React, { FC, SyntheticEvent, useState } from 'react' | ||
|
||
const useStyles = createUseStyles({ | ||
container: { display: 'grid', placeItems: 'stretch' }, | ||
text: { | ||
display: 'block', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap' | ||
}, | ||
wrapper: { | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap' | ||
} | ||
}) | ||
|
||
interface CellWithTooltipProps { | ||
text: string | ||
} | ||
|
||
export const CellWithTooltip: FC<CellWithTooltipProps> = ({ | ||
text | ||
}: CellWithTooltipProps) => { | ||
const [hasTooltip, setHasTooltip] = useState(false) | ||
|
||
const classes = useStyles() | ||
|
||
return ( | ||
<div className={classes.container}> | ||
<div | ||
className={classes.wrapper} | ||
onMouseEnter={(e: SyntheticEvent) => { | ||
const el = e.currentTarget as HTMLElement | ||
|
||
setHasTooltip(el.scrollWidth > el.offsetWidth) | ||
}} | ||
> | ||
{hasTooltip ? ( | ||
<Tooltip placement='bottomLeft' title={text}> | ||
{text} | ||
</Tooltip> | ||
) : ( | ||
text | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import cn from 'classnames' | ||
import { createUseStyles } from 'react-jss' | ||
import { defaultIconHeight } from './utils' | ||
import { styleguide } from 'components/assets/styles' | ||
import { Tooltip } from 'components/Tooltip' | ||
import { Icon, IconProps } from '../Icon' | ||
import React, { FC } from 'react' | ||
|
||
const { spacing } = styleguide | ||
|
||
const useStyles = createUseStyles({ | ||
count: { borderBottom: '1px solid', marginLeft: spacing.s }, | ||
icon: { | ||
'&:not(:last-child)': { | ||
marginRight: spacing.s | ||
} | ||
}, | ||
iconInTooltip: { | ||
marginBottom: spacing.s, | ||
marginRight: spacing.s | ||
}, | ||
tooltip: { | ||
'&.ant-tooltip': { | ||
'& > .ant-tooltip-content > .ant-tooltip-inner': { | ||
padding: `${spacing.s}px 0 0 ${spacing.s}px` | ||
}, | ||
maxWidth: 250 - spacing.s | ||
} | ||
} | ||
}) | ||
|
||
interface Props { | ||
iconPropsArr: IconProps[] | ||
height?: number | ||
truncateLength?: number | ||
} | ||
|
||
export const MultipleIcons: FC<Props> = ({ | ||
iconPropsArr = [], | ||
height = defaultIconHeight, | ||
truncateLength = 2 | ||
}: Props) => { | ||
const classes = useStyles() | ||
|
||
interface RenderIcons { | ||
sliceStartIndex: number | ||
sliceEndIndex?: number | ||
isInsideTooltip?: boolean | ||
} | ||
const renderIcons = ({ | ||
sliceStartIndex, | ||
sliceEndIndex, | ||
isInsideTooltip | ||
}: RenderIcons) => | ||
iconPropsArr | ||
.slice(sliceStartIndex, sliceEndIndex) | ||
.map((iconProps, i) => { | ||
return ( | ||
<Icon | ||
{...iconProps} | ||
classes={[ | ||
cn({ | ||
[classes.icon]: true, | ||
[classes.iconInTooltip]: isInsideTooltip | ||
}) | ||
]} | ||
height={height} | ||
key={i} | ||
/> | ||
) | ||
}) | ||
|
||
return ( | ||
<> | ||
{renderIcons({ sliceEndIndex: truncateLength, sliceStartIndex: 0 })} | ||
{truncateLength < iconPropsArr.length && ( | ||
<Tooltip | ||
classes={[classes.tooltip]} | ||
placement='bottom' | ||
renderWithoutDataTag | ||
title={renderIcons({ | ||
isInsideTooltip: true, | ||
sliceStartIndex: truncateLength | ||
})} | ||
triggerMode='click' | ||
> | ||
<span | ||
className={classes.count} | ||
onClick={e => | ||
// this is to prevent the entire row from being clicked | ||
e.stopPropagation() | ||
} | ||
> | ||
+{iconPropsArr.length - truncateLength} | ||
</span> | ||
</Tooltip> | ||
)} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.