Skip to content

Commit

Permalink
feat(TMC-2505): integrate status dot to tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
VolodymyrKovalM committed Oct 31, 2024
1 parent f59e03c commit 06ae686
Show file tree
Hide file tree
Showing 25 changed files with 214 additions and 189 deletions.

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
Expand Up @@ -14,18 +14,23 @@ export const variants = {
warning: 'warning',
};

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

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

StatusBubblePrimitive.displayName = 'StatusBubblePrimitive';
StatusDotPrimitive.displayName = 'StatusDotPrimitive';

export default StatusBubblePrimitive;
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
2 changes: 1 addition & 1 deletion packages/design-system/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export * from './components/RatioBar';
export * from './components/RichRadioButton';
export * from './components/Skeleton';
export * from './components/Status';
export * from './components/StatusBubble';
export * from './components/StatusDot';
export * from './components/Stepper';
export * from './components/Switch';
export * from './components/Tabs';
Expand Down

This file was deleted.

Loading

0 comments on commit 06ae686

Please sign in to comment.