From b3239165243f5bee1e7c1aeb2c1c1e4ae50d6ed2 Mon Sep 17 00:00:00 2001 From: "Taushanova-Atanasova, Inna" Date: Mon, 29 Oct 2018 16:45:23 -0400 Subject: [PATCH] Issue#14: refactor action bar --- src/ActionBar/ActionBar.Component.js | 244 +++++++++++++++++++++------ src/ActionBar/ActionBar.js | 61 ++++--- src/index.js | 10 +- 3 files changed, 242 insertions(+), 73 deletions(-) diff --git a/src/ActionBar/ActionBar.Component.js b/src/ActionBar/ActionBar.Component.js index 62895e03f..3f52334c3 100644 --- a/src/ActionBar/ActionBar.Component.js +++ b/src/ActionBar/ActionBar.Component.js @@ -1,30 +1,91 @@ import React from 'react'; -import { ActionBar } from '../'; +import { ActionBar, ActionBarBack, ActionBarHeader, ActionBarActions } from '../'; import { Button, Popover, Menu, MenuList, MenuItem } from '../'; import { DocsTile, DocsText, Separator, Header, Description, Import, Properties } from '../'; export const ActionBarComponent = () => { - const titleActionBarCode = ``; + const actionBarBackBtnCode = ` + + + + + + +`; + + const actionBarNoBackBtnCode = ` + + + + + +`; - const mainActionsActionBarCode = ` - - + const actionBarContextualCode = ` + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + `; - const severalActionsActionBarCode = ` - } - body={ - - - Option 1 - Option 2 - Option 3 - Option 4 - - - } - /> + const mobileActionBarCode = ` + + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + +`; + + const mobileCustomWidthActionBarCode = ` + + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + `; return ( @@ -41,40 +102,58 @@ export const ActionBarComponent = () => { -

Title

- - The page title is displayed prominently in the Action Bar. This is helpful for the user to know exactly - where they are. - +

Action bar with back button, description and action buttons.

- + + + + + + + + - {titleActionBarCode} + {actionBarBackBtnCode} -

Main Actions

- - Display main actions within the Action bar. This allows for users to find important page actions in a - consistent area no matter what page they are on within the application. - +

Action bar with no Back button

- - - + + + + + + - {mainActionsActionBarCode} + {actionBarNoBackBtnCode} @@ -85,23 +164,84 @@ export const ActionBarComponent = () => { more than 3-4 actions. This also works well for a responsive/adaptive application. - - } - body={ - - - Option 1 - Option 2 - Option 3 - Option 4 - - - } + + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + + + + {actionBarContextualCode} + + + +

Action bar mobile view

+ + + + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + + + + {mobileActionBarCode} + + + +

Action bar mobile view with custom width

+ + + + + + } + body={ + + + Option 1 + Option 2 + Option 3 + Option 4 + + + } + /> + - {severalActionsActionBarCode} + {mobileCustomWidthActionBarCode} diff --git a/src/ActionBar/ActionBar.js b/src/ActionBar/ActionBar.js index 2800d0e00..02302f05d 100644 --- a/src/ActionBar/ActionBar.js +++ b/src/ActionBar/ActionBar.js @@ -1,29 +1,50 @@ import React from 'react'; import PropTypes from 'prop-types'; -export const ActionBar = (props) => { - const { title, hasActions, children } = props; +export const ActionBar = props => { + const { mobile, width, children } = props; + return ( -
-
-

- {title} -

-
- { - hasActions ? ( -
- { children } -
- ) : null - } -
+ + {mobile ? ( +
+
{children}
+
+ ) : ( +
{children}
+ )} +
); -} +}; ActionBar.propTypes = { - title: PropTypes.string.isRequired, - hasActions: PropTypes.bool -} + mobile: PropTypes.bool +}; + +export const ActionBarBack = props => { + return ( +
+
+ ); +}; + +export const ActionBarHeader = props => { + const { title, description } = props; + return ( +
+

{title}

+

{description}

+
+ ); +}; +ActionBarHeader.propTypes = { + title: PropTypes.string, + description: PropTypes.string +}; +export const ActionBarActions = props => { + const { children } = props; + return
{children}
; +}; diff --git a/src/index.js b/src/index.js index 762ab9522..b9ae0d1fd 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,12 @@ import './index.css'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; -import { ActionBar } from '../src/ActionBar/ActionBar'; +import { + ActionBar, + ActionBarBack, + ActionBarHeader, + ActionBarActions +} from '../src/ActionBar/ActionBar'; import { Alert } from '../src/Alert/Alert'; import { Badge, Label, Status } from '../src/Badge/Badge'; import { Breadcrumb, BreadcrumbItem } from '../src/Breadcrumb/Breadcrumb'; @@ -69,6 +74,9 @@ export { Properties, Playground, ActionBar, + ActionBarBack, + ActionBarHeader, + ActionBarActions, Alert, Badge, Label,