diff --git a/src/app/component/[component]/design-docs/client.tsx b/src/app/component/[component]/design-docs/client.tsx index 3ad75223..828d9160 100644 --- a/src/app/component/[component]/design-docs/client.tsx +++ b/src/app/component/[component]/design-docs/client.tsx @@ -1,13 +1,21 @@ 'use client'; +import { css } from '@emotion/css'; import { ContentstackRichText } from '@/components/content-stack'; import { CSNode } from '@/components/content-stack/types'; -import { ErrorBoundary } from 'next/dist/client/components/error-boundary'; interface DesignDocsContentProps { content?: CSNode; } export const DesignDocsContent = ({ content }: DesignDocsContentProps) => { - return ; + return ( +
+ +
+ ); }; diff --git a/src/app/component/[component]/design-docs/page.tsx b/src/app/component/[component]/design-docs/page.tsx index 0e1353e0..704e8308 100644 --- a/src/app/component/[component]/design-docs/page.tsx +++ b/src/app/component/[component]/design-docs/page.tsx @@ -1,5 +1,3 @@ -import { css } from '@emotion/css'; - import { fetchComponent } from '@/utils/ContentStack/getContentstackResources'; import { DesignDocsContent } from './client'; @@ -13,11 +11,7 @@ export default async function Page({ }); return ( -
+
); diff --git a/src/app/component/[component]/layout.tsx b/src/app/component/[component]/layout.tsx index 55159aa9..f553a771 100644 --- a/src/app/component/[component]/layout.tsx +++ b/src/app/component/[component]/layout.tsx @@ -1,22 +1,22 @@ -"use client"; +'use client'; -import { css } from "@emotion/css"; -import { useRouter, usePathname } from "next/navigation"; -import React from "react"; +import { css } from '@emotion/css'; +import { useRouter, usePathname } from 'next/navigation'; +import React from 'react'; -import IconButton from "@leafygreen-ui/icon-button"; -import { CodeSandbox, Figma, Github } from "@/components/glyphs"; -import { useDarkMode } from "@leafygreen-ui/leafygreen-provider"; -import { Tabs, Tab } from "@leafygreen-ui/tabs"; -import { color, spacing } from "@leafygreen-ui/tokens"; -import { H2 } from "@leafygreen-ui/typography"; +import IconButton from '@leafygreen-ui/icon-button'; +import { CodeSandbox, Figma, Github } from '@/components/glyphs'; +import { useDarkMode } from '@leafygreen-ui/leafygreen-provider'; +import { Tabs, Tab } from '@leafygreen-ui/tabs'; +import { color, spacing } from '@leafygreen-ui/tokens'; +import { H2 } from '@leafygreen-ui/typography'; -import useComponentFields from "@/hooks/useComponentFields"; -import { getGithubLink } from "@/utils"; +import { useComponentFields } from '@/hooks'; +import { getGithubLink } from '@/utils'; -const liveExamplePath = "live-example"; -const designDocsPath = "design-docs"; -const codeDocsPath = "code-docs"; +const liveExamplePath = 'live-example'; +const designDocsPath = 'design-docs'; +const codeDocsPath = 'code-docs'; export default function ComponentLayout({ children, @@ -25,13 +25,13 @@ export default function ComponentLayout({ }) { const router = useRouter(); const pathname = usePathname(); - const currentComponent = pathname.split("/")[2]; + const currentComponent = pathname.split('/')[2]; const { theme } = useDarkMode(); const component = useComponentFields({ componentName: currentComponent }); const getSelected = () => { - const suffix = pathname.split("/")[3]; + const suffix = pathname.split('/')[3]; if (suffix === liveExamplePath) { return 0; } @@ -61,7 +61,7 @@ export default function ComponentLayout({ href: component?.codesandbox_url?.href, icon: , }, - ] + ]; return (
- {currentComponent.split("-").join(" ")} + {currentComponent.split('-').join(' ')} - {externalLinks.map(({ 'aria-label': ariaLabel, href, icon }, index) => ( - - {icon} - - ))} + {externalLinks.map( + ({ 'aria-label': ariaLabel, href, icon }, index) => ( + + {icon} + + ), + )}
} > diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 01a79667..0ab2042b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,7 +2,7 @@ import { css } from '@emotion/css'; import { RootStyleRegistry } from '@/components/global'; -import { useMediaQuery } from '@/hooks/useMediaQuery'; +import { useMediaQuery } from '@/hooks'; import LeafyGreenProvider, { useDarkMode, } from '@leafygreen-ui/leafygreen-provider'; diff --git a/src/app/private/page.tsx b/src/app/private/page.tsx index 42d0e148..fdf15553 100644 --- a/src/app/private/page.tsx +++ b/src/app/private/page.tsx @@ -1,34 +1,27 @@ -"use client"; +'use client'; -import { useEffect, useState } from "react"; -import { useRouter } from "next/navigation"; -import Button from "@leafygreen-ui/button"; -import { BasicEmptyState } from "@leafygreen-ui/empty-state"; +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import Button from '@leafygreen-ui/button'; +import { BasicEmptyState } from '@leafygreen-ui/empty-state'; // @ts-expect-error -import ArrowLeftIcon from "@leafygreen-ui/icon/dist/ArrowLeft"; +import ArrowLeftIcon from '@leafygreen-ui/icon/dist/ArrowLeft'; // @ts-expect-error -import LogInIcon from "@leafygreen-ui/icon/dist/LogIn"; -import { getSession, login, Session } from "@/auth"; -import { ComingSoon, Security } from "@/components/glyphs"; +import LogInIcon from '@leafygreen-ui/icon/dist/LogIn'; +import { getSession, login, Session } from '@/auth'; +import { ComingSoon, Security } from '@/components/glyphs'; +import { useSession } from '@/hooks'; export default function Private() { const router = useRouter(); - const [session, setSession] = useState(); - - useEffect(() => { - getSession().then((response) => { - if (response !== null) { - setSession(response); - } - }); - }, []); + const session = useSession(); return session?.user ? ( } onClick={() => router.push("/")}> + } diff --git a/src/app/template.tsx b/src/app/template.tsx index abe31e34..98ed6a36 100644 --- a/src/app/template.tsx +++ b/src/app/template.tsx @@ -12,7 +12,7 @@ import { SideNavigation, Search, } from '@/components/global'; -import { useMediaQuery } from '@/hooks/useMediaQuery'; +import { useMediaQuery } from '@/hooks'; import { SIDE_NAV_WIDTH } from '@/constants'; import { ContentStackContextProvider } from '@/contexts/ContentStackContext'; import { ComponentFields, ContentPageGroup } from '@/utils/ContentStack/types'; diff --git a/src/components/global/Search.tsx b/src/components/global/Search.tsx index 477a0889..608a84bf 100644 --- a/src/components/global/Search.tsx +++ b/src/components/global/Search.tsx @@ -7,7 +7,7 @@ import debounce from 'lodash/debounce'; import LockIcon from '@leafygreen-ui/icon/dist/Lock'; import { SearchInput, SearchResult } from '@leafygreen-ui/search-input'; import { spacing } from '@leafygreen-ui/tokens'; -import { getSession, Session } from '@/auth'; +import { useSession } from '@/hooks'; import { components } from '@/utils/components'; const fuseOptions = { @@ -22,7 +22,7 @@ const useFuseSearch = (data: any[], options: IFuseOptions) => { }; export function Search() { - const [session, setSession] = useState(); + const session = useSession(); const [searchTerm, setSearchTerm] = useState(''); const [results, setResults] = useState(components); @@ -48,14 +48,6 @@ export function Search() { } }, [searchTerm]); - useEffect(() => { - getSession().then(response => { - if (response !== null) { - setSession(response); - } - }); - }, []); - return ( (); - - useEffect(() => { - getSession().then((response) => { - if (response !== null) { - setSession(response); - } - }); - }, []); + const session = useSession(); return session?.user ? (
{ + const [session, setSession] = useState(); + + useEffect(() => { + getSession().then(response => { + if (response !== null) { + setSession(response); + } + }); + }, []); + + return session; +};