-
Notifications
You must be signed in to change notification settings - Fork 10
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
c82415e
commit 5f7dbd5
Showing
12 changed files
with
132 additions
and
1,253 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
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,57 +1,15 @@ | ||
"use client"; | ||
|
||
import { CacheProvider } from "@chakra-ui/next-js"; | ||
import { ChakraProvider, extendTheme } from "@chakra-ui/react"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
import { AuthProvider } from "src/auth/AuthProvider"; | ||
|
||
// Force chakra to always be light mode - because we're removing it eventually. | ||
type ColourMode = "light" | "dark"; | ||
const noopColourModeManager = { | ||
type: "localStorage" as const, | ||
ssr: false, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
get(_init?: ColourMode | undefined) { | ||
return "light" as const; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
set(_value: "system") {}, | ||
}; | ||
|
||
export function Providers({ children }: PropsWithChildren) { | ||
return ( | ||
<CacheProvider> | ||
<ChakraProvider | ||
theme={extendTheme({ | ||
styles: { | ||
// Remove the Chakra defaults - we don't need them with Panda. | ||
// https://chakra-ui.com/docs/styled-system/global-styles#default-styles | ||
global: { | ||
body: { | ||
fontFamily: "unset", | ||
color: "unset", | ||
bg: "unset", | ||
lineHeight: "unset", | ||
}, | ||
|
||
"*, *::before, &::after": { | ||
borderColor: "unset", | ||
wordWrap: "unset", | ||
}, | ||
}, | ||
}, | ||
})} | ||
// We're not using Chakra's reset, instead we're using Panda CSS. | ||
resetCSS={false} | ||
colorModeManager={noopColourModeManager} | ||
> | ||
<AuthProvider> | ||
{/* -- */} | ||
{children} | ||
{/* -- */} | ||
</AuthProvider> | ||
</ChakraProvider> | ||
</CacheProvider> | ||
<AuthProvider> | ||
{/* -- */} | ||
{children} | ||
{/* -- */} | ||
</AuthProvider> | ||
); | ||
} |
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
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
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
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,9 +1,100 @@ | ||
import { UseDisclosureProps, useDisclosure } from "@chakra-ui/react"; | ||
import { useCallback, useEffect, useId, useRef, useState } from "react"; | ||
|
||
// Disclosure | ||
// TODO: Copy into our codebase: | ||
// https://github.com/chakra-ui/chakra-ui/blob/main/packages/hooks/use-disclosure/src/index.ts | ||
export interface UseDisclosureProps { | ||
isOpen?: boolean; | ||
defaultIsOpen?: boolean; | ||
onClose?(): void; | ||
onOpen?(): void; | ||
id?: string; | ||
} | ||
|
||
export { useDisclosure }; | ||
export type { UseDisclosureProps }; | ||
export type WithDisclosure<T> = UseDisclosureProps & T; | ||
|
||
type HTMLProps = React.HTMLAttributes<HTMLElement>; | ||
|
||
export function useCallbackRef<T extends (...args: any[]) => any>( | ||
callback: T | undefined, | ||
deps: React.DependencyList = [], | ||
) { | ||
const callbackRef = useRef(callback); | ||
|
||
useEffect(() => { | ||
callbackRef.current = callback; | ||
}); | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
return useCallback(((...args) => callbackRef.current?.(...args)) as T, deps); | ||
} | ||
|
||
export function useDisclosure(props: UseDisclosureProps = {}) { | ||
const { | ||
onClose: onCloseProp, | ||
onOpen: onOpenProp, | ||
isOpen: isOpenProp, | ||
id: idProp, | ||
} = props; | ||
|
||
const handleOpen = useCallbackRef(onOpenProp); | ||
const handleClose = useCallbackRef(onCloseProp); | ||
|
||
const [isOpenState, setIsOpen] = useState(props.defaultIsOpen || false); | ||
|
||
const isOpen = isOpenProp !== undefined ? isOpenProp : isOpenState; | ||
|
||
const isControlled = isOpenProp !== undefined; | ||
|
||
const uid = useId(); | ||
const id = idProp ?? `disclosure-${uid}`; | ||
|
||
const onClose = useCallback(() => { | ||
if (!isControlled) { | ||
setIsOpen(false); | ||
} | ||
handleClose?.(); | ||
}, [isControlled, handleClose]); | ||
|
||
const onOpen = useCallback(() => { | ||
if (!isControlled) { | ||
setIsOpen(true); | ||
} | ||
handleOpen?.(); | ||
}, [isControlled, handleOpen]); | ||
|
||
const onToggle = useCallback(() => { | ||
if (isOpen) { | ||
onClose(); | ||
} else { | ||
onOpen(); | ||
} | ||
}, [isOpen, onOpen, onClose]); | ||
|
||
function getButtonProps(props: HTMLProps = {}): HTMLProps { | ||
return { | ||
...props, | ||
"aria-expanded": isOpen, | ||
"aria-controls": id, | ||
onClick(event) { | ||
props.onClick?.(event); | ||
onToggle(); | ||
}, | ||
}; | ||
} | ||
|
||
function getDisclosureProps(props: HTMLProps = {}): HTMLProps { | ||
return { | ||
...props, | ||
hidden: !isOpen, | ||
id, | ||
}; | ||
} | ||
|
||
return { | ||
isOpen, | ||
onOpen, | ||
onClose, | ||
onToggle, | ||
isControlled, | ||
getButtonProps, | ||
getDisclosureProps, | ||
}; | ||
} |
Oops, something went wrong.
5f7dbd5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden-homepage – ./home
storyden-homepage.vercel.app
storyden-homepage-git-main-southclaws.vercel.app
storyden.org
www.storyden.org
storyden-homepage-southclaws.vercel.app
5f7dbd5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden – ./web
storyden-southclaws.vercel.app
storyden.vercel.app
storyden-git-main-southclaws.vercel.app
www.makeroom.club
demo.storyden.org
makeroom.club