Skip to content

Commit

Permalink
Use a semanticTokens to declare header height
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed Dec 19, 2023
1 parent 81d7de5 commit 8c5fd08
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
5 changes: 2 additions & 3 deletions dapp/src/components/DocsDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import {
DrawerOverlay,
} from "@chakra-ui/react"
import { useDocsDrawer } from "../../hooks"
import { HEADER_HEIGHT } from "../Header"
import { TextMd } from "../shared/Typography"

export default function DocsDrawer() {
const { isOpen, onClose } = useDocsDrawer()

return (
<Drawer size="xl" placement="right" isOpen={isOpen} onClose={onClose}>
<DrawerOverlay mt={HEADER_HEIGHT} />
<DrawerContent mt={HEADER_HEIGHT}>
<DrawerOverlay mt="header_height" />
<DrawerContent mt="header_height">
<DrawerBody>
{/* TODO: Add a documentation */}
<TextMd>Documentation</TextMd>
Expand Down
4 changes: 1 addition & 3 deletions dapp/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { Flex, HStack, Icon } from "@chakra-ui/react"
import ConnectWallet from "./ConnectWallet"
import { AcreLogo } from "../../static/icons"

export const HEADER_HEIGHT = 24

export default function Header() {
return (
<HStack as="header" p={6} height={HEADER_HEIGHT}>
<HStack as="header" p={6}>
<Icon as={AcreLogo} w={20} h={12} />
<Flex ml="auto">
<ConnectWallet />
Expand Down
3 changes: 1 addition & 2 deletions dapp/src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react"
import { Box, Button, useMultiStyleConfig } from "@chakra-ui/react"
import { useDocsDrawer, useSidebar } from "../../hooks"
import { HEADER_HEIGHT } from "../Header"

export default function Sidebar() {
const { isOpen } = useSidebar()
Expand All @@ -11,8 +10,8 @@ export default function Sidebar() {
return (
<Box
as="aside"
mt="header_height"
w={isOpen ? 80 : 0}
mt={HEADER_HEIGHT}
__css={styles.sidebarContainer}
>
<Box __css={styles.sidebar}>
Expand Down
5 changes: 2 additions & 3 deletions dapp/src/components/shared/ModalBase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ModalContent,
ModalOverlay,
} from "@chakra-ui/react"
import { HEADER_HEIGHT } from "../../Header"
import { ModalFlowContext, ModalFlowContextValue } from "../../../contexts"
import { useSidebar } from "../../../hooks"

Expand Down Expand Up @@ -68,8 +67,8 @@ export default function ModalBase({
return (
<ModalFlowContext.Provider value={contextValue}>
<Modal size="md" isOpen={isOpen} onClose={handleClose}>
<ModalOverlay mt={HEADER_HEIGHT} />
<ModalContent mt={2 * HEADER_HEIGHT}>
<ModalOverlay mt="header_height" />
<ModalContent mt="modal_shift">
<ModalCloseButton />
{children}
</ModalContent>
Expand Down
3 changes: 2 additions & 1 deletion dapp/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StyleFunctionProps, extendTheme } from "@chakra-ui/react"
import { mode } from "@chakra-ui/theme-tools"
import Button from "./Button"
import Switch from "./Switch"
import { colors, fonts, lineHeights, zIndices } from "./utils"
import { colors, fonts, lineHeights, semanticTokens, zIndices } from "./utils"
import Drawer from "./Drawer"
import Modal from "./Modal"
import Card from "./Card"
Expand All @@ -16,6 +16,7 @@ const defaultTheme = {
fonts,
lineHeights,
zIndices,
semanticTokens,
styles: {
global: (props: StyleFunctionProps) => ({
body: {
Expand Down
1 change: 1 addition & 0 deletions dapp/src/theme/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./colors"
export * from "./fonts"
export * from "./zIndices"
export * from "./semanticTokens"
6 changes: 6 additions & 0 deletions dapp/src/theme/utils/semanticTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const semanticTokens = {
space: {
header_height: 24,
modal_shift: 36,
},
}

0 comments on commit 8c5fd08

Please sign in to comment.