diff --git a/package.json b/package.json index eba33f3d5b1..b4c4b28ef55 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "remark-gfm": "^3.0.1", "swiper": "^11.1.10", "tailwind-merge": "^2.3.0", + "tailwind-variants": "^0.2.1", "tailwindcss-animate": "^1.0.7", "usehooks-ts": "^3.1.0", "yaml-loader": "^0.8.0" diff --git a/src/@chakra-ui/components/ReactSelect.ts b/src/@chakra-ui/components/ReactSelect.ts deleted file mode 100644 index 17abb11362f..00000000000 --- a/src/@chakra-ui/components/ReactSelect.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { createMultiStyleConfigHelpers, cssVar } from "@chakra-ui/react" - -import { reactSelectAnatomyKeys } from "@/components/Select/innerComponents" - -const $borderBaseWidth = cssVar("border-base-width") - -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(reactSelectAnatomyKeys) - -const baseStyle = definePartsStyle({ - container: { - [$borderBaseWidth.variable]: "borders.1px", - w: "full", - minH: 10.5, - cursor: "pointer", - position: "relative", - zIndex: 1, - "& > .react-select__menu": { - zIndex: -1, - }, - }, - control: { - border: $borderBaseWidth.reference, - borderColor: "currentColor", - outlineOffset: "-2px", - p: 2, - gap: 4, - _hover: { - color: "primary.base", - borderColor: "primary.lowContrast", - }, - "&[data-expanded=true]": { - bg: "background.highlight", - color: "primary.base", - borderColor: "primary.lowContrast", - }, - "&:focus-within:not([data-expanded=true])": { - outline: "3px solid", - outlineColor: "primary.hover", - borderColor: "transparent", - }, - }, - groupHeading: { - color: "body.medium", - }, - indicatorIcon: { - fontSize: "sm", - transitionProperty: "common", - transitionDuration: "normal", - "*[data-expanded=true] &": { - transform: "rotate(180deg)", - }, - }, - menuList: { - bg: "background.highlight", - w: "full", - maxH: "xs", - overflowY: "auto", - }, - option: { - color: "body.base", - p: 2, - "&[data-focused=true]": { - bg: "primary.lowContrast", - color: "primary.base", - }, - "&[data-active=true]": { - bg: "body.light", - color: "primary.visited", - }, - }, -}) - -const $borderTopRadius = cssVar("border-top-radius") - -const variantFlushed = definePartsStyle({ - container: { - [$borderTopRadius.variable]: "radii.base", - borderTopRadius: $borderTopRadius.reference, - }, - control: { - borderTopRadius: $borderTopRadius.reference, - borderTopColor: "transparent", - borderInlineColor: "transparent", - _hover: { - borderTopColor: "transparent", - borderInlineColor: "transparent", - }, - "&[data-expanded=true]": { - borderColor: "body.light", - borderBottomColor: "primary.base", - }, - }, - menuList: { - borderInline: $borderBaseWidth.reference, - borderBottom: $borderBaseWidth.reference, - borderColor: "body.light", - borderBottomRadius: "base", - }, -}) - -const $borderOutlineRadius = cssVar("border-outline-radius") - -const variantOutline = definePartsStyle({ - container: { - [$borderOutlineRadius.variable]: "radii.base", - borderRadius: $borderOutlineRadius.reference, - }, - control: { - borderRadius: $borderOutlineRadius.reference, - "&[data-expanded=true]": { - borderBottomColor: "transparent", - borderBottomRadius: "none", - }, - }, - menuList: { - borderInline: $borderBaseWidth.reference, - borderBottom: $borderBaseWidth.reference, - borderColor: "primary.lowContrast", - borderBottomRadius: "base", - }, -}) - -const variants = { - flushed: variantFlushed, - outline: variantOutline, -} - -export const ReactSelect = defineMultiStyleConfig({ - baseStyle, - variants, - defaultProps: { - variant: "flushed", - }, -}) diff --git a/src/@chakra-ui/components/index.ts b/src/@chakra-ui/components/index.ts index 9cf99739fa5..1a1b20cefcf 100644 --- a/src/@chakra-ui/components/index.ts +++ b/src/@chakra-ui/components/index.ts @@ -22,7 +22,6 @@ import { Modal } from "./Modal" import { Popover } from "./Popover" import { Progress } from "./Progress" import { Radio } from "./Radio" -import { ReactSelect } from "./ReactSelect" import { Switch } from "./Switch" import { Table } from "./Table" import { Tabs } from "./Tabs" @@ -52,7 +51,6 @@ export default { Popover, Progress, Radio, - ReactSelect, Spinner: spinnerDefaultTheme, Switch, Table, diff --git a/src/components/CentralizedExchanges/index.tsx b/src/components/CentralizedExchanges/index.tsx index 64e4444005d..4898ddd01ad 100644 --- a/src/components/CentralizedExchanges/index.tsx +++ b/src/components/CentralizedExchanges/index.tsx @@ -9,7 +9,7 @@ import Emoji from "@/components/Emoji" import InlineLink from "@/components/Link" import OldHeading from "@/components/OldHeading" import Text from "@/components/OldText" -import Select from "@/components/Select" +import Select from "@/components/ui/Select" import { getLocaleTimestamp } from "@/lib/utils/time" diff --git a/src/components/FindWallet/LanguageSupportFilter.tsx b/src/components/FindWallet/LanguageSupportFilter.tsx index fe425fd92de..36f3c567e29 100644 --- a/src/components/FindWallet/LanguageSupportFilter.tsx +++ b/src/components/FindWallet/LanguageSupportFilter.tsx @@ -12,7 +12,7 @@ import { Text, } from "@chakra-ui/react" -import Select from "@/components/Select" +import Select from "@/components/ui/Select" import { getLanguageCodeName } from "@/lib/utils/intl" import { trackCustomEvent } from "@/lib/utils/matomo" diff --git a/src/components/Layer2/Layer2Onboard.tsx b/src/components/Layer2/Layer2Onboard.tsx index cfce20bb152..309abd4de59 100644 --- a/src/components/Layer2/Layer2Onboard.tsx +++ b/src/components/Layer2/Layer2Onboard.tsx @@ -26,7 +26,7 @@ import { ButtonLink } from "../Buttons" import InlineLink from "../Link" import OldHeading from "../OldHeading" import Text from "../OldText" -import Select, { SelectOnChange } from "../Select" +import Select, { SelectOnChange } from "../ui/Select" const Flex50 = (props: ChildOnlyProp) => ( diff --git a/src/components/Select/context.ts b/src/components/Select/context.ts deleted file mode 100644 index e579cdcf622..00000000000 --- a/src/components/Select/context.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createStylesContext, type SystemStyleObject } from "@chakra-ui/react" - -import { reactSelectAnatomyKeys } from "./innerComponents" - -const [ReactSelectStylesProvider, useReactSelectStyles] = - createStylesContext("ReactSelect") - -export const SelectStylesProvider = ReactSelectStylesProvider - -export const useSelectStyles = useReactSelectStyles as () => Record< - (typeof reactSelectAnatomyKeys)[number], - SystemStyleObject -> diff --git a/src/components/Select/innerComponents.tsx b/src/components/Select/innerComponents.tsx deleted file mode 100644 index f9ba42f5aec..00000000000 --- a/src/components/Select/innerComponents.tsx +++ /dev/null @@ -1,194 +0,0 @@ -import * as React from "react" -import { FaChevronDown } from "react-icons/fa" -import type { - ContainerProps, - ControlProps, - DropdownIndicatorProps, - GroupBase, - GroupProps, - MenuListProps, - OptionProps, -} from "react-select" -import { Box, Center, HStack, Icon } from "@chakra-ui/react" - -import { useSelectStyles } from "./context" - -export const reactSelectAnatomyKeys = [ - "container", - "control", - "indicatorIcon", - "menuList", - "option", - "groupHeading", -] as const - -export const nullop = () => null - -/* - * Note on the Generic declarations: - * Because the custom components are being created outside of the `components` - * prop, generics sent to the respective props have to be redeclared, else type - * errors throw for incompatibility. - */ - -const SelectContainer = < - Option, - IsMulti extends boolean, - Group extends GroupBase