Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaustubh9031 committed Jan 3, 2025
1 parent d99be12 commit 286c17a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Filter/LabelFilter/LabelFilter.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Label } from "../../LabelSelector/Label.types";
import LabelFilter from "./LabelFilter";
import { LabelFilter } from "./LabelFilter";
import React from "react";
import { action } from "@storybook/addon-actions";

Expand Down
2 changes: 1 addition & 1 deletion src/Filter/LabelFilter/LabelFilter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import { describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";

import LabelFilter from "./LabelFilter";
import { LabelFilter } from "./LabelFilter";
import { LabelFilterProps } from "./LabelFilter.types";
import userEvent from "@testing-library/user-event";

Expand Down
6 changes: 3 additions & 3 deletions src/Filter/LabelFilter/LabelFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { VirtualizedAutocomplete } from "../../Autocomplete/Autocomplete";
/**
* A label filter allows the user to select multiple labels from a list.
*/
export default function LabelFilter({
export function LabelFilter({
value = [],
limitTags = -1,
...props
Expand Down Expand Up @@ -73,10 +73,11 @@ function Tags(
const { value = [], onChange = () => {} } = ownerState;
return labels.map((label, index) => (
<LabelChip
{...getTagProps({ index })}
key={label._id}
label={label.name}
color={label.color}
style={{ marginLeft: 2 }}
sx={{ marginLeft: 2 }}
onDelete={e => {
// Remove label from the value
const updatedValue = value.filter(l => l._id !== label._id);
Expand All @@ -90,7 +91,6 @@ function Tags(
));
}

// Render label options
/**
* Renders a single option in the dropdown for selection.
* @param props - HTML attributes for the list item element.
Expand Down
3 changes: 0 additions & 3 deletions src/Filter/LabelFilter/LabelFilter.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Label } from "../../LabelSelector/Label.types";
import LabelFilter from "./LabelFilter";

/**
* Props definition for the LabelFilter component
Expand Down Expand Up @@ -32,5 +31,3 @@ export type LabelFilterProps = {
*/
value?: Label[];
};

export default LabelFilter as React.FC<LabelFilterProps>;
2 changes: 2 additions & 0 deletions src/Filter/LabelFilter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { LabelFilter } from "./LabelFilter";
export type { LabelFilterProps } from "./LabelFilter.types";
6 changes: 3 additions & 3 deletions src/Filter/SidebarFilter/SidebarFilter.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, StoryFn } from "@storybook/react";

import CheckboxFilter from "../CheckboxFilter/CheckboxFilter";
import LabelFilter from "../LabelFilter/LabelFilter";
import { LabelFilter } from "../LabelFilter/LabelFilter";
import React from "react";
import { SidebarFilter } from "./SidebarFilter";
import { SidebarFilterProps } from "./SidebarFilter.types";
Expand All @@ -24,8 +24,8 @@ const meta: Meta<typeof SidebarFilter> = {

// standard options
const labelOptions = [
{ _id: 1, color: "#005FA8", description: "first label", name: "label 1" },
{ _id: 2, color: "#f542e0", description: "second label", name: "label 2" }
{ _id: "1", color: "#005FA8", description: "first label", name: "label 1" },
{ _id: "2", color: "#f542e0", description: "second label", name: "label 2" }
];
const checkboxOptions = ["Option 1", "Option 2", "Option 3"];

Expand Down
5 changes: 1 addition & 4 deletions src/Filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ export {
default as CheckboxFilter,
type CheckboxFilterProps
} from "./CheckboxFilter";
export {
default as LabelFilter,
type LabelFilterProps
} from "./LabelFilter/LabelFilter.types";
export { LabelFilter, type LabelFilterProps } from "./LabelFilter";
export { default as RangeFilter, type RangeFilterProps } from "./RangeFilter";

export { SidebarFilter, type SidebarFilterProps } from "./SidebarFilter";
Expand Down

0 comments on commit 286c17a

Please sign in to comment.