diff --git a/components/builds/BuildFilters.tsx b/components/builds/BuildFilters.tsx
index 81f59391f..d02163dfe 100644
--- a/components/builds/BuildFilters.tsx
+++ b/components/builds/BuildFilters.tsx
@@ -9,7 +9,6 @@ import {
NumberInputField,
NumberInputStepper,
Radio,
- Select,
} from "@chakra-ui/react";
import { t, Trans } from "@lingui/macro";
import { Ability, Mode } from "@prisma/client";
@@ -22,15 +21,135 @@ import { useMyTheme } from "hooks/common";
import { Fragment, useState } from "react";
import { FiTrash } from "react-icons/fi";
import { abilities, isMainAbility } from "utils/lists/abilities";
+import { components } from "react-select";
+import ModeImage from "components/common/ModeImage";
+import MySelect from "components/common/MySelect";
+import defaultStyles from "utils/selectStyles";
interface Props {
filters: UseBuildsByWeaponState["filters"];
dispatch: UseBuildsByWeaponDispatch;
}
+const modeOptions = [
+ {
+ label: "All modes",
+ value: "ALL",
+ },
+ {
+ label: "Splat Zones",
+ value: "SZ",
+ },
+ {
+ label: "Tower Control",
+ value: "TC",
+ },
+ {
+ label: "Rainmaker",
+ value: "RM",
+ },
+ {
+ label: "Clam Blitz",
+ value: "CB",
+ },
+ {
+ label: "Turf War",
+ value: "TW",
+ },
+] as const;
+
+const abilitiesOptions = abilities.map((item) => {
+ return { label: item.name, value: item.code };
+});
+
+const ModeOption = (props: any) => {
+ return (
+
+
+
+ {props.value !== "ALL" ? (
+
+ ) : (
+ <>>
+ )}
+
+ {props.label}
+
+
+ );
+};
+
+const AbilityOption = (props: any) => {
+ return (
+
+
+
+
+
+ {props.label}
+
+
+ );
+};
+
+const ModeSingleValue = (props: any) => {
+ return (
+
+ {props.data.value !== "ALL" ? (
+
+
+
+ ) : (
+ <>>
+ )}
+ {props.data.label}
+
+ );
+};
+
const BuildFilters: React.FC = ({ filters, dispatch }) => {
- const [modeValueChanged, setModeValueChanged] = useState(false);
- const { gray } = useMyTheme();
+ const [mode, setMode] = useState<{ label: string; value: string }>(
+ modeOptions[0]
+ );
+
+ const {
+ borderColor,
+ themeColorOpaque,
+ textColor,
+ gray
+ } = useMyTheme();
+
+ const selectDefaultStyles = defaultStyles();
+ const selectStyles = {
+ ...selectDefaultStyles,
+ singleValue: (base: any) => ({
+ ...base,
+ padding: 0,
+ borderRadius: 5,
+ color: textColor,
+ fontSize: '0.875rem',
+ display: "flex",
+ }),
+ option: (styles: any, {isFocused}: any) => {
+ return {
+ ...styles,
+ backgroundColor: isFocused ? themeColorOpaque : undefined,
+ fontSize: '0.875rem',
+ color: textColor,
+ };
+ },
+ control: (base: any) => ({
+ ...base,
+ borderColor,
+ minHeight: 32,
+ height: 32,
+ background: "hsla(0, 0%, 0%, 0)",
+ }),
+ dropdownIndicator: (base: any) => ({
+ ...base,
+ padding: 4
+ }),
+ };
return (
<>
@@ -171,58 +290,49 @@ const BuildFilters: React.FC = ({ filters, dispatch }) => {
align="center"
flexDir={["column", "row"]}
>
-
-
+
+ {
+ return !filters.find(
+ (filterElement) => filterElement.ability === option.value
+ );
+ })}
+ setValue={(value) => {
+ dispatch({
+ type: "ADD_FILTER",
+ ability: value as Ability,
+ });
+ }}
+ components={{
+ Option: AbilityOption,
+ }}
+ styles={selectStyles}
+ />
+
+
+ {
+ const mode = modeOptions.find((option) => option.value === value);
+ if (mode) setMode(mode);
+ dispatch({
+ type: "SET_MODE_FILTER",
+ modeFilter: value === "ALL" ? undefined : (value as Mode),
+ });
+ }}
+ components={{
+ Option: ModeOption,
+ SingleValue: ModeSingleValue,
+ }}
+ styles={selectStyles}
+ />
+
>
);
diff --git a/components/common/ModeImage.tsx b/components/common/ModeImage.tsx
index 3745aa758..fc69238ee 100644
--- a/components/common/ModeImage.tsx
+++ b/components/common/ModeImage.tsx
@@ -3,7 +3,7 @@ import { CSSProperties } from "react";
interface ModeImageProps {
mode: "TW" | "SZ" | "TC" | "RM" | "CB";
- size?: 24 | 32 | 64 | 128;
+ size?: 20 | 24 | 32 | 64 | 128;
onClick?: () => void;
style?: CSSProperties;
}
diff --git a/components/common/MultipleModeSelector.tsx b/components/common/MultipleModeSelector.tsx
index 865439c27..7e4bd1493 100644
--- a/components/common/MultipleModeSelector.tsx
+++ b/components/common/MultipleModeSelector.tsx
@@ -11,6 +11,7 @@ import ReactSelect, {
import { SelectComponents } from "react-select/src/components";
import { Box, Flex } from "@chakra-ui/react";
import ModeImage from "./ModeImage";
+import defaultStyles from "utils/selectStyles";
interface SelectProps {
options?:
@@ -70,14 +71,12 @@ const MultipleModeSelector: React.FC = ({
defaultValue,
}) => {
const {
- borderColor,
themeColorHex,
bgColor,
- themeColorOpaque,
- textColor,
} = useMyTheme();
const [inputValue, setInputValue] = useState("");
const [selectedModes, setSelectedModes] = useState(defaultValue);
+ const selectDefaultStyles = defaultStyles();
const handleChange = (selectedOption: any) => {
if (!selectedOption) {
@@ -144,38 +143,7 @@ const MultipleModeSelector: React.FC = ({
neutral5: bgColor,
},
})}
- styles={{
- singleValue: (base) => ({
- ...base,
- padding: 5,
- borderRadius: 5,
- color: textColor,
- display: "flex",
- }),
- input: (base) => ({
- ...base,
- color: textColor,
- }),
- multiValue: (base) => ({
- ...base,
- background: themeColorHex,
- color: "black",
- }),
- option: (styles, { isFocused }) => {
- return {
- ...styles,
- backgroundColor: isFocused ? themeColorOpaque : undefined,
- color: textColor,
- };
- },
- menu: (styles) => ({ ...styles, zIndex: 999 }),
- control: (base) => ({
- ...base,
- borderColor,
- minHeight: "2.5rem",
- background: "hsla(0, 0%, 0%, 0)",
- }),
- }}
+ styles={selectDefaultStyles}
/>
);
};
diff --git a/components/common/MySelect.tsx b/components/common/MySelect.tsx
index 3c5ea0d42..ef9df6564 100644
--- a/components/common/MySelect.tsx
+++ b/components/common/MySelect.tsx
@@ -9,6 +9,7 @@ import ReactSelect, {
ValueType,
} from "react-select";
import { SelectComponents } from "react-select/src/components";
+import defaultStyles from "utils/selectStyles";
interface SelectProps {
options?:
@@ -36,6 +37,7 @@ interface SelectProps {
menuIsOpen?: boolean;
hideMenuBeforeTyping?: boolean;
customFilterOption?: (option: any, rawInput: string) => boolean;
+ styles?: any;
}
const DropdownIndicator = (props: any) => {
@@ -62,15 +64,14 @@ const MySelect: React.FC = ({
menuIsOpen = false,
hideMenuBeforeTyping,
customFilterOption,
+ styles
}) => {
const {
- borderColor,
themeColorHex,
bgColor,
- themeColorOpaque,
- textColor,
} = useMyTheme();
const [inputValue, setInputValue] = useState("");
+ const selectDefaultStyles = defaultStyles();
const handleChange = (selectedOption: any) => {
if (!selectedOption) {
@@ -136,38 +137,7 @@ const MySelect: React.FC = ({
},
})}
autoFocus={autoFocus}
- styles={{
- singleValue: (base) => ({
- ...base,
- padding: 5,
- borderRadius: 5,
- color: textColor,
- display: "flex",
- }),
- input: (base) => ({
- ...base,
- color: textColor,
- }),
- multiValue: (base) => ({
- ...base,
- background: themeColorHex,
- color: "black",
- }),
- option: (styles, { isFocused }) => {
- return {
- ...styles,
- backgroundColor: isFocused ? themeColorOpaque : undefined,
- color: textColor,
- };
- },
- menu: (styles) => ({ ...styles, zIndex: 999 }),
- control: (base) => ({
- ...base,
- borderColor,
- minHeight: "2.5rem",
- background: "hsla(0, 0%, 0%, 0)",
- }),
- }}
+ styles={ styles ? styles : selectDefaultStyles}
/>
);
};
diff --git a/utils/selectStyles.ts b/utils/selectStyles.ts
new file mode 100644
index 000000000..73430da56
--- /dev/null
+++ b/utils/selectStyles.ts
@@ -0,0 +1,46 @@
+import { useMyTheme } from "../hooks/common";
+
+
+const defaultStyles = () => {
+ const {
+ borderColor,
+ themeColorHex,
+ themeColorOpaque,
+ textColor,
+ } = useMyTheme();
+
+ return {
+ singleValue: (base: any) => ({
+ ...base,
+ padding: 5,
+ borderRadius: 5,
+ color: textColor,
+ display: "flex",
+ }),
+ input: (base: any) => ({
+ ...base,
+ color: textColor,
+ }),
+ multiValue: (base: any) => ({
+ ...base,
+ background: themeColorHex,
+ color: "black",
+ }),
+ option: (styles: any, {isFocused}: any) => {
+ return {
+ ...styles,
+ backgroundColor: isFocused ? themeColorOpaque : undefined,
+ color: textColor,
+ };
+ },
+ menu: (styles: any) => ({...styles, zIndex: 999}),
+ control: (base: any) => ({
+ ...base,
+ borderColor,
+ minHeight: "2.5rem",
+ background: "hsla(0, 0%, 0%, 0)",
+ }),
+ };
+};
+
+export default defaultStyles;
\ No newline at end of file