Skip to content

Commit

Permalink
feat: navigation pattern and bugs fixes (#3346)
Browse files Browse the repository at this point in the history
* feat: navigation pattern and bugs fixes

* fix: callout link

* fix: add the new page to vrt

* fix: pr feedback

* fix: apply suggestions from code review

Co-authored-by: Sarah <[email protected]>

---------

Co-authored-by: Sarah <[email protected]>
  • Loading branch information
SiTaggart and serifluous authored Jul 25, 2023
1 parent abf6c19 commit 3c8e02a
Show file tree
Hide file tree
Showing 19 changed files with 1,020 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/eleven-peaches-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/sidebar': patch
'@twilio-paste/core': patch
---

[Sidebr] fixed an issue with overlay sidebars where the topbar would be over the sidebar when sidebar is expanded
6 changes: 6 additions & 0 deletions .changeset/happy-bulldogs-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/in-page-navigation': patch
'@twilio-paste/core': patch
---

[In-page Navigation] allow in page navigation to remove bottom margin
1 change: 1 addition & 0 deletions cypress/integration/sitemap-vrt/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const SITEMAP = [
'/patterns/',
'/patterns/empty-state/',
'/patterns/error-state/',
'/patterns/navigation/',
'/patterns/notifications-and-feedback/',
'/patterns/object-details/',
'/patterns/privacy/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {InPageNavigationContext} from './InPageNavigationContext';
export interface InPageNavigationProps extends Omit<React.ComponentPropsWithRef<'div'>, 'children'> {
children?: React.ReactNode;
element?: BoxProps['element'];
marginBottom?: 'space0';
'aria-label': string;
variant?: Variants;
}

const InPageNavigation = React.forwardRef<HTMLDivElement, InPageNavigationProps>(
({element = 'IN_PAGE_NAVIGATION', variant = 'default', children, ...props}, ref) => {
({element = 'IN_PAGE_NAVIGATION', variant = 'default', marginBottom, children, ...props}, ref) => {
const isFullWidth = variant === 'fullWidth' || variant === 'inverse_fullWidth';

return (
Expand All @@ -27,7 +28,7 @@ const InPageNavigation = React.forwardRef<HTMLDivElement, InPageNavigationProps>
display="flex"
justifyContent={isFullWidth ? 'space-evenly' : 'flex-start'}
margin="space0"
marginBottom="space60"
marginBottom={marginBottom || 'space60'}
padding="space0"
columnGap={!isFullWidth ? 'space80' : 'space0'}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/components/sidebar/src/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const StyledSidebar = React.forwardRef<HTMLDivElement, BoxProps>((props, ref) =>
borderRightWidth="borderWidth10"
borderRightColor="colorBorderInverseWeaker"
backgroundColor="colorBackgroundInverse"
zIndex="zIndex40"
zIndex="zIndex50"
position="fixed"
top={0}
left={0}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import * as React from 'react';
import {Button} from '@twilio-paste/button';
import {Box} from '@twilio-paste/box';
import type {StoryFn} from '@storybook/react';
import {LogoTwilioIcon} from '@twilio-paste/icons/esm/LogoTwilioIcon';
import {ProductMessagingIcon} from '@twilio-paste/icons/esm/ProductMessagingIcon';
import {ProductVideoIcon} from '@twilio-paste/icons/esm/ProductVideoIcon';
import {ProductLookupIcon} from '@twilio-paste/icons/esm/ProductLookupIcon';
import {PlusIcon} from '@twilio-paste/icons/esm/PlusIcon';
import {MoreIcon} from '@twilio-paste/icons/esm/MoreIcon';
// ONLY for storybook stacked view not to complain on duplicates. aria-label should be carefully selected strings
import {useUID} from '@twilio-paste/uid-library';
import {Topbar, TopbarActions} from '@twilio-paste/topbar';
import {Menu, MenuButton, MenuItem, useMenuState} from '@twilio-paste/menu';

import {
Sidebar,
SidebarBody,
SidebarHeader,
SidebarHeaderLabel,
SidebarHeaderIconButton,
SidebarCollapseButton,
SidebarFooter,
SidebarPushContentWrapper,
SidebarNavigation,
SidebarNavigationItem,
SidebarNavigationDisclosure,
SidebarNavigationDisclosureHeading,
SidebarNavigationDisclosureHeadingWrapper,
SidebarNavigationDisclosureContent,
SidebarNavigationSeparator,
SidebarBetaBadge,
} from '../../src';
import {AccountSwitcherMenu} from './components/AccountSwitcher';
import {TrialBadge} from './components/TrialBadge';
import {SearchBox} from './components/SearchBox';
import {SupportMenu} from './components/SupportMenu';
import {AppSwitcher} from './components/AppSwitcher';
import {UserDialogExample} from './components/UserDialogConsole';
import {AccountMenu} from './components/AccountMenu';
import {BillingMenu} from './components/BillingMenu';

// eslint-disable-next-line import/no-default-export
export default {
title: 'Components/Sidebar/FullCompositions',
};

const onClick = (): void => {};

/* eslint-disable react/jsx-max-depth */
export const ConsoleCollapsed: StoryFn = () => {
const id = useUID();
const menu = useMenuState();
const menuLookup = useMenuState();
const menuVideo = useMenuState();
const sidebarNavigationSkipLinkID = useUID();
const topbarSkipLinkID = useUID();
const mainContentSkipLinkID = useUID();

const [pushSidebarCollapsed, setPushSidebarCollapsed] = React.useState(true);

return (
<Box minWidth="1000px">
{/* Can be placed anywhere - position fixed */}
<Sidebar
collapsed={pushSidebarCollapsed}
variant="compact"
sidebarNavigationSkipLinkID={sidebarNavigationSkipLinkID}
topbarSkipLinkID={topbarSkipLinkID}
mainContentSkipLinkID={mainContentSkipLinkID}
>
<SidebarHeader>
<SidebarHeaderIconButton as="a" href="#">
<LogoTwilioIcon size="sizeIcon20" decorative={false} title="Go to Console homepage" />
</SidebarHeaderIconButton>
<SidebarHeaderLabel>Twilio Console</SidebarHeaderLabel>
</SidebarHeader>
<SidebarBody>
<SidebarNavigation aria-label={id} hierarchical hideItemsOnCollapse>
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading icon={<ProductMessagingIcon decorative />} selected>
Messaging
</SidebarNavigationDisclosureHeading>
<MenuButton {...menu} variant="inverse_link" size="icon_small">
<MoreIcon decorative={false} title="More" />
</MenuButton>
<Menu {...menu} aria-label="Preferences">
<MenuItem {...menu} onClick={onClick}>
Unpin from sidebar
</MenuItem>
<MenuItem {...menu} href="http://www.google.com">
Go to docs
</MenuItem>
</Menu>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="https://google.com">Overview</SidebarNavigationItem>
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading selected>Try it out</SidebarNavigationDisclosureHeading>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="https://google.com">Send an SMS</SidebarNavigationItem>
<SidebarNavigationItem href="https://google.com" selected>
Send a Whatsapp message
</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
<SidebarNavigationItem href="https://google.com">Services</SidebarNavigationItem>
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading>Senders</SidebarNavigationDisclosureHeading>
<SidebarBetaBadge as="span">Beta</SidebarBetaBadge>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="https://google.com">Addons</SidebarNavigationItem>
<SidebarNavigationItem href="https://google.com">Navigation Item</SidebarNavigationItem>
<SidebarNavigationItem href="https://google.com">Navigation Item</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading>Settings</SidebarNavigationDisclosureHeading>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="#">
Addons <SidebarBetaBadge as="span">Beta</SidebarBetaBadge>
</SidebarNavigationItem>
<SidebarNavigationItem href="https://google.com">Navigation Item</SidebarNavigationItem>
<SidebarNavigationItem href="https://google.com">Navigation Item</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading icon={<ProductLookupIcon decorative />}>
Lookup
</SidebarNavigationDisclosureHeading>
<MenuButton {...menuLookup} variant="inverse_link" size="icon_small">
<MoreIcon decorative={false} title="More" />
</MenuButton>
<Menu {...menuLookup} aria-label="Preferences">
<MenuItem {...menuLookup} onClick={onClick}>
Unpin from sidebar
</MenuItem>
<MenuItem {...menuLookup} href="http://www.google.com">
Go to docs
</MenuItem>
</Menu>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="https://google.com">Lookup a phone number</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
</SidebarNavigationDisclosure>
<SidebarNavigationSeparator />
<SidebarNavigationDisclosure>
<SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureHeading icon={<ProductVideoIcon decorative />}>
Video
</SidebarNavigationDisclosureHeading>
<MenuButton {...menuVideo} variant="inverse_link" size="icon_small">
<MoreIcon decorative={false} title="More" />
</MenuButton>
<Menu {...menuVideo} aria-label="Preferences">
<MenuItem {...menuVideo} onClick={onClick}>
Unpin from sidebar
</MenuItem>
<MenuItem {...menuVideo} href="http://www.google.com">
Go to docs
</MenuItem>
</Menu>
</SidebarNavigationDisclosureHeadingWrapper>
<SidebarNavigationDisclosureContent>
<SidebarNavigationItem href="https://google.com">Overview</SidebarNavigationItem>
</SidebarNavigationDisclosureContent>
<SidebarNavigationSeparator />
</SidebarNavigationDisclosure>
<SidebarNavigationItem href="https://google.com">
Explore products <PlusIcon decorative />
</SidebarNavigationItem>
</SidebarNavigation>
</SidebarBody>

<SidebarFooter>
<SidebarCollapseButton
onClick={() => setPushSidebarCollapsed(!pushSidebarCollapsed)}
i18nCollapseLabel="Close sidebar"
i18nExpandLabel="Open sidebar"
/>
</SidebarFooter>
</Sidebar>

{/* Must wrap content area */}
<SidebarPushContentWrapper collapsed={pushSidebarCollapsed} variant="compact">
<Topbar id={topbarSkipLinkID}>
<TopbarActions justify="start">
<AccountSwitcherMenu />
<TrialBadge />
</TopbarActions>
<TopbarActions justify="end">
<SearchBox />
<AccountMenu />
<BillingMenu />
<SupportMenu />
<AppSwitcher />
<UserDialogExample />
</TopbarActions>
</Topbar>
<Box padding="space70" id={mainContentSkipLinkID}>
<Button variant="primary" onClick={() => setPushSidebarCollapsed(!pushSidebarCollapsed)}>
Toggle Push Sidebar
</Button>
</Box>
</SidebarPushContentWrapper>
</Box>
);
};
/* eslint-enable react/jsx-max-depth */
ConsoleCollapsed.parameters = {
padding: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const Console: StoryFn = () => {
const [pushSidebarCollapsed, setPushSidebarCollapsed] = React.useState(false);

return (
<Box>
<Box minWidth="1000px">
{/* Can be placed anywhere - position fixed */}
<Sidebar
collapsed={pushSidebarCollapsed}
Expand Down
Loading

0 comments on commit 3c8e02a

Please sign in to comment.