-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9d70ae
commit 0df5493
Showing
12 changed files
with
159 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react" | ||
import { | ||
Drawer, | ||
DrawerBody, | ||
DrawerContent, | ||
Text, | ||
DrawerOverlay, | ||
useColorModeValue, | ||
} from "@chakra-ui/react" | ||
import { useDocsDrawerContext } from "../../hooks" | ||
|
||
export default function DocsDrawer() { | ||
const { isOpen, onClose } = useDocsDrawerContext() | ||
|
||
return ( | ||
<Drawer size="lg" placement="right" isOpen={isOpen} onClose={onClose}> | ||
<DrawerOverlay /> | ||
{/* TODO: Set the correct background color */} | ||
<DrawerContent bg={useColorModeValue("grey.100", "grey.100")}> | ||
<DrawerBody> | ||
{/* TODO: Add a documentation */} | ||
<Text>Documentation</Text> | ||
</DrawerBody> | ||
</DrawerContent> | ||
</Drawer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react" | ||
import { Box, Button, useColorModeValue } from "@chakra-ui/react" | ||
import { useDocsDrawerContext, useStakingFlowContext } from "../../hooks" | ||
import DocsDrawer from "../DocsDrawer" | ||
|
||
export default function Sidebar({ marginTop }: { marginTop?: number }) { | ||
const { modalType } = useStakingFlowContext() | ||
const { onOpen } = useDocsDrawerContext() | ||
|
||
return ( | ||
<> | ||
<Box | ||
top={0} | ||
right={0} | ||
h="100vh" | ||
position="fixed" | ||
width={modalType ? 80 : 0} | ||
height="100vh" | ||
transition="width 0.3s" | ||
zIndex="sidebar" | ||
// TODO: Set the correct background color | ||
bg={useColorModeValue("white", "white")} | ||
mt={marginTop} | ||
> | ||
{/* TODO: Add a correct content for the sidebar */} | ||
<Button onClick={onOpen}>Open a documentation</Button> | ||
</Box> | ||
<DocsDrawer /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { createContext, useCallback, useMemo, useState } from "react" | ||
|
||
type DocsDrawerContextValue = { | ||
isOpen: boolean | ||
onOpen: () => void | ||
onClose: () => void | ||
} | ||
|
||
export const DocsDrawerContext = createContext<DocsDrawerContextValue>({ | ||
isOpen: false, | ||
onOpen: () => {}, | ||
onClose: () => {}, | ||
}) | ||
|
||
export function DocsDrawerContextProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}): React.ReactElement { | ||
const [isOpen, setIsOpen] = useState(false) | ||
|
||
const onOpen = useCallback(() => { | ||
setIsOpen(true) | ||
}, []) | ||
|
||
const onClose = useCallback(() => { | ||
setIsOpen(false) | ||
}, []) | ||
|
||
const contextValue: DocsDrawerContextValue = useMemo<DocsDrawerContextValue>( | ||
() => ({ | ||
isOpen, | ||
onOpen, | ||
onClose, | ||
}), | ||
[isOpen, onClose, onOpen], | ||
) | ||
|
||
return ( | ||
<DocsDrawerContext.Provider value={contextValue}> | ||
{children} | ||
</DocsDrawerContext.Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./WalletContext" | ||
export * from "./LedgerWalletAPIProvider" | ||
export * from "./StakingFlowContext" | ||
export * from "./DocsDrawerContext" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useContext } from "react" | ||
import { DocsDrawerContext } from "../contexts" | ||
|
||
export function useDocsDrawerContext() { | ||
const context = useContext(DocsDrawerContext) | ||
|
||
if (!context) { | ||
throw new Error( | ||
"DocsDrawerContext used outside of DocsDrawerContext component", | ||
) | ||
} | ||
|
||
return context | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ComponentSingleStyleConfig } from "@chakra-ui/react" | ||
|
||
const Drawer: ComponentSingleStyleConfig = { | ||
baseStyle: { | ||
dialogContainer: { | ||
zIndex: "drawer", | ||
}, | ||
}, | ||
} | ||
|
||
export default Drawer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./colors" | ||
export * from "./zIndices" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const zIndices = { | ||
hide: -1, | ||
auto: "auto", | ||
base: 0, | ||
docked: 10, | ||
dropdown: 1000, | ||
sticky: 1100, | ||
banner: 1200, | ||
overlay: 1300, | ||
modal: 1400, | ||
sidebar: 1450, | ||
drawer: 1470, | ||
popover: 1500, | ||
skipLink: 1600, | ||
toast: 1700, | ||
tooltip: 1800, | ||
} |