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 12 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
12 changes: 12 additions & 0 deletions src/application-navigation/ApplicationNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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 +120,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 ApplicationNavigationWorkspace.
*/
workspace: PropTypes.element,
};

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

Expand Down Expand Up @@ -167,6 +177,7 @@ const ApplicationNavigation = ({

return (
<TerraApplicationNavigation
id={id}
hero={hero}
notifications={notifications}
titleConfig={titleConfig}
Expand All @@ -182,6 +193,7 @@ const ApplicationNavigation = ({
onSelectHelp={onSelectHelp}
onSelectLogout={propOnSelectLogout && onSelectLogout}
onDrawerMenuStateChange={onDrawerMenuStateChange}
workspace={workspace}
>
<ApplicationLoadingOverlayProvider>
<ApplicationStatusOverlayProvider>
Expand Down
150 changes: 150 additions & 0 deletions src/application-navigation/ApplicationNavigationWorkspace.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import React from 'react';
import PropTypes from 'prop-types';
import Workspace, { WorkspaceItem } from '../workspace';
import ApplicationNavigationWorkspaceItem from './ApplicationNavigationWorkspaceItem';

const propTypes = {
/**
* Callback function triggering when the workspace size changes.
*/
onSizeChange: PropTypes.func,
/**
* Callback function triggering when the presentation state changes.
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
*/
onPresentationStateChange: PropTypes.func,
/**
* Callback function triggering when the active.
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
*/
onActiveItemChange: PropTypes.func,
/**
* The string key linked to the action workspace.
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
*/
initialActiveItemKey: PropTypes.string.isRequired,
/**
* Child content to be placed within the main content region.
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
*/
children: PropTypes.node.isRequired,
/**
* Whether or not the workspace should initially display as open.
*/
initialIsOpen: PropTypes.bool,
/**
* The size string value matching the active size option.
*/
initialSize: PropTypes.object,
/**
* @private
* Id string to apply to the workspace
*/
id: PropTypes.string.isRequired,
/**
* @private
* Whether or not the workspace is open
*/
isOpen: PropTypes.bool,
/**
* @private
* Function callback i.e. `onRequest(event)`
*/
onRequestClose: PropTypes.func,
/**
* @private
* Whether or not the workspace is present as an overlay
*/
isPresentedAsOverlay: PropTypes.bool,
/**
* @private
* Numeric scale value ranging from `0.0 - 1.0` as the minimum to maximum size for the workspace
*/
sizeScalar: PropTypes.number,
/**
* @private
* The string representation of the workspace size
*/
activeSize: PropTypes.string,
/**
* @private
* Array of objects containing key/text pairs for the available size options
*/
sizeOptions: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
})),
/**
* @private
* Function callback i.e. `onRequestSizeChange(size)`
*/
onRequestSizeChange: PropTypes.func,
};

const ApplicationNavigationWorkspace = ({
// consumer props
onSizeChange,
onPresentationStateChange,
onActiveItemChange,
initialActiveItemKey,
children,
// These props are read by the parent to determine the controlled values to pass down.
initialIsOpen, // eslint-disable-line no-unused-vars, react/no-unused-prop-types
initialSize, // eslint-disable-line no-unused-vars, react/no-unused-prop-types

// private injected props
id,
isOpen,
onRequestClose,
isPresentedAsOverlay,
sizeScalar,
activeSize,
sizeOptions,
onRequestSizeChange,
}) => {
const [activeItemKey, setActiveItemKey] = React.useState(initialActiveItemKey);

React.useEffect(() => {
if (onSizeChange && sizeScalar !== undefined) {
onSizeChange(sizeScalar);
}
}, [sizeScalar, onSizeChange]);

React.useEffect(() => {
if (onPresentationStateChange) {
onPresentationStateChange(isOpen);
}
}, [isOpen, onPresentationStateChange]);

React.useEffect(() => {
if (onActiveItemChange) {
onActiveItemChange(activeItemKey);
}
}, [activeItemKey, onActiveItemChange]);

return (
<Workspace
id={id}
activeItemKey={activeItemKey}
onRequestActivate={itemKey => {
setActiveItemKey(itemKey);
}}
activeSize={activeSize}
sizeOptions={sizeOptions}
onRequestSizeChange={onRequestSizeChange}
onRequestDismiss={onRequestClose}
dismissButtonIsVisible={isPresentedAsOverlay}
isPresentedAsOverlay={isPresentedAsOverlay}
>
{React.Children.map(children, (child) => (
<WorkspaceItem
itemKey={child.props.itemKey}
label={child.props.label}
metaData={child.props.metaData}
render={child.props.render}
/>
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
))}
</Workspace>
);
};

ApplicationNavigationWorkspace.propTypes = propTypes;
ApplicationNavigationWorkspace.Item = ApplicationNavigationWorkspaceItem;

export default ApplicationNavigationWorkspace;
28 changes: 28 additions & 0 deletions src/application-navigation/ApplicationNavigationWorkspaceItem.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
import PropTypes from 'prop-types';

/* eslint-disable no-unused-vars, react/no-unused-prop-types */
const propTypes = {
/**
* Key to match with the activeItemKey to handle the display of selection.
*/
itemKey: PropTypes.string.isRequired,
/**
* Text to be displayed on the item or as it's aria-label.
*/
label: PropTypes.string.isRequired,
/**
* Object to be returned in the onRequestActive.
*/
metaData: PropTypes.object,
/**
* The render block for the workspace item
*/
render: PropTypes.func,
};

const ApplicationNavigationWorkspaceItem = () => <React.Fragment />;

ApplicationNavigationWorkspaceItem.propTypes = propTypes;

export default ApplicationNavigationWorkspaceItem;
19 changes: 16 additions & 3 deletions src/application-navigation/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import {
titleConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType, userConfigPropType,
titleConfigPropType,
navigationItemsPropType,
extensionItemsPropType,
utilityItemsPropType,
userConfigPropType,
} from './private/utils/propTypes';
import ApplicationNavigationActionsContext from './ApplicationNavigationActionsContext';
import ApplicationNavigation from './ApplicationNavigation';
import ApplicationNavigationWorkspace from './ApplicationNavigationWorkspace';
import ApplicationNavigationWorkspaceItem from './ApplicationNavigationWorkspaceItem';

export default ApplicationNavigation;
export {
titleConfigPropType, navigationItemsPropType, extensionItemsPropType, utilityItemsPropType, userConfigPropType,
titleConfigPropType,
navigationItemsPropType,
extensionItemsPropType,
utilityItemsPropType,
userConfigPropType,
ApplicationNavigationActionsContext,
ApplicationNavigationWorkspace,
ApplicationNavigationWorkspaceItem,
dkasper-was-taken marked this conversation as resolved.
Show resolved Hide resolved
};

Loading