-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TMC-2505/webapp): implement status bubble component (#5436)
* feat(TMC-2505): implement status bubble component * feat(TMC-2505): implement status bubble component * feat(TMC-2505): implement status bubble component * fix tests in forms package
- Loading branch information
1 parent
555b9f5
commit 76ac44b
Showing
16 changed files
with
269 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@talend/design-system': minor | ||
--- | ||
|
||
feat(TMC-2505/webapp): implement status bubble component |
29 changes: 29 additions & 0 deletions
29
...ges/design-system/src/components/StatusBubble/Primitive/StatusBubblePrimitive.module.scss
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,29 @@ | ||
@use '@talend/design-tokens/lib/tokens' as tokens; | ||
|
||
.statusBubble { | ||
display: block; | ||
width: tokens.$coral-spacing-xs; | ||
height: tokens.$coral-spacing-xs; | ||
border-radius: 50%; | ||
|
||
&.beta { | ||
background-color: tokens.$coral-color-beta-icon; | ||
} | ||
|
||
&.error { | ||
background-color: tokens.$coral-color-danger-icon; | ||
} | ||
|
||
&.information { | ||
background-color: tokens.$coral-color-info-icon; | ||
} | ||
|
||
&.success { | ||
background-color: tokens.$coral-color-success-icon; | ||
} | ||
|
||
&.warning { | ||
background-color: tokens.$coral-color-warning-icon; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
packages/design-system/src/components/StatusBubble/Primitive/StatusBubblePrimitive.test.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,12 @@ | ||
import { describe, expect, it } from '@jest/globals'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import StatusBubble, { variants } from './StatusBubblePrimitive'; | ||
|
||
describe('StatusBubble', (): void => { | ||
it('Should render', (): void => { | ||
render(<StatusBubble variant={variants.success} data-testid="my-status-bubble-component" />); | ||
|
||
expect(screen.getByTestId('my-status-bubble-component')).toBeVisible(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/design-system/src/components/StatusBubble/Primitive/StatusBubblePrimitive.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,31 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import classnames from 'classnames'; | ||
|
||
import { DataAttributes } from '../../../types'; | ||
|
||
import styles from './StatusBubblePrimitive.module.scss'; | ||
|
||
export const variants = { | ||
beta: 'beta', | ||
error: 'error', | ||
information: 'information', | ||
success: 'success', | ||
warning: 'warning', | ||
}; | ||
|
||
export type StatusBubbleProps = { | ||
variant: string; | ||
} & DataAttributes; | ||
|
||
const StatusBubblePrimitive = forwardRef( | ||
({ variant, ...rest }: StatusBubbleProps, ref: Ref<HTMLSpanElement>) => { | ||
return ( | ||
<span className={classnames(styles.statusBubble, styles[variant])} ref={ref} {...rest} /> | ||
); | ||
}, | ||
); | ||
|
||
StatusBubblePrimitive.displayName = 'StatusBubblePrimitive'; | ||
|
||
export default StatusBubblePrimitive; |
27 changes: 27 additions & 0 deletions
27
packages/design-system/src/components/StatusBubble/StatusBubble.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,27 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import { StatusBubbleProps, variants } from './Primitive/StatusBubblePrimitive'; | ||
import StatusBubbleBeta from './variations/StatusBubbleBeta'; | ||
import StatusBubbleError from './variations/StatusBubbleError'; | ||
import StatusBubbleInformation from './variations/StatusBubbleInformation'; | ||
import StatusBubbleSuccess from './variations/StatusBubbleSuccess'; | ||
import StatusBubbleWarning from './variations/StatusBubbleWarning'; | ||
|
||
const StatusBubble = forwardRef((props: StatusBubbleProps, ref: Ref<HTMLSpanElement>) => { | ||
switch (props.variant) { | ||
case variants.beta: | ||
return <StatusBubbleBeta {...props} ref={ref} />; | ||
case variants.error: | ||
return <StatusBubbleError {...props} ref={ref} />; | ||
case variants.information: | ||
return <StatusBubbleInformation {...props} ref={ref} />; | ||
case variants.success: | ||
return <StatusBubbleSuccess {...props} ref={ref} />; | ||
case variants.warning: | ||
return <StatusBubbleWarning {...props} ref={ref} />; | ||
default: | ||
return null; | ||
} | ||
}); | ||
|
||
export default StatusBubble; |
15 changes: 15 additions & 0 deletions
15
packages/design-system/src/components/StatusBubble/index.ts
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 @@ | ||
import StatusBubble from './StatusBubble'; | ||
import StatusBubbleBeta from './variations/StatusBubbleBeta'; | ||
import StatusBubbleError from './variations/StatusBubbleError'; | ||
import StatusBubbleInformation from './variations/StatusBubbleInformation'; | ||
import StatusBubbleSuccess from './variations/StatusBubbleSuccess'; | ||
import StatusBubbleWarning from './variations/StatusBubbleWarning'; | ||
|
||
export { | ||
StatusBubble, | ||
StatusBubbleBeta, | ||
StatusBubbleError, | ||
StatusBubbleInformation, | ||
StatusBubbleSuccess, | ||
StatusBubbleWarning, | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/design-system/src/components/StatusBubble/variations/StatusBubbleBeta.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,16 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import StatusBubblePrimitive, { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../Primitive/StatusBubblePrimitive'; | ||
|
||
export type StatusBubbleBetaProps = Omit<StatusBubbleProps, 'variant'>; | ||
|
||
const StatusBubbleBeta = forwardRef((props: StatusBubbleBetaProps, ref: Ref<HTMLSpanElement>) => { | ||
return <StatusBubblePrimitive variant={variants.beta} ref={ref} {...props} />; | ||
}); | ||
|
||
StatusBubbleBeta.displayName = 'StatusBubbleBeta'; | ||
|
||
export default StatusBubbleBeta; |
16 changes: 16 additions & 0 deletions
16
packages/design-system/src/components/StatusBubble/variations/StatusBubbleError.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,16 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import StatusBubblePrimitive, { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../Primitive/StatusBubblePrimitive'; | ||
|
||
export type StatusBubbleErrorProps = Omit<StatusBubbleProps, 'variant'>; | ||
|
||
const StatusBubbleError = forwardRef((props: StatusBubbleErrorProps, ref: Ref<HTMLSpanElement>) => { | ||
return <StatusBubblePrimitive variant={variants.error} ref={ref} {...props} />; | ||
}); | ||
|
||
StatusBubbleError.displayName = 'StatusBubbleError'; | ||
|
||
export default StatusBubbleError; |
18 changes: 18 additions & 0 deletions
18
packages/design-system/src/components/StatusBubble/variations/StatusBubbleInformation.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,18 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import StatusBubblePrimitive, { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../Primitive/StatusBubblePrimitive'; | ||
|
||
export type StatusBubbleInformationProps = Omit<StatusBubbleProps, 'variant'>; | ||
|
||
const StatusBubbleInformation = forwardRef( | ||
(props: StatusBubbleInformationProps, ref: Ref<HTMLSpanElement>) => { | ||
return <StatusBubblePrimitive variant={variants.information} ref={ref} {...props} />; | ||
}, | ||
); | ||
|
||
StatusBubbleInformation.displayName = 'StatusBubbleInformation'; | ||
|
||
export default StatusBubbleInformation; |
18 changes: 18 additions & 0 deletions
18
packages/design-system/src/components/StatusBubble/variations/StatusBubbleSuccess.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,18 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import StatusBubblePrimitive, { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../Primitive/StatusBubblePrimitive'; | ||
|
||
export type StatusBubbleSuccessProps = Omit<StatusBubbleProps, 'variant'>; | ||
|
||
const StatusBubbleSuccess = forwardRef( | ||
(props: StatusBubbleSuccessProps, ref: Ref<HTMLSpanElement>) => { | ||
return <StatusBubblePrimitive variant={variants.success} ref={ref} {...props} />; | ||
}, | ||
); | ||
|
||
StatusBubbleSuccess.displayName = 'StatusBubbleSuccess'; | ||
|
||
export default StatusBubbleSuccess; |
18 changes: 18 additions & 0 deletions
18
packages/design-system/src/components/StatusBubble/variations/StatusBubbleWarning.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,18 @@ | ||
import { forwardRef, Ref } from 'react'; | ||
|
||
import StatusBubblePrimitive, { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../Primitive/StatusBubblePrimitive'; | ||
|
||
export type StatusBubbleWarningProps = Omit<StatusBubbleProps, 'variant'>; | ||
|
||
const StatusBubbleWarning = forwardRef( | ||
(props: StatusBubbleWarningProps, ref: Ref<HTMLSpanElement>) => { | ||
return <StatusBubblePrimitive variant={variants.warning} ref={ref} {...props} />; | ||
}, | ||
); | ||
|
||
StatusBubbleWarning.displayName = 'StatusBubbleWarning'; | ||
|
||
export default StatusBubbleWarning; |
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
21 changes: 21 additions & 0 deletions
21
packages/design-system/src/stories/feedback/StatusBubble.mdx
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,21 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/blocks'; | ||
|
||
import { FigmaImage } from '@talend/storybook-docs'; | ||
|
||
import * as Stories from './StatusBubble.stories'; | ||
import { Status } from '../Status.block'; | ||
|
||
<Meta of={Stories} /> | ||
<Status id="status" /> | ||
|
||
# StatusBubble | ||
|
||
The status bubble component displays state information using circle shape with semantic colors | ||
|
||
### Variations | ||
|
||
<Canvas of={Stories.Beta} /> | ||
<Canvas of={Stories.Error} /> | ||
<Canvas of={Stories.Information} /> | ||
<Canvas of={Stories.Success} /> | ||
<Canvas of={Stories.Warning} /> |
39 changes: 39 additions & 0 deletions
39
packages/design-system/src/stories/feedback/StatusBubble.stories.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,39 @@ | ||
import { | ||
StatusBubble, | ||
StatusBubbleBeta, | ||
StatusBubbleError, | ||
StatusBubbleInformation, | ||
StatusBubbleSuccess, | ||
StatusBubbleWarning, | ||
} from '../../'; | ||
import { | ||
StatusBubbleProps, | ||
variants, | ||
} from '../../components/StatusBubble/Primitive/StatusBubblePrimitive'; | ||
|
||
export const Beta = () => <StatusBubbleBeta />; | ||
export const Error = () => <StatusBubbleError />; | ||
export const Information = () => <StatusBubbleInformation />; | ||
export const Success = () => <StatusBubbleSuccess />; | ||
export const Warning = () => <StatusBubbleWarning />; | ||
|
||
export const Usage = (props: StatusBubbleProps) => <StatusBubble {...props} />; | ||
|
||
Usage.args = { | ||
variant: variants.beta, | ||
}; | ||
|
||
Usage.argTypes = { | ||
variant: { | ||
description: 'StatusBubble variation', | ||
options: Object.values(variants), | ||
control: { | ||
type: 'select', | ||
}, | ||
}, | ||
}; | ||
|
||
export default { | ||
title: 'Feedback/StatusBubble', | ||
component: StatusBubble, | ||
}; |
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