Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[workspace-v1-epic] Add WorkspaceLayout and SkipTos #244

Merged
merged 25 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
87c1edd
Initial files, next will start pulling apart.
dkasper-was-taken Jun 21, 2021
b4dfc2d
Stubs for layout and skip to.
dkasper-was-taken Jun 21, 2021
4eb9c3a
Basic functionality working, need to updated translations.
dkasper-was-taken Jun 22, 2021
992b6f4
Update translation labels.
dkasper-was-taken Jun 22, 2021
45dd9f8
Big mess...
dkasper-was-taken Jun 23, 2021
d8e407f
Working example with skipTos
dkasper-was-taken Jun 23, 2021
8d1d8d4
Test file structor and workspace layout doc entry.
dkasper-was-taken Jun 28, 2021
0b0329f
File cleanup and further doc.
dkasper-was-taken Jun 29, 2021
35348e2
Spec file with examples, needs jest.
dkasper-was-taken Jun 30, 2021
bea06dd
Updated tests and screenshots.
dkasper-was-taken Jul 1, 2021
51288ff
Update lint resource paths.
dkasper-was-taken Jul 2, 2021
738a204
Add change log.
dkasper-was-taken Jul 2, 2021
0316e95
PR comments, update doc, add id, fix tests.
dkasper-was-taken Jul 2, 2021
00cfc93
Updates for PR, address dot notation.
dkasper-was-taken Jul 2, 2021
6e7e603
Correct route.
dkasper-was-taken Jul 2, 2021
464e73d
Add todos for i18n.
dkasper-was-taken Jul 7, 2021
b264796
Adding translations. Adding consumption docs for workspace.
tbiethman Jul 16, 2021
3bac96d
Fixing lint.
tbiethman Jul 16, 2021
f789205
Getting tests to pass
tbiethman Jul 16, 2021
a78b39d
PR tweaks
tbiethman Jul 16, 2021
7a52186
Adding NotificationBanner doc
tbiethman Jul 16, 2021
a6c00b8
Adding workspace to demo example
tbiethman Jul 16, 2021
c0d45c0
Rendering layout actions in demo
tbiethman Jul 16, 2021
a1fe70e
Update src/terra-dev-site/app/components.2/ApplicationNavigation.app.mdx
tbiethman Jul 19, 2021
b1b1f15
Removing errant TODOs
tbiethman Jul 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Added
* Local file inclusion of terra-application-navigation
* Added ApplicationNavigationActionsContext to application-navigation
* Added WorkspaceLayout to local ApplicationNavigation instance

## 1.48.0 - (June 15, 2021)

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"keycode-js": "^3.1.0",
"mutationobserver-shim": "0.3.3",
"prop-types": "^15.5.8",
"react-draggable": "^4.4.3",
"react-onclickoutside": "^6.7.1",
"resize-observer-polyfill": "^1.4.1",
"terra-action-footer": "^2.61.0",
Expand Down
17 changes: 16 additions & 1 deletion src/application-navigation/ApplicationNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {
useRef, useCallback, Suspense,
} from 'react';
import PropTypes from 'prop-types';
import uuidv4 from 'uuid/v4';
import TerraApplicationNavigation from './private/ApplicationNavigation';
import {
titleConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType, userConfigPropType,
Expand All @@ -12,6 +13,7 @@ import ApplicationLoadingOverlay, { ApplicationLoadingOverlayProvider } from '..
import { ApplicationStatusOverlayProvider } from '../application-status-overlay';
import { NavigationPromptCheckpoint, navigationPromptResolutionOptionsShape, getUnsavedChangesPromptOptions } from '../navigation-prompt';
import { ApplicationIntlContext } from '../application-intl';
import ApplicationNavigationWorkspace from './private/workspace-layout/ApplicationNavigationWorkspace';

const propTypes = {
/**
Expand Down Expand Up @@ -44,6 +46,10 @@ const propTypes = {
* An element to render within the ApplicationNavigation utility menu, shifted to the drawer at the `medium` breakpoint and below.
*/
hero: PropTypes.element,
/**
* The base id used to generate ids of workspace, navigation, utility, and extension items
*/
id: PropTypes.string,
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
/**
* An array of configuration objects with information specifying the creation of navigation items. These items
* are rendered within the ApplicationNavigation header at larger breakpoints and within the drawer menu at smaller breakpoints.
Expand Down Expand Up @@ -116,6 +122,10 @@ const propTypes = {
* These items are rendered within the popup utility menu at larger breakpoints and within the drawer menu at smaller breakpoints.
*/
utilityItems: utilityItemsPropType,
/**
* An ApplicationNavigationWorkspace element and it's associated ApplicationNavigationWorkspaceItems.
*/
workspace: PropTypes.element,
};

const ApplicationNavigation = ({
Expand All @@ -125,6 +135,7 @@ const ApplicationNavigation = ({
disablePromptsForNavigationItems,
extensionItems,
hero,
id,
navigationItems,
navigationPromptResolutionOptions,
notifications,
Expand All @@ -138,10 +149,11 @@ const ApplicationNavigation = ({
titleConfig,
userConfig,
utilityItems,
workspace,
}) => {
const applicationIntl = React.useContext(ApplicationIntlContext);

const navigationPromptCheckpointRef = useRef();
const idRef = React.useRef(uuidv4());

const onSelectNavigationItem = useCallback((selectedItemKey) => {
if (disablePromptsForNavigationItems) {
Expand All @@ -167,6 +179,7 @@ const ApplicationNavigation = ({

return (
<TerraApplicationNavigation
id={id || idRef.current}
hero={hero}
notifications={notifications}
titleConfig={titleConfig}
Expand All @@ -182,6 +195,7 @@ const ApplicationNavigation = ({
onSelectHelp={onSelectHelp}
onSelectLogout={propOnSelectLogout && onSelectLogout}
onDrawerMenuStateChange={onDrawerMenuStateChange}
workspace={workspace}
>
<ApplicationLoadingOverlayProvider>
<ApplicationStatusOverlayProvider>
Expand All @@ -201,5 +215,6 @@ const ApplicationNavigation = ({
};

ApplicationNavigation.propTypes = propTypes;
ApplicationNavigation.Workspace = ApplicationNavigationWorkspace;

export default ApplicationNavigation;
19 changes: 14 additions & 5 deletions src/application-navigation/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import {
titleConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType, userConfigPropType,
} from './private/utils/propTypes';
// import {
// titleConfigPropType,
// navigationItemsPropType,
// extensionItemsPropType,
// utilityItemsPropType,
// userConfigPropType,
// } from './private/utils/propTypes';
tbiethman marked this conversation as resolved.
Show resolved Hide resolved
import ApplicationNavigationActionsContext from './ApplicationNavigationActionsContext';
import ApplicationNavigation from './ApplicationNavigation';

export default ApplicationNavigation;
export {
titleConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType, userConfigPropType,
// titleConfigPropType,
// navigationItemsPropType,
// extensionItemsPropType,
// utilityItemsPropType,
// userConfigPropType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

ApplicationNavigationActionsContext,
};

63 changes: 53 additions & 10 deletions src/application-navigation/private/ApplicationNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { shouldRenderCompactNavigation } from './utils/helpers';
import {
titleConfigPropType, userConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType,
} from './utils/propTypes';
import WorkspaceLayout from './workspace-layout/WorkspaceLayout';

import styles from './ApplicationNavigation.module.scss';

Expand Down Expand Up @@ -108,6 +109,10 @@ const propTypes = {
* A collection of child elements to render within the ApplicationNavigation body.
*/
children: PropTypes.node,
/**
* An ApplicationNavigationWorkspace element and it's associated ApplicationNavigationWorkspaceItems.
*/
workspace: PropTypes.element,
};

const defaultProps = {
Expand All @@ -134,6 +139,7 @@ const ApplicationNavigation = ({
onSelectUtilityItem,
notifications,
children,
workspace,
}) => {
const drawerMenuRef = useRef();
const contentLayoutRef = useRef();
Expand All @@ -145,9 +151,11 @@ const ApplicationNavigation = ({
const drawerMenuIsOpenRef = useRef(false);
const closeMenuCallbackRef = useRef();
const renderedNavItemKeyRef = useRef(activeNavigationItemKey);
const skipToWorkspaceActionRef = useRef();

const [drawerMenuIsOpen, setDrawerMenuIsOpen] = useState(false);
const [popupMenuIsOpen, setPopupMenuIsOpen] = useState(false);
const [renderSkipToWorkspace, setRenderSkipToWorkspace] = useState(false);

const closeMenuEvent = 'terra-application-navigation.dismiss-menu';

Expand Down Expand Up @@ -273,6 +281,19 @@ const ApplicationNavigation = ({
);
}

function createWorkspaceAction() {
let skipToAction;
if (renderSkipToWorkspace) {
skipToAction = () => {
if (!skipToWorkspaceActionRef.current) {
return;
}
skipToWorkspaceActionRef.current();
};
}
return skipToAction;
}

function renderCompactHeader() {
return (
<CompactHeader
Expand All @@ -295,6 +316,7 @@ const ApplicationNavigation = ({
onSelectHelp={onSelectHelp}
onSelectLogout={onSelectLogout}
id={id}
skipToWorkspaceAction={createWorkspaceAction()}
/>
);
}
Expand All @@ -321,6 +343,7 @@ const ApplicationNavigation = ({
onSelectSettings={onSelectSettings}
onSelectHelp={onSelectHelp}
onSelectLogout={onSelectLogout}
skipToWorkspaceAction={createWorkspaceAction()}
/>
);
}
Expand Down Expand Up @@ -442,6 +465,35 @@ const ApplicationNavigation = ({
const theme = React.useContext(ThemeContext);
const appNavClassNames = cx('application-navigation', theme.className);

const renderMain = () => {
const skipToCallback = action => {
skipToWorkspaceActionRef.current = action;

if (action && !renderSkipToWorkspace) {
setRenderSkipToWorkspace(true);
}
};

return (
<WorkspaceLayout
id={`${id}-workspace-layout`}
workspace={workspace}
skipToCallback={skipToCallback}
>
<main
ref={mainContainerRef}
tabIndex="-1"
role="main"
className={cx('main-container')}
aria-labelledby={hiddenMainTitle ? 'main-inner-title' : null}
>
{hiddenMainTitle}
{children}
</main>
</WorkspaceLayout>
);
};

return (
<div className={appNavClassNames}>
<div
Expand All @@ -457,16 +509,7 @@ const ApplicationNavigation = ({
className={cx('content-layout', { 'drawer-menu-is-open': drawerMenuIsOpen })}
>
{shouldRenderCompactNavigation(activeBreakpoint) ? renderCompactHeader() : renderHeader()}
<main
ref={mainContainerRef}
tabIndex="-1"
role="main"
className={cx('main-container')}
aria-labelledby={hiddenMainTitle ? 'main-inner-title' : null}
>
{hiddenMainTitle}
{children}
</main>
{renderMain()}
<Overlay
className={cx('overlay')}
isOpen={drawerMenuIsOpen}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:local {
.clinical-lowlight-theme {
--terra-application-resize-handle-hover-background-color: rgba(34, 42, 46, 0.6);
--terra-application-resize-handle-dragging-background-color: rgba(34, 42, 46, 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:local {
.clinical-lowlight-theme {
--terra-application-workspace-layout-workspace-overlay-background-color: rgba(0, 0, 0, 0.3);
}
}
18 changes: 18 additions & 0 deletions src/application-navigation/private/header/_CompactHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ const propTypes = {
* A configuration object with information pertaining to the application's user.
*/
userConfig: userConfigPropType,
/**
* Action to tie to the skipToLink for workspace.
*/
skipToWorkspaceAction: PropTypes.func,
};

const defaultProps = {
Expand Down Expand Up @@ -169,6 +173,7 @@ const CompactHeader = ({
intl,
hero,
userConfig,
skipToWorkspaceAction,
}) => {
const [navigationIsOpen, setNavigationIsOpen] = useState(false);
const [utilitiesIsOpen, setUtilitiesIsOpen] = useState(false);
Expand Down Expand Up @@ -333,11 +338,24 @@ const CompactHeader = ({
);
}

function renderSkipToWorkspace() {
if (!skipToWorkspaceAction) {
return undefined;
}

return (
<button type="button" role="link" onClick={skipToWorkspaceAction} className={cx('skip-content-button')}>
{intl.formatMessage({ id: 'terraApplication.workspace.skipToLabel' })}
</button>
);
}

return (
<header role="banner" className={cx('compact-header')}>
<button type="button" role="link" onClick={onSelectSkipToContent} className={cx('skip-content-button')}>
{intl.formatMessage({ id: 'terraApplication.navigation.header.skipToContentTitle' })}
</button>
{renderSkipToWorkspace()}
{renderMenuButton()}
<div className={cx('title-container')}>
{renderTitle()}
Expand Down
18 changes: 18 additions & 0 deletions src/application-navigation/private/header/_Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ const propTypes = {
* If `onSelectLogout` is not provided, the Logout action button will not be rendered.
*/
onSelectLogout: PropTypes.func,
/**
* Action to tie to the skipToLink for workspace.
*/
skipToWorkspaceAction: PropTypes.func,
};

const defaultProps = {
Expand Down Expand Up @@ -129,6 +133,7 @@ const Header = ({
onSelectSettings,
onSelectHelp,
onSelectLogout,
skipToWorkspaceAction,
}) => {
function renderTitle() {
if (!titleConfig) {
Expand Down Expand Up @@ -198,11 +203,24 @@ const Header = ({
);
}

function renderSkipToWorkspace() {
if (!skipToWorkspaceAction) {
return undefined;
}

return (
<button type="button" role="link" onClick={skipToWorkspaceAction} className={cx('skip-content-button')}>
{intl.formatMessage({ id: 'terraApplication.workspace.skipToLabel' })}
</button>
);
}

return (
<header role="banner" className={cx('header')}>
<button type="button" role="link" onClick={onSelectSkipToContent} className={cx('skip-content-button')}>
{intl.formatMessage({ id: 'terraApplication.navigation.header.skipToContentTitle' })}
</button>
{renderSkipToWorkspace()}
<div className={cx('title-container')}>
{renderTitle()}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:local {
.orion-fusion-theme {
--terra-application-resize-handle-hover-background-color: rgba(34, 42, 46, 0.6);
--terra-application-resize-handle-dragging-background-color: rgba(34, 42, 46, 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:local {
.orion-fusion-theme {
--terra-application-workspace-layout-workspace-overlay-background-color: rgba(0, 0, 0, 0.3);
}
}
Loading