Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCT 1079 - filters Chip #2937

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

smooth!

);
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
Loading