diff --git a/dapp/src/DApp.tsx b/dapp/src/DApp.tsx index 1fd0809c7..c8fc3f954 100644 --- a/dapp/src/DApp.tsx +++ b/dapp/src/DApp.tsx @@ -9,7 +9,6 @@ import { AcreSdkProvider } from "./acre-react/contexts" import GlobalStyles from "./components/GlobalStyles" import { DocsDrawerContextProvider, - SidebarContextProvider, WalletConnectionAlertContextProvider, } from "./contexts" import { useInitApp } from "./hooks" @@ -67,15 +66,13 @@ function DAppProviders() { - - - - - - - - - + + + + + + + diff --git a/dapp/src/components/Layout.tsx b/dapp/src/components/Layout.tsx index de7bb05a2..24ba593e9 100644 --- a/dapp/src/components/Layout.tsx +++ b/dapp/src/components/Layout.tsx @@ -7,7 +7,6 @@ import { usePostHogPageViewCapture } from "#/hooks/posthog" import DocsDrawer from "./DocsDrawer" import Header from "./Header" import ModalRoot from "./ModalRoot" -import Sidebar from "./Sidebar" import MobileModeBanner from "./MobileModeBanner" import Footer from "./Footer" @@ -51,7 +50,6 @@ function Layout() { > - diff --git a/dapp/src/components/ModalRoot/withBaseModal.tsx b/dapp/src/components/ModalRoot/withBaseModal.tsx index 5eeb2396a..b5d8cb4d5 100644 --- a/dapp/src/components/ModalRoot/withBaseModal.tsx +++ b/dapp/src/components/ModalRoot/withBaseModal.tsx @@ -1,7 +1,7 @@ import React, { ComponentType, useCallback } from "react" import { Modal, ModalContent, ModalOverlay, ModalProps } from "@chakra-ui/react" import { BaseModalProps } from "#/types" -import { useAppNavigate, useSidebar } from "#/hooks" +import { useAppNavigate } from "#/hooks" const MODAL_BASE_SIZE = "lg" @@ -12,7 +12,6 @@ function withBaseModal( return function ModalBase(props: T) { const { closeModal, closeOnEsc, navigateToOnClose } = props - const { isOpen: isSidebarOpen } = useSidebar() const navigate = useAppNavigate() const handleCloseModal = useCallback(() => { @@ -33,13 +32,7 @@ function withBaseModal( {...modalProps} > - + diff --git a/dapp/src/components/Sidebar.tsx b/dapp/src/components/Sidebar.tsx deleted file mode 100644 index b521add95..000000000 --- a/dapp/src/components/Sidebar.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import React, { ComponentProps, useEffect } from "react" -import { Box, useMultiStyleConfig } from "@chakra-ui/react" -import { useScrollbarVisibility, useSidebar } from "#/hooks" -import { EXTERNAL_HREF } from "#/constants" -import ButtonLink from "./shared/ButtonLink" - -const CHAKRA_MODAL_CONTAINER_SELECTOR = ".chakra-modal__content-container" - -const BUTTONS: Partial>[] = [ - { - children: "Docs", - variant: "solid", - href: EXTERNAL_HREF.DOCS, - isExternal: true, - }, - { - children: "FAQ", - colorScheme: "gold", - href: EXTERNAL_HREF.FAQ, - isExternal: true, - }, - { - children: "Contracts", - colorScheme: "gold", - href: EXTERNAL_HREF.CONTRACTS, - isExternal: true, - }, - { - children: "Blog", - colorScheme: "gold", - href: EXTERNAL_HREF.BLOG, - isExternal: true, - }, -] - -export default function Sidebar() { - const { isOpen } = useSidebar() - const { isVisible, scrollbarWidth, refreshState } = useScrollbarVisibility( - CHAKRA_MODAL_CONTAINER_SELECTOR, - ) - const styles = useMultiStyleConfig("Sidebar") - - useEffect(() => { - if (!isOpen) return - refreshState() - }, [isOpen, refreshState]) - - return ( - - - {BUTTONS.map((buttonProps) => ( - - ))} - - - ) -} diff --git a/dapp/src/contexts/SidebarContext.tsx b/dapp/src/contexts/SidebarContext.tsx deleted file mode 100644 index 125b871a1..000000000 --- a/dapp/src/contexts/SidebarContext.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import useIsEmbed from "#/hooks/useIsEmbed" -import React, { createContext, useCallback, useMemo, useState } from "react" - -type SidebarContextValue = { - isOpen: boolean - onOpen: () => void - onClose: () => void -} - -export const SidebarContext = createContext({ - isOpen: false, - onOpen: () => {}, - onClose: () => {}, -}) - -export function SidebarContextProvider({ - children, -}: { - children: React.ReactNode -}): React.ReactElement { - const { isEmbed } = useIsEmbed() - - const [isOpen, setIsOpen] = useState(false) - - const onOpen = useCallback(() => { - if (isEmbed) return - - setIsOpen(true) - }, [isEmbed]) - - const onClose = useCallback(() => { - setIsOpen(false) - }, []) - - const contextValue: SidebarContextValue = useMemo( - () => ({ - isOpen, - onOpen, - onClose, - }), - [isOpen, onClose, onOpen], - ) - - return ( - - {children} - - ) -} diff --git a/dapp/src/contexts/index.tsx b/dapp/src/contexts/index.tsx index 658feecbd..263951aec 100644 --- a/dapp/src/contexts/index.tsx +++ b/dapp/src/contexts/index.tsx @@ -1,5 +1,4 @@ export * from "./DocsDrawerContext" -export * from "./SidebarContext" export * from "./StakeFlowContext" export * from "./PaginationContext" export * from "./WalletConnectionAlertContext" diff --git a/dapp/src/hooks/index.ts b/dapp/src/hooks/index.ts index 91b1cfeb6..7758c4fd7 100644 --- a/dapp/src/hooks/index.ts +++ b/dapp/src/hooks/index.ts @@ -2,7 +2,6 @@ export * from "./store" export * from "./sdk" export * from "./orangeKit" export * from "./useDetectThemeMode" -export * from "./useSidebar" export * from "./useDocsDrawer" export * from "./useTransactionDetails" export * from "./useStakeFlowContext" @@ -34,7 +33,6 @@ export { default as useTriggerConnectWalletModal } from "./useTriggerConnectWall export { default as useLastUsedBtcAddress } from "./useLastUsedBtcAddress" export { default as useAcrePoints } from "./useAcrePoints" export { default as useSignMessageAndCreateSession } from "./useSignMessageAndCreateSession" -export { default as useScrollbarVisibility } from "./useScrollbarVisibility" export { default as useAccessCode } from "./useAccessCode" export { default as useFormField } from "./useFormField" export { default as useDepositBTCTransaction } from "./useDepositBTCTransaction" diff --git a/dapp/src/hooks/useScrollbarVisibility.ts b/dapp/src/hooks/useScrollbarVisibility.ts deleted file mode 100644 index c1ce79034..000000000 --- a/dapp/src/hooks/useScrollbarVisibility.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { useCallback, useEffect, useState } from "react" - -const SCROLLBAR_WIDTH = `${window.innerWidth - document.body.offsetWidth}px` - -function isScrollbarVisible(selector: string) { - const element = document.querySelector(selector) - - if (!element) return false - - return element?.scrollHeight > element?.clientHeight -} - -export default function useScrollbarVisibility(selector: string) { - const [isVisible, setIsVisible] = useState(false) - - useEffect(() => { - const handleResize = () => { - setIsVisible(isScrollbarVisible(selector)) - } - window.addEventListener("resize", handleResize) - - return () => { - window.removeEventListener("resize", handleResize) - } - }, [selector]) - - const refreshState = useCallback(() => { - setIsVisible(isScrollbarVisible(selector)) - }, [selector]) - - return { isVisible, scrollbarWidth: SCROLLBAR_WIDTH, refreshState } -} diff --git a/dapp/src/hooks/useSidebar.ts b/dapp/src/hooks/useSidebar.ts deleted file mode 100644 index 944364076..000000000 --- a/dapp/src/hooks/useSidebar.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useContext } from "react" -import { SidebarContext } from "#/contexts" - -export function useSidebar() { - const context = useContext(SidebarContext) - - if (!context) { - throw new Error("SidebarContext used outside of SidebarContext component") - } - - return context -} diff --git a/dapp/src/theme/Sidebar.ts b/dapp/src/theme/Sidebar.ts deleted file mode 100644 index 1b1a431b1..000000000 --- a/dapp/src/theme/Sidebar.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" - -const PARTS = ["sidebarContainer", "sidebar"] - -const baseStyleSidebarContainer = defineStyle({ - top: 0, - right: 0, - h: "100vh", - position: "fixed", - overflow: "hidden", - zIndex: "sidebar", - transition: "width 0.3s", -}) - -const baseStyleSidebar = defineStyle({ - p: 4, - height: "100%", - w: "sidebar_width", - bg: "gold.200", - borderTop: "2px", - borderLeft: "2px", - borderColor: "gold.100", - borderTopLeftRadius: "xl", - display: "flex", - flexDirection: "column", - gap: 3, -}) - -const multiStyleConfig = createMultiStyleConfigHelpers(PARTS) - -const baseStyle = multiStyleConfig.definePartsStyle({ - sidebarContainer: baseStyleSidebarContainer, - sidebar: baseStyleSidebar, -}) - -export const sidebarTheme = multiStyleConfig.defineMultiStyleConfig({ - baseStyle, -}) diff --git a/dapp/src/theme/index.ts b/dapp/src/theme/index.ts index aaf6f4765..4c306df41 100644 --- a/dapp/src/theme/index.ts +++ b/dapp/src/theme/index.ts @@ -13,7 +13,6 @@ import { modalTheme } from "./Modal" import { cardTheme } from "./Card" import { tooltipTheme } from "./Tooltip" import { headingTheme } from "./Heading" -import { sidebarTheme } from "./Sidebar" import { currencyBalanceTheme } from "./CurrencyBalance" import { tokenBalanceInputTheme } from "./TokenBalanceInput" import { inputTheme } from "./Input" @@ -61,7 +60,6 @@ const defaultTheme = { Input: inputTheme, Link: linkTheme, Modal: modalTheme, - Sidebar: sidebarTheme, Spinner: spinnerTheme, Tag: tagTheme, TokenBalanceInput: tokenBalanceInputTheme, diff --git a/dapp/src/theme/utils/semanticTokens.ts b/dapp/src/theme/utils/semanticTokens.ts index 8ad1298ba..e33367d84 100644 --- a/dapp/src/theme/utils/semanticTokens.ts +++ b/dapp/src/theme/utils/semanticTokens.ts @@ -5,7 +5,4 @@ export const semanticTokens = { modal_shift: "9.75rem", // 156px dashboard_card_padding: 5, }, - sizes: { - sidebar_width: 80, - }, } diff --git a/dapp/src/theme/utils/zIndices.ts b/dapp/src/theme/utils/zIndices.ts index 3e9fb1a4b..0b8c0d5e5 100644 --- a/dapp/src/theme/utils/zIndices.ts +++ b/dapp/src/theme/utils/zIndices.ts @@ -1,9 +1,7 @@ export const zIndices = { - sidebar: 1450, drawer: 1470, mobileBanner: 1500, header: 1400, footer: 1380, - modalContent: 1410, modalOverlay: 1390, }