diff --git a/packages/api-explorer/src/ApiExplorer.tsx b/packages/api-explorer/src/ApiExplorer.tsx index 5ff52a87b..734906e6f 100644 --- a/packages/api-explorer/src/ApiExplorer.tsx +++ b/packages/api-explorer/src/ApiExplorer.tsx @@ -28,10 +28,21 @@ import type { FC } from 'react' import React, { useReducer, useState, useEffect, useCallback } from 'react' import { useLocation } from 'react-router' import styled, { createGlobalStyle } from 'styled-components' -import { Aside, ComponentsProvider, Layout, Page } from '@looker/components' +import { + Aside, + ComponentsProvider, + Divider, + Heading, + IconButton, + Layout, + Page, + Space, +} from '@looker/components' import type { SpecList } from '@looker/sdk-codegen' import type { RunItSetter } from '@looker/run-it' import { funFetch, fallbackFetch, OAuthScene } from '@looker/run-it' +import { FirstPage } from '@styled-icons/material/FirstPage' +import { LastPage } from '@styled-icons/material/LastPage' import { SearchContext, LodeContext, defaultLodeContextValue } from './context' import type { IApixEnvAdaptor } from './utils' import { @@ -52,6 +63,8 @@ import { import { AppRouter } from './routes' import { apixFilesHost } from './utils/lodeUtils' import { useActions } from './hooks' +import { TOGGLE_LABEL } from './components/Header' +import { SelectorContainer } from './components/SelectorContainer' export interface ApiExplorerProps { specs: SpecList @@ -70,7 +83,7 @@ const ApiExplorer: FC = ({ setVersionsUrl, exampleLodeUrl = 'https://raw.githubusercontent.com/looker-open-source/sdk-codegen/main/examplesIndex.json', declarationsLodeUrl = `${apixFilesHost}/declarationsIndex.json`, - headless = false, + headless = true, }) => { const [initializing, setInitializing] = useState(true) const location = useLocation() @@ -178,16 +191,64 @@ const ApiExplorer: FC = ({ /> )} - {hasNavigation && ( - + + {headless && ( + <> + + {hasNavigation && ( + + API DOCUMENTATION + + )} + : + } + label={TOGGLE_LABEL} + onClick={() => toggleNavigation()} + /> + + {hasNavigation && ( + <> + + + + )} + + )} + {hasNavigation && ( - - )} + )} + {oauthReturn && } {!oauthReturn && spec.api && ( = ({ ) } -/* Border support for `Aside` coming in @looker/components very soon */ -export const AsideBorder = styled(Aside)` - border-right: 1px solid ${({ theme }) => theme.colors.ui2}; +export const AsideBorder = styled(Aside)<{ + isOpen: boolean + headless: boolean +}>` + width: ${({ isOpen, headless }) => + isOpen ? '20rem' : headless ? '4rem' : '0rem'}; ` - export default ApiExplorer diff --git a/packages/api-explorer/src/components/Header/Header.tsx b/packages/api-explorer/src/components/Header/Header.tsx index e1e9049f4..188d0aaea 100644 --- a/packages/api-explorer/src/components/Header/Header.tsx +++ b/packages/api-explorer/src/components/Header/Header.tsx @@ -56,6 +56,8 @@ interface HeaderProps { export const HEADER_REM = 4 +export const TOGGLE_LABEL = 'Toggle Navitagion' + /** * Renders the API Explorer header */ @@ -78,7 +80,7 @@ export const HeaderLayout: FC = ({ onClick={() => toggleNavigation()} icon={} aria-label="nav toggle" - label="Toggle Navigation" + label={TOGGLE_LABEL} /> diff --git a/packages/api-explorer/src/components/Header/index.ts b/packages/api-explorer/src/components/Header/index.ts index 55c9b022b..1adacb39a 100644 --- a/packages/api-explorer/src/components/Header/index.ts +++ b/packages/api-explorer/src/components/Header/index.ts @@ -23,4 +23,4 @@ SOFTWARE. */ -export { Header, HEADER_REM } from './Header' +export { Header, HEADER_REM, TOGGLE_LABEL } from './Header' diff --git a/packages/api-explorer/src/components/SelectorContainer/SelectorContainer.tsx b/packages/api-explorer/src/components/SelectorContainer/SelectorContainer.tsx index 2d8dacae6..7b90be579 100644 --- a/packages/api-explorer/src/components/SelectorContainer/SelectorContainer.tsx +++ b/packages/api-explorer/src/components/SelectorContainer/SelectorContainer.tsx @@ -26,6 +26,7 @@ import type { FC, Dispatch } from 'react' import React from 'react' +import type { SpaceHelperProps } from '@looker/components' import { Space, IconButton } from '@looker/components' import { ChangeHistory } from '@styled-icons/material/ChangeHistory' import type { SpecList, SpecItem } from '@looker/sdk-codegen' @@ -35,7 +36,7 @@ import { diffPath } from '../../utils' import { SdkLanguageSelector } from './SdkLanguageSelector' import { ApiSpecSelector } from './ApiSpecSelector' -interface SelectorContainerProps { +interface SelectorContainerProps extends SpaceHelperProps { /** Specs to choose from */ specs: SpecList /** Current selected spec */ @@ -53,8 +54,9 @@ export const SelectorContainer: FC = ({ specs, spec, specDispatch, + ...spaceProps }) => ( - + diff --git a/packages/api-explorer/src/components/SideNav/SideNav.tsx b/packages/api-explorer/src/components/SideNav/SideNav.tsx index f73c4fa9f..95823b4c7 100644 --- a/packages/api-explorer/src/components/SideNav/SideNav.tsx +++ b/packages/api-explorer/src/components/SideNav/SideNav.tsx @@ -28,14 +28,12 @@ import type { FC, Dispatch } from 'react' import React, { useContext, useEffect, useState } from 'react' import { useHistory, useLocation } from 'react-router-dom' import { - Heading, TabList, Tab, TabPanel, TabPanels, useTabs, InputSearch, - SpaceVertical, } from '@looker/components' import type { SpecItem, @@ -50,7 +48,6 @@ import type { SpecAction } from '../../reducers' import { setPattern } from '../../reducers' import { useWindowSize } from '../../utils' import { HEADER_REM } from '../Header' -import { SelectorContainer } from '../SelectorContainer' import { SideNavMethodTags } from './SideNavMethodTags' import { SideNavTypeTags } from './SideNavTypeTags' import { useDebounce, countMethods, countTypes } from './searchUtils' @@ -66,12 +63,7 @@ interface SideNavProps { specDispatch: Dispatch } -export const SideNav: FC = ({ - headless = false, - specs, - spec, - specDispatch, -}) => { +export const SideNav: FC = ({ headless = false, spec }) => { const history = useHistory() const location = useLocation() const api = spec.api || ({} as ApiModel) @@ -151,28 +143,18 @@ export const SideNav: FC = ({ return (