diff --git a/packages/__docs__/src/App/index.tsx b/packages/__docs__/src/App/index.tsx index 9e6fbcaba8..8800b062d2 100644 --- a/packages/__docs__/src/App/index.tsx +++ b/packages/__docs__/src/App/index.tsx @@ -35,13 +35,14 @@ import { } from 'react' import { Alert } from '@instructure/ui-alerts' +import { Breadcrumb } from '@instructure/ui-breadcrumb' import { Checkbox } from '@instructure/ui-checkbox' import { InstUISettingsProvider, withStyle, jsx } from '@instructure/emotion' import { Flex } from '@instructure/ui-flex' import { Text } from '@instructure/ui-text' import { View } from '@instructure/ui-view' import { AccessibleContent } from '@instructure/ui-a11y-content' -import { MobileTopNav } from '@instructure/ui-top-nav-bar' +import { MobileTopNav, DesktopTopNav } from '@instructure/ui-top-nav-bar' import { IconButton } from '@instructure/ui-buttons' import { Tray } from '@instructure/ui-tray' import { Link } from '@instructure/ui-link' @@ -97,9 +98,236 @@ export const AppContext = createContext({ const WrapperComponent = (props) => { const [isSmallScreen, setIsSmallScreen] = useState(false) - - const SmallScreen = () =>

Small screen

- const BigScreen = () =>

Big screen

+ const [isLightMode, setIsLightMode] = useState(false) + + const brandSvg = ( + + + + + + ) + + const SmallScreen = () => ( +
+ + + + + + + + + + + +
+ + Back +
+ +
+ Courses + + } + rightIcon={} + onClick={() => alert('Account clicked')} + > + Account + + } + rightIcon={} + onClick={() => alert('Admin clicked')} + > + Admin + + } + rightIcon={} + onClick={() => alert('Dashboard')} + > + Dashboard + + } + onClick={() => alert('Simple option with no left icon')} + > + Simple option with no left icon + + +
+
+ { + setIsLightMode((prev) => !prev) + }} + /> +
+

+ 1 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 2 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 3 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 4 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 5 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 6 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 7 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 8 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 9 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 10 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 11 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 12 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 13 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 14 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 15 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 16 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 17 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 18 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 19 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+

+ 20 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias + excepturi a blanditiis, aspernatur repellat repellendus dolores cum + labore eligendi architecto asperiores, dolor quisquam sequi mollitia + quibusdam, cumque id ab amet? +

+
+ ) + const BigScreen = () => ( + + + + Student Forecast + University of Utah + University of Colleges + + + + ) useEffect(() => { const handleResize = () => { @@ -151,8 +379,7 @@ class App extends Component { layout: 'large', docsData: null, versionsData: null, - iconsData: null, - lightMode: true + iconsData: null } } @@ -760,25 +987,6 @@ class App extends Component { return } - const brandSvg = ( - - - - - - ) - return ( { }} > - - - - - - - - - - - -
- - Back -
- -
- Courses - - } - rightIcon={} - onClick={() => alert('Account clicked')} - > - Account - - } - rightIcon={} - onClick={() => alert('Admin clicked')} - > - Admin - - } - rightIcon={} - onClick={() => alert('Dashboard')} - > - Dashboard - - } - onClick={() => alert('Simple option with no left icon')} - > - Simple option with no left icon - - -
-
- { - this.setState((prevState) => { - return { ...prevState, lightMode: !prevState.lightMode } - }) - }} - /> -
-

- 1 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 2 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 3 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 4 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 5 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 6 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 7 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 8 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 9 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 10 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 11 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 12 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 13 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 14 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 15 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 16 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 17 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 18 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 19 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

-

- 20 Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Molestias excepturi a blanditiis, aspernatur repellat repellendus - dolores cum labore eligendi architecto asperiores, dolor quisquam - sequi mollitia quibusdam, cumque id ab amet? -

) diff --git a/packages/ui-top-nav-bar/src/DesktopTopNav/README.md b/packages/ui-top-nav-bar/src/DesktopTopNav/README.md new file mode 100644 index 0000000000..32fd6797e8 --- /dev/null +++ b/packages/ui-top-nav-bar/src/DesktopTopNav/README.md @@ -0,0 +1,107 @@ +--- +describes: MobileTopNav +--- + +POC mobile top nav + +```js +--- +type: example +--- +const Example = () => { + const lightMode = false + const brandSvg = ( + + + + + + ) + return ( +
+

+ 1 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 2 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 3 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 4 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 5 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 6 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 7 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 8 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 9 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 10 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 11 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 12 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 13 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 14 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 15 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 16 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 17 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 18 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 19 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+

+ 20 + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Molestias excepturi a blanditiis, aspernatur repellat repellendus dolores cum labore eligendi architecto asperiores, dolor quisquam sequi mollitia quibusdam, cumque id ab amet? +

+
+ ) +} + +render() +``` diff --git a/packages/ui-top-nav-bar/src/DesktopTopNav/index.tsx b/packages/ui-top-nav-bar/src/DesktopTopNav/index.tsx new file mode 100644 index 0000000000..5250f66576 --- /dev/null +++ b/packages/ui-top-nav-bar/src/DesktopTopNav/index.tsx @@ -0,0 +1,107 @@ +/* eslint-disable react/display-name */ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 - present Instructure, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** @jsx jsx */ +import { Children, PropsWithChildren, useEffect, useState } from 'react' +import { jsx, useTheme } from '@instructure/emotion' +import type { DesktopTopNavProps } from './props' + +import { IconButton } from '@instructure/ui-buttons' +import { IconHamburgerLine, IconXLine } from '@instructure/ui-icons' +import { generateStyles } from './styles' + +/** +--- +category: components +--- +**/ +const DesktopTopNav = ({ + lightMode = false, + styles, + children +}: DesktopTopNavProps) => { + const [open, setOpen] = useState(false) + + useEffect(() => { + const body = document.getElementsByTagName('body')[0] + body.style.overflow = open ? 'hidden' : 'visible' + }, [open]) + + const getSubComponent = (displayName: any) => { + return Children.map(children, (child: any) => child)?.filter( + (child: any) => child?.type?.displayName === displayName + ) + } + + return ( +
+
+ + {/*{!open && getSubComponent('BtnRow')}*/} + setOpen((open) => !open)} + > + {open ? : } + + + {getSubComponent('BreadCrumb')} +
+
+ ) +} + +const BreadCrumb = ({ children }: PropsWithChildren) => { + return ( +
{children}
+ ) +} + +BreadCrumb.displayName = 'BreadCrumb' + +const withStyles = + ( + generateStyles: (props: any, theme: any) => ComponentStyle + ) => + (WrappedComponent: any) => + (originalProps: ComponentOwnProps) => { + const theme = useTheme() + const styledProps = { + styles: generateStyles(originalProps, theme), + ...originalProps + } + return + } + +const SC: any = withStyles(generateStyles)(DesktopTopNav) + +SC.BreadCrumb = BreadCrumb +// TODO investigate whether displayName should be added to the original component + +export { SC as DesktopTopNav } +export default SC diff --git a/packages/ui-top-nav-bar/src/DesktopTopNav/props.ts b/packages/ui-top-nav-bar/src/DesktopTopNav/props.ts new file mode 100644 index 0000000000..86d2efe2ad --- /dev/null +++ b/packages/ui-top-nav-bar/src/DesktopTopNav/props.ts @@ -0,0 +1,51 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 - present Instructure, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import type { ReactNode, PropsWithChildren } from 'react' + +type DesktopTopNavOwnProps = { + lightMode?: boolean + brand?: ReactNode +} + +type DesktopTopNavStyle = { + container: (open: boolean) => { + [key: string]: string | number + } + content: (open: boolean) => { + [key: string]: string | number + } + topBar: { + [key: string]: string | number + } + btnRow: { + [key: string]: string | number + } +} + +type DesktopTopNavProps = DesktopTopNavOwnProps & { + styles: DesktopTopNavStyle +} & PropsWithChildren + +export type { DesktopTopNavProps, DesktopTopNavOwnProps } diff --git a/packages/ui-top-nav-bar/src/DesktopTopNav/styles.tsx b/packages/ui-top-nav-bar/src/DesktopTopNav/styles.tsx new file mode 100644 index 0000000000..720f5901f2 --- /dev/null +++ b/packages/ui-top-nav-bar/src/DesktopTopNav/styles.tsx @@ -0,0 +1,97 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 - present Instructure, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import type { DesktopTopNavProps } from './props' + +//TODO use theme variables for spacing +const generateStyles = (props: DesktopTopNavProps, theme: any) => { + const { lightMode } = props + return { + container: (open: boolean) => { + return { + height: '54px', + position: open ? 'fixed' : 'relative', + backgroundColor: lightMode + ? theme.colors.ui.surfacePageSecondary + : theme.colors.ui.surfaceDark, + color: lightMode + ? theme.colors.contrasts.grey125125 + : theme.colors?.contrasts?.white1010, + width: '100%', + zIndex: '1000' + } + }, + topBar: { + padding: `0 ${theme.spacing.small}`, + height: '54px', + display: 'flex', + alignItems: 'center' + // justifyContent: 'space-between' + }, + content: (open: boolean) => { + return { + padding: `0 ${theme.spacing.small}`, + height: open ? '100%' : '0px', + top: '3.375rem', + bottom: 0, + left: 0, + right: 0, + overflow: open ? 'scroll' : 'hidden', + position: 'fixed', + backgroundColor: lightMode + ? theme.colors.ui.surfacePageSecondary + : theme.colors.ui.surfaceDark, + color: lightMode + ? theme.colors.contrasts.grey125125 + : theme.colors?.contrasts?.white1010 + } + }, + btnRow: { + display: 'flex', + gap: '12px' + } + } +} +const generateItemListStyles = (_props: any, theme: any) => { + return { + divider: { + height: '0.0625rem', + overflow: 'hidden', + background: theme.colors.contrasts.grey1214 + } + } +} +const generateItemStyles = (_props: any, _theme: any) => { + return { + container: { + margin: '16px 0', + display: 'flex', + cursor: 'pointer', + alignItems: 'flex-end' + }, + leftIcon: { paddingRight: '8px', fontSize: '18px' }, + rightIcon: { marginLeft: 'auto', paddingRight: '8px', fontSize: '18px' } + } +} + +export { generateStyles, generateItemListStyles, generateItemStyles } diff --git a/packages/ui-top-nav-bar/src/MobileTopNav/index.tsx b/packages/ui-top-nav-bar/src/MobileTopNav/index.tsx index b0650ebd62..ca853b2d98 100644 --- a/packages/ui-top-nav-bar/src/MobileTopNav/index.tsx +++ b/packages/ui-top-nav-bar/src/MobileTopNav/index.tsx @@ -61,7 +61,7 @@ const MobileTopNav = ({ }, [open]) const getSubComponent = (displayName: any) => { - return Children.map(children, (child: any) => child).filter( + return Children.map(children, (child: any) => child)?.filter( (child: any) => child?.type?.displayName === displayName ) } diff --git a/packages/ui-top-nav-bar/src/index.ts b/packages/ui-top-nav-bar/src/index.ts index 366adfc871..0305fc98b8 100644 --- a/packages/ui-top-nav-bar/src/index.ts +++ b/packages/ui-top-nav-bar/src/index.ts @@ -62,3 +62,4 @@ export type { } from './TopNavBar/TopNavBarUser/props' export { MobileTopNav } from './MobileTopNav' +export { DesktopTopNav } from './DesktopTopNav'