Skip to content

Commit

Permalink
feat(TMC-2505): integrate status dot to tabs component (#5439)
Browse files Browse the repository at this point in the history
* feat(TMC-2505): integrate status dot to tabs component

* feat(TMC-2505): integrate status dot to tabs component

* feat(TMC-2505): integrate status dot to tabs component
  • Loading branch information
VolodymyrKovalM authored Nov 4, 2024
1 parent f59e03c commit dea4b37
Show file tree
Hide file tree
Showing 27 changed files with 245 additions and 215 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-vans-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/design-system': minor
---

feat(TMC-2505): integrate status dot to tabs component

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions packages/design-system/src/components/StatusBubble/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use '@talend/design-tokens/lib/tokens' as tokens;

.statusBubble {
.statusDot {
display: block;
width: tokens.$coral-spacing-xs;
height: tokens.$coral-spacing-xs;
Expand Down
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 StatusDot, { variants } from './StatusDotPrimitive';

describe('StatusDot', (): void => {
it('Should render', (): void => {
render(<StatusDot variant={variants.success} data-testid="my-status-dot-component" />);

expect(screen.getByTestId('my-status-dot-component')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { forwardRef, Ref } from 'react';

import classnames from 'classnames';

import { DataAttributes } from '../../../types';

import styles from './StatusDotPrimitive.module.scss';

export const variants = {
beta: 'beta',
error: 'error',
information: 'information',
success: 'success',
warning: 'warning',
};

export type StatusDotProps = {
variant: string;
className?: string;
} & DataAttributes;

const StatusDotPrimitive = forwardRef(
({ variant, className, ...rest }: StatusDotProps, ref: Ref<HTMLSpanElement>) => {
return (
<span
className={classnames(styles.statusDot, styles[variant], className)}
ref={ref}
{...rest}
/>
);
},
);

StatusDotPrimitive.displayName = 'StatusDotPrimitive';

export default StatusDotPrimitive;
27 changes: 27 additions & 0 deletions packages/design-system/src/components/StatusDot/StatusDot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { forwardRef, Ref } from 'react';

import { StatusDotProps, variants } from './Primitive/StatusDotPrimitive';
import StatusDotBeta from './variations/StatusDotBeta';
import StatusDotError from './variations/StatusDotError';
import StatusDotInformation from './variations/StatusDotInformation';
import StatusDotSuccess from './variations/StatusDotSuccess';
import StatusDotWarning from './variations/StatusDotWarning';

const StatusBubble = forwardRef((props: StatusDotProps, ref: Ref<HTMLSpanElement>) => {
switch (props.variant) {
case variants.beta:
return <StatusDotBeta {...props} ref={ref} />;
case variants.error:
return <StatusDotError {...props} ref={ref} />;
case variants.information:
return <StatusDotInformation {...props} ref={ref} />;
case variants.success:
return <StatusDotSuccess {...props} ref={ref} />;
case variants.warning:
return <StatusDotWarning {...props} ref={ref} />;
default:
return null;
}
});

export default StatusBubble;
15 changes: 15 additions & 0 deletions packages/design-system/src/components/StatusDot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import StatusDot from './StatusDot';
import StatusDotBeta from './variations/StatusDotBeta';
import StatusDotError from './variations/StatusDotError';
import StatusDotInformation from './variations/StatusDotInformation';
import StatusDotSuccess from './variations/StatusDotSuccess';
import StatusDotWarning from './variations/StatusDotWarning';

export {
StatusDot,
StatusDotBeta,
StatusDotError,
StatusDotInformation,
StatusDotSuccess,
StatusDotWarning,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { forwardRef, Ref } from 'react';

import StatusDotPrimitive, { StatusDotProps, variants } from '../Primitive/StatusDotPrimitive';

export type StatusDotBetaProps = Omit<StatusDotProps, 'variant'>;

const StatusDotBeta = forwardRef((props: StatusDotBetaProps, ref: Ref<HTMLSpanElement>) => {
return <StatusDotPrimitive variant={variants.beta} ref={ref} {...props} />;
});

StatusDotBeta.displayName = 'StatusDotBeta';

export default StatusDotBeta;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { forwardRef, Ref } from 'react';

import StatusDotPrimitive, { StatusDotProps, variants } from '../Primitive/StatusDotPrimitive';

export type StatusDotErrorProps = Omit<StatusDotProps, 'variant'>;

const StatusDotError = forwardRef((props: StatusDotErrorProps, ref: Ref<HTMLSpanElement>) => {
return <StatusDotPrimitive variant={variants.error} ref={ref} {...props} />;
});

StatusDotError.displayName = 'StatusDotError';

export default StatusDotError;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { forwardRef, Ref } from 'react';

import StatusDotPrimitive, { StatusDotProps, variants } from '../Primitive/StatusDotPrimitive';

export type StatusDotInformationProps = Omit<StatusDotProps, 'variant'>;

const StatusDotInformation = forwardRef(
(props: StatusDotInformationProps, ref: Ref<HTMLSpanElement>) => {
return <StatusDotPrimitive variant={variants.information} ref={ref} {...props} />;
},
);

StatusDotInformation.displayName = 'StatusDotInformation';

export default StatusDotInformation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { forwardRef, Ref } from 'react';

import StatusDotPrimitive, { StatusDotProps, variants } from '../Primitive/StatusDotPrimitive';

export type StatusDotSuccessProps = Omit<StatusDotProps, 'variant'>;

const StatusDotSuccess = forwardRef((props: StatusDotSuccessProps, ref: Ref<HTMLSpanElement>) => {
return <StatusDotPrimitive variant={variants.success} ref={ref} {...props} />;
});

StatusDotSuccess.displayName = 'StatusDotSuccess';

export default StatusDotSuccess;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { forwardRef, Ref } from 'react';

import StatusDotPrimitive, { StatusDotProps, variants } from '../Primitive/StatusDotPrimitive';

export type StatusDotWarningProps = Omit<StatusDotProps, 'variant'>;

const StatusDotWarning = forwardRef((props: StatusDotWarningProps, ref: Ref<HTMLSpanElement>) => {
return <StatusDotPrimitive variant={variants.warning} ref={ref} {...props} />;
});

StatusDotWarning.displayName = 'StatusDotWarning';

export default StatusDotWarning;
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@
transition: tokens.$coral-transition-fast;
transform: translateY(100%);
}

.statusDot {
align-self: flex-start;
}
}
3 changes: 3 additions & 0 deletions packages/design-system/src/components/Tabs/Primitive/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IconNameWithSize } from '@talend/icons';

import { SizedIcon } from '../../Icon';
import { StackHorizontal } from '../../Stack';
import { StatusDot } from '../../StatusDot';
import { TagDefault } from '../../Tag';
import { Tooltip } from '../../Tooltip';
import { TabsInternalContext } from './TabsProvider';
Expand All @@ -31,6 +32,7 @@ export type TabPropTypes = {
disabled?: boolean;
icon?: IconNameWithSize<'S'>;
tag?: string | number;
statusDot?: string;
tooltip?: string;
error?: boolean;
};
Expand All @@ -53,6 +55,7 @@ export function Tab(props: TabPropTypes) {
{props.icon && <SizedIcon size="S" name={props.icon} />}
<span className={style.tab__copy}>{props.title}</span>
{props.tag && <TagDefault>{props.tag}</TagDefault>}
{props.statusDot && <StatusDot variant={props.statusDot} className={style.statusDot} />}
</StackHorizontal>
</button>
);
Expand Down
Loading

0 comments on commit dea4b37

Please sign in to comment.