Skip to content

Commit

Permalink
FCT 1079 - filters Chip (#2937)
Browse files Browse the repository at this point in the history
* chore(rebase): update filters files

* chore(filters chip): remove local dev tag from Filters story so that reviewers can see component in preview storybook

* chore(rebase): update filters files

* fix(chip styles): disabled text color now colorNeutral40

* chore(rebase): update filters files
  • Loading branch information
ByronDWall authored Oct 7, 2024
1 parent e7df60b commit 73f1f8e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { screen, render } from '../../../../../../test/test-utils';
import Chip from './chip';

/**
* THIS IS A PLACEHOLDER, PLEASE UPDATE IT
*/
describe('FilterMenu Chip', () => {
it('should render the chip', async () => {
await render(<Chip />);
await screen.findByText('chip');
await render(<Chip label="test" />);
const chip = await screen.findByRole('listitem');
expect(chip.textContent).toEqual('test');
});
});
39 changes: 37 additions & 2 deletions packages/components/filters/src/filter-menu/chip/chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
function Chip() {
return <div>chip</div>;
import { type ReactNode } from 'react';
import { designTokens } from '@commercetools-uikit/design-system';
import { css } from '@emotion/react';

export type TFilterMenuChipProps = {
isDisabled?: boolean;
label: ReactNode;
};

const chipStyles = css`
font-size: ${designTokens.fontSize20};
font-weight: ${designTokens.fontWeight400};
line-height: ${designTokens.lineHeight20};
color: ${designTokens.colorPrimary20};
background-color: ${designTokens.colorPrimary95};
height: ${designTokens.spacing40};
padding: 0 ${designTokens.spacing20};
border-radius: calc(
${designTokens.borderRadius20} - ${designTokens.borderRadius4}
);
display: inline-flex;
justify-content: center;
align-items: center;
list-style: none;
`;

const disabledChipStyles = css`
color: ${designTokens.colorNeutral40};
background-color: ${designTokens.colorNeutral90};
`;

function Chip(props: TFilterMenuChipProps) {
return (
<li css={[chipStyles, props.isDisabled && disabledChipStyles]}>
{props.label}
</li>
);
}

export default Chip;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Chip } from '../chip';

export type TFilterMenuTriggerButtonProps = {
label: string;
};
Expand All @@ -8,7 +6,6 @@ const TriggerButton = (props: TFilterMenuTriggerButtonProps) => {
return (
<button>
<div>{props.label}</div>
<Chip />
</button>
);
};
Expand Down
1 change: 1 addition & 0 deletions packages/components/filters/src/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function Filters(props: TFiltersProps) {
return (
<div style={{ display: 'flex', gap: designTokens.spacing20 }}>
<div>{props.label}</div>
<div style={{ display: 'flex', gap: designTokens.spacing20 }}></div>
</div>
);
}
Expand Down

0 comments on commit 73f1f8e

Please sign in to comment.