Skip to content

Commit

Permalink
Enhancements for filterselect and name filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jadmsaadaot committed Dec 13, 2023
1 parent ac91ef3 commit b788270
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
43 changes: 14 additions & 29 deletions epictrack-web/src/components/shared/filterSelect/FilterSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ import SingleValue from "./components/SingleValueContainer";
import DropdownIndicator from "./components/DropDownIndicator";
import { MET_Header_Font_Weight_Regular } from "../../../styles/constants";

// const useStyle = makeStyles({
// infoSelect: {
// pointerEvents: "auto",
// borderRadius: "4px",
// "& > div:first-child": {
// paddingRight: 0,
// },
// "&:hover": {
// backgroundColor: Palette.neutral.bg.main,
// },
// },
// });

const INPUT_SIZE = "0.875rem";
const FilterSelect = (props: SelectProps) => {
// const classes = useStyle();
const { name, isMulti, defaultValue } = props;
const standardDefault = isMulti ? [] : "";
const [options, setOptions] = React.useState<OptionType[]>([]);
Expand Down Expand Up @@ -92,7 +79,6 @@ const FilterSelect = (props: SelectProps) => {
};

const applyFilters = () => {
// header.column.setFilterValue(selectedOptions);
if (props.filterAppliedCallback) {
props.filterAppliedCallback(selectedOptions);
}
Expand All @@ -117,7 +103,6 @@ const FilterSelect = (props: SelectProps) => {
const clearFilters = () => {
setSelectedOptions([]);
setSelectValue(isMulti ? [] : "");
// header.column.setFilterValue(isMulti ? [] : "");
if (props.filterClearedCallback) {
props.filterClearedCallback(isMulti ? [] : "");
}
Expand All @@ -139,6 +124,16 @@ const FilterSelect = (props: SelectProps) => {
setOptions(filterOptions);
}, [props.options]);

const isSearchable = () => {
if (props.isSearchable !== undefined) return props.isSearchable;

if (selectValue instanceof Array) {
return selectValue.length === 0;
}

return !selectValue;
};

return (
<Select
value={selectValue}
Expand Down Expand Up @@ -196,12 +191,6 @@ const FilterSelect = (props: SelectProps) => {
? Palette.primary.accent.light
: Palette.neutral.accent.light,
boxShadow: "none",
// "&:hover": {
// borderColor:
// props.isFocused || props.menuIsOpen
// ? Palette.primary.accent.light
// : "transparent",
// },
...(props.selectProps.filterProps?.variant === "bar" && {
borderColor: props.isFocused
? Palette.primary.accent.light
Expand All @@ -219,7 +208,7 @@ const FilterSelect = (props: SelectProps) => {
...base,
fontWeight: MET_Header_Font_Weight_Regular,
color: Palette.neutral.light,
fontSize: "0.875rem",
fontSize: INPUT_SIZE,
lineHeight: "1rem",
...(props.selectProps.filterProps?.variant == "bar" && {
color: Palette.primary.accent.main,
Expand All @@ -234,20 +223,16 @@ const FilterSelect = (props: SelectProps) => {
input: (base, props) => ({
...base,
fontWeight: "400",
fontSize: INPUT_SIZE,
}),
}}
isClearable={false}
menuPortalTarget={document.body}
controlShouldRenderValue={props.controlShouldRenderValue}
// className={clsx({
// [classes.infoSelect]: props.info,
// })}
// classNames={{
// control: () => (props.info ? classes.infoSelect : ""),
// }}
isLoading={props.isLoading}
loadingMessage={() => "Loading..."}
isDisabled={props.isDisabled}
isSearchable={isSearchable()}
/>
);
};
Expand Down
1 change: 1 addition & 0 deletions epictrack-web/src/styles/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const Palette = {
light: "#FDD166",
bg: {
light: "#FEEEC5",
main: "FEDD8C",
},
},
success: {
Expand Down
5 changes: 4 additions & 1 deletion epictrack-web/src/utils/MatchingTextHighlight.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Palette } from "../styles/theme";


Check failure on line 3 in epictrack-web/src/utils/MatchingTextHighlight.tsx

View workflow job for this annotation

GitHub Actions / linting (14.x)

Delete `␍⏎`
export const highlightText = (text: string, query: string) => {
const index = text.toLowerCase().indexOf(query.toLowerCase());
if (index !== -1) {
return (
<>
{text.substring(0, index)}
<span style={{ backgroundColor: "rgb(255, 203, 127)" }}>
<span style={{ backgroundColor: Palette.secondary.main }}>
{text.substring(index, index + query.length)}
</span>
{text.substring(index + query.length)}
Expand Down

0 comments on commit b788270

Please sign in to comment.