forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Fixing unreleased search preview bugs (datahub-project#5432)
- Loading branch information
1 parent
aa9ec87
commit 255a5db
Showing
5 changed files
with
67 additions
and
22 deletions.
There are no files selected for viewing
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
47 changes: 41 additions & 6 deletions
47
datahub-web-react/src/app/entity/shared/components/styled/ExpandedActorGroup.tsx
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 |
---|---|---|
@@ -1,18 +1,53 @@ | ||
import { Popover, Typography } from 'antd'; | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { CorpGroup, CorpUser } from '../../../../../types.generated'; | ||
import { ExpandedActor } from './ExpandedActor'; | ||
|
||
const PopoverActors = styled.div``; | ||
|
||
const ActorsContainer = styled.div` | ||
display: flex; | ||
justify-content: right; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
`; | ||
|
||
const RemainderText = styled(Typography.Text)` | ||
display: flex; | ||
justify-content: right; | ||
margin-right: 8px; | ||
`; | ||
|
||
type Props = { | ||
actors: Array<CorpUser | CorpGroup>; | ||
max: number; | ||
onClose?: (actor: CorpUser | CorpGroup) => void; | ||
}; | ||
|
||
export const ExpandedActorGroup = ({ actors, onClose }: Props) => { | ||
const DEFAULT_MAX = 10; | ||
|
||
export const ExpandedActorGroup = ({ actors, max = DEFAULT_MAX, onClose }: Props) => { | ||
const finalActors = actors.length > max ? actors.slice(0, max) : actors; | ||
const remainder = actors.length > max ? actors.length - max : undefined; | ||
|
||
return ( | ||
<> | ||
{actors.map((actor) => ( | ||
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} /> | ||
))} | ||
</> | ||
<Popover | ||
placement="left" | ||
content={ | ||
<PopoverActors> | ||
{actors.map((actor) => ( | ||
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} /> | ||
))} | ||
</PopoverActors> | ||
} | ||
> | ||
<ActorsContainer> | ||
{finalActors.map((actor) => ( | ||
<ExpandedActor key={actor.urn} actor={actor} onClose={() => onClose?.(actor)} /> | ||
))} | ||
</ActorsContainer> | ||
{remainder && <RemainderText type="secondary">+ {remainder} more</RemainderText>} | ||
</Popover> | ||
); | ||
}; |
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