1.0.0 • Published 11 months ago

@element-public/react-top-app-bar v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

TopAppBar

Description

The top application bar display information and actions relating to the current screen. It can contain branding, screen titles, navigation, and actions.

See live demos on storybook

Storybook TopAppBar Demos

Install bundle from npm-e

npm i @element-public/react-components @element-public/themes

Optional: install the component individually

npm i @element-public/react-top-app-bar @element-public/themes

Open ~/.npmrc in an editor and add the following line to enable the @element-public scope:

@element-public:registry=https://npm.platforms.engineering

Troubleshooting

See below if you have never installed a package from Bayer's npm-enterprise or run into the following error:

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login

Setup an access token

See the devtools npm-e guide to learn how to create an access token if this is the first time you are using a npm-e package at Bayer or you do not have a line that starts with the following in your ~/.npmrc file:

//npm.platforms.engineering/:_authToken=

Notes

TopAppBar is normally placed at the top of a page or site to display things such as the title, subtitle, or other items that a menu would hold. Using TopAppBar is a good way to keep the page organized and easy to navigate. It is easy to use and understand making it very user-friendly.

Top App Bar Props

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
contextualbooleanfalsefalseThe top app bar will styled contextually and displaying contextualActions. A top app bar can transform into a contextual top app bar to provide contextual actions to selected items. For example, if a photo is selected, phot editing actions can be displayed.
contextualThemestring'dark'falseVisual theme of the contextual background, dark or lightAccepted Values: dark, light
densebooleanfalsefalseThe TopAppBar will have reduced padding.
elevatedbooleanfalsefalseWhether or not the top app bar is elevated. By default it will be elevated on scroll only.
fixedbooleantruefalseThe TopAppBar will remain on screen.
logoSizestring'small'falseSize of the logo. Use small for 40x40, medium for 80x40, large for 130x40 images and lgSquare for 48x48.Accepted Values: small, medium, large, lgSquare
logoTitleWrapperReact.ReactNode|functionundefinedfalseOptionally wrap both the logo and title content. This is intended for situations where a combined clickable logo & title would be used to go to the home/root of a website or application. Note: any interaction styling and accessibility concerns need to be handled by the wrapper itself (which is recommended for accessibility).
prominentbooleanfalsefalseThe TopAppBar will have increased padding.
scrollTargetReact.ReactNode|string'window'falseSet a custom scroll target for the top app bar, defaults to window.
subtitlestring|React.ReactNodenullfalseSubtitle text for the Top App Bar. Cannot be used with children.
tabActionsbooleanfalsefalseIndicates whether the actions are tabs. Only necessary if not using Element Tabs. Will apply styles automatically for Element Tabs. Custom CSS may be necessary if not using Element Tabs.
themeColorstring'primary'falseBackground theme color. Accepts one of 'primary', 'secondary', or 'surface'.Accepted Values: primary, secondary, surface, linear-gradient-white-to-bottom, linear-gradient-white-to-top, linear-gradient-black-to-bottom, linear-gradient-black-to-top, linear-gradient-primary-dark-to-bottom, linear-gradient-primary-dark-to-top, linear-gradient-primary-darker-to-bottom, linear-gradient-primary-darker-to-top, linear-gradient-primary-to-bottom, linear-gradient-primary-to-top, linear-gradient-secondary-dark-to-bottom, linear-gradient-secondary-dark-to-top, linear-gradient-secondary-darker-to-bottom, linear-gradient-secondary-darker-to-top, linear-gradient-secondary-to-bottom, linear-gradient-secondary-to-top
titlestring|React.ReactNodenullfalseTitle text for the Top App Bar. Cannot be used with children.
useContentMaxWidthbooleanfalsefalseIf true the top app bar's content will have a max width according to your theme's breakpoints.

Top App Bar Render Props

NameTypeDefaultRequiredDescription
actionsReact.ReactNodenullfalseExpects one or more ActionItems, will accept any valid components or markup.
childrenReact.ReactNodeundefinedfalseContent to be rendered in the center of TopAppBar. Accepts any valid markup. Cannot be used with Title and Subtitle.
logoReact.ReactNodenullfalseOptional logo. Expects an image but accepts any valid markup.
navigationReact.ReactNodenullfalseNavigation icon to trigger a menu. Expects an IconButton but accepts any valid markup.
prominentTabsReact.ReactNodenullfalseTabs to be displayed in the lower slot of the top app bar. If this props is present the prominent props is automatically applied. If the actions prop is tabs actions will be ignored. Expects Element Tabs, but accepts any valid components or markup.

Top App Bar Events

NameDefaultRequiredParamsDescription
onNavigationnullfalseFired when navigation icon is clicked.

Top App Bar Breaking Changes

Description
short (removed): This variant is no longer supported.
shortCollapsed (removed): This variant is no longer supported.
shortCollapsedWithIcons (removed): This variant is no longer supported.
variant (removed): These variants are no longer supported.

Action Item Props

NameTypeDefaultRequiredDescription
badgestring|function|React.ReactNodeundefinedfalseThe custom action notification badge to be rendered.
iconstringnullfalseAccepts the name of any valid material icon (see Icon component documentation for a list of valid icons).
labelstringnullfalseARIA label value to support screen readers.
typestring'icon'falseType of action item to be rendered.Accepted Values: icon, link, tabs

Top App Bar Fixed Adjust Props

NameTypeDefaultRequiredDescription
bannerOpenbooleanfalsefalseApply the adjusted left margin.
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
densebooleanfalsefalseSet to the same value as in TopAppBar to have the correct spacing.
prominentbooleanfalsefalseSet to the same value as in TopAppBar to have the correct spacing.
tagstring|React.ElementType|React.Component'div'falseBase component/tag that will be rendered.
useContentMaxWidthbooleanfalsefalseIf true the content will have a max width according to your theme's breakpoints.

Top App Bar Fixed Adjust Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the TopAppBar. Accepts any valid markup.

Top App Bar Content Wrapper Props

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.

Top App Bar Content Wrapper Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the TopAppBar. Accepts any valid markup.