Skip to content

Commit

Permalink
feat(Badge): remove icon and text variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnau-mnau committed Oct 17, 2023
1 parent 9c4ca93 commit 9e1afbc
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 41 deletions.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 0 additions & 16 deletions src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,3 @@ ErrorBadge.args = {
...SimpleBadge.args,
variant: 'error',
};

export const TextBadge = BadgeTemplate.bind({});
TextBadge.args = {
...SimpleBadge.args,
variant: 'info',
count: undefined,
text: 'New',
};
export const TextBadgeWithIcon = BadgeTemplate.bind({});
TextBadgeWithIcon.args = {
...SimpleBadge.args,
variant: 'info',
count: undefined,
text: 'New',
iconName: 'lightbulb',
};
22 changes: 2 additions & 20 deletions src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import {
} from '../../utils';
import { CLX_COMPONENT } from '../../theme/constants';
import { SpaceSizes } from '../../theme';
import { SSCIcons, Types } from '../Icon/Icon.types';
import { IconTypes, SSCIconNames } from '../../theme/icons/icons.enums';
import { Icon } from '../Icon';
import { Inline, Padbox } from '../layout';
import { Padbox } from '../layout';

const BadgeNeutral = css`
background-color: ${getColor('neutral.300')};
Expand Down Expand Up @@ -65,34 +62,19 @@ const normalizeCount = pipe(defaultWhen(lte(100), '99+'));

const Badge: React.FC<BadgeProps> = ({
count,
text,
iconName,
iconType,
variant = BadgeVariants.error,
}) => (
<BadgeElement
$variant={variant}
className={CLX_COMPONENT}
paddingSize={SpaceSizes.sm}
>
<Inline align="center" as="span" gap="sm" justify="center">
{iconName ? <Icon name={iconName} type={iconType} /> : null}
<span>{count ? normalizeCount(count) : text}</span>
</Inline>
<span>{normalizeCount(count)}</span>
</BadgeElement>
);

Badge.propTypes = {
count: PropTypes.number,
text: PropTypes.string,
iconName: PropTypes.oneOfType([
PropTypes.oneOf<SSCIcons>(Object.values(SSCIconNames)),
PropTypes.string,
]),
iconType: PropTypes.oneOfType([
PropTypes.oneOf<Types>(Object.values(IconTypes)),
PropTypes.string,
]),
};

export default Badge;
4 changes: 0 additions & 4 deletions src/components/Badge/Badge.types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Types as IconTypes, SSCIcons } from '../Icon/Icon.types';
import { BadgeVariants } from './Badge.enums';

export type BadgeVariant = typeof BadgeVariants[keyof typeof BadgeVariants];

export interface BadgeProps {
count?: number;
text?: string;
variant?: BadgeElementProps['$variant'];
className?: string;
iconName?: SSCIcons | string;
iconType?: IconTypes | string;
}

export interface BadgeElementProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { SSCIconNames } from '../../../../theme/icons/icons.enums';
import { Button } from '../../../Button';
import { Badge } from '../../../Badge';
import { Pill } from '../../../Pill';
import { Inline } from '../../../layout';
import { SSCIcons } from '../../../Icon/Icon.types';
import { ControlButtonProps } from './ControlButton.types';
Expand All @@ -28,7 +29,7 @@ const ControlButton: React.FC<ControlButtonProps> = ({
<span>{label}</span>
{appliedFilters > 0 && <Badge count={appliedFilters} variant="neutral" />}
{hiddenColumns > 0 && (
<Badge text={`${hiddenColumns} hidden`} variant="neutral" />
<Pill color="gray" label={`${hiddenColumns} hidden`} />
)}
</Inline>
</Button>
Expand Down

0 comments on commit 9e1afbc

Please sign in to comment.