Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8373 from vigneshm/artifact-list-status-bubble
feat(core/managed): Add status bubble in artifact list
- Loading branch information
Showing
4 changed files
with
96 additions
and
24 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
15 changes: 15 additions & 0 deletions
15
app/scripts/modules/core/src/managed/StatusBubbleStack.less
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,15 @@ | ||
.StatusBubbleContainer { | ||
background-color: var(--color-alabaster); | ||
border-radius: 50%; | ||
padding: 2px; | ||
margin-left: -8px; | ||
} | ||
|
||
.HiddenStatusCount { | ||
border-radius: 50%; | ||
background-color: var(--color-status-neutral); | ||
color: var(--color-white); | ||
margin-left: -4px; | ||
margin-right: 6px; | ||
padding: 4px 8px; | ||
} |
37 changes: 37 additions & 0 deletions
37
app/scripts/modules/core/src/managed/StatusBubbleStack.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { take } from 'lodash'; | ||
|
||
import { IStatusBubbleProps, StatusBubble } from './StatusBubble'; | ||
|
||
import './StatusBubbleStack.less'; | ||
|
||
export interface IStatusBubbleStackProps { | ||
borderColor: string; | ||
maxBubbles: number; | ||
statuses: Array<Pick<IStatusBubbleProps, 'iconName' | 'appearance'>>; | ||
} | ||
|
||
export const StatusBubbleStack = ({ borderColor, maxBubbles, statuses }: IStatusBubbleStackProps) => { | ||
// We only have limited space in the UI and we cannot show all the statuses in the stack, so only take the first few | ||
// important statuses. | ||
const statusBubblesToRender = take(statuses, statuses.length <= maxBubbles ? maxBubbles : maxBubbles - 1); | ||
const hiddenStatusBubbleCount = statuses.length - statusBubblesToRender.length; | ||
|
||
return ( | ||
<div className="flex-container-h middle sp-margin-s-right"> | ||
{statusBubblesToRender.map((status, index) => ( | ||
<div | ||
className="StatusBubbleContainer" | ||
key={status.iconName} | ||
style={{ | ||
backgroundColor: borderColor, | ||
zIndex: statusBubblesToRender.length - index, | ||
}} | ||
> | ||
<StatusBubble iconName={status.iconName} appearance={status.appearance} size="small" /> | ||
</div> | ||
))} | ||
{!!hiddenStatusBubbleCount && <div className="HiddenStatusCount">+{hiddenStatusBubbleCount}</div>} | ||
</div> | ||
); | ||
}; |