Skip to content

Commit

Permalink
feat: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasdano committed Dec 16, 2024
1 parent 414f1eb commit 761adbb
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/components/TabStepper/components/TabStep/TabStep.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import React, { useMemo } from 'react';
import React from 'react';
import { Tab as ReactAriaTab } from 'react-aria-components';

import { stepContainer, stepStyles, stepSubtitle, stepTitle } from './TabStep.style';
import type { TabStepProps } from '../../types';

import type { AcceptedIconNames } from '~/components/Icon';
import Icon from '~/components/Icon';
import useTheme from '~/hooks/useTheme';
import type { SemanticColorsKey } from '~/theme/tokens/semantic/colors';

const STATUS_ICON = {
done: {
name: 'success' as AcceptedIconNames,
color: 'indicators.brand' as SemanticColorsKey,
},
warning: {
name: 'warning' as AcceptedIconNames,
color: 'indicators.error' as SemanticColorsKey,
},
};

const TabStep = React.forwardRef<HTMLDivElement, TabStepProps>((props, ref) => {
const { children, id, title, subtitle, status = 'pending', dataTestPrefixId, ...rest } = props;
Expand All @@ -14,21 +27,7 @@ const TabStep = React.forwardRef<HTMLDivElement, TabStepProps>((props, ref) => {

const theme = useTheme();

const iconName = useMemo(() => {
if (status === 'done') {
return 'success';
}

return 'warning';
}, [status]);

const iconColor = useMemo(() => {
if (status === 'done') {
return 'indicators.brand';
}

return 'indicators.error';
}, [status]);
const icon = status !== 'pending' ? STATUS_ICON[status] : null;

return (
<ReactAriaTab id={id} {...rest} ref={ref} css={stepStyles()} data-status={status}>
Expand All @@ -39,8 +38,8 @@ const TabStep = React.forwardRef<HTMLDivElement, TabStepProps>((props, ref) => {
{title}
{hasIcon && (
<Icon
name={iconName}
color={theme.tokens.colors.get(iconColor)}
name={icon.name}
color={theme.tokens.colors.get(icon.color)}
dataTestPrefixId={`${dataTestPrefixId}_icon`}
/>
)}
Expand Down

0 comments on commit 761adbb

Please sign in to comment.