1.0.0 • Published 11 months ago

@element-public/react-drawer v1.0.0

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

Drawer

Description

Navigation drawers provide access to destinations and app functionality, such as switching accounts. It can either be permanently on-screen or controlled by a navigation menu icon. A navigation drawer is recommended for: 1. Apps with five or more top-level destinations 2. Apps with two or more levels of navigation hierarchy 3. Quick navigation between unrelated destinations

See live demos on storybook

Storybook Drawer 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-drawer @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

The Drawer component works with, or include, other components, like Button, to open, close, and navigate the Drawer, Typography, to apply certain styles and sizes of text in the Drawer, and List, to improve the flow of the Drawer's contents for users.

Usage

Different Drawers should be used in various cases. For example, a Permanent Drawer could be used to prevent a user from closing or navigating away from the Drawer, so it is always visible. Alternatively, a Dismissible Drawer can be opened and closed by clicking a button, so it only appears when the user wants it to.

Sub Components

Drawer uses the following sub components:

NameDescription
DrawerPrimary container for all the drawer contents
DrawerHeaderContains the top title portion of the drawer.
DrawerContentThe container for the main body of the drawer.
DrawerScrimCovers the screen behind the drawer component to focus the users attention.
DrawerAppContentContainer for app contents. Its child is resized when the drawer opens/closes.

Drawer Props

NameTypeDefaultRequiredDescription
belowTopAppBarbooleannullfalsePositions the modal lower, below the TopAppBar.
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
openbooleannullfalseDisplays the drawer when variant is either dismissible or modal`
variantstringempty stringfalseDefines the type of drawer. By default the drawer will be always shown, a permanent drawer. If defined, either modal or dismissibleAccepted Values: modal, dismissible

Drawer Deprecated Props

NameTypeDefaultRequiredDeprecatedDescription
dismissiblebooleanundefinedfalseUse variant='dismissible' instead.Enables a dismissible drawer.
modalbooleanundefinedfalseUse variant='modal' instead.Enabled a modal drawer.

Drawer Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the Drawer

Drawer Events

NameDefaultRequiredParamsDescription
onClosenullfalseFired when drawer is closed.
onOpennullfalseFired when drawer is opened.

Drawer Breaking Changes

Description
Drawer: Child component DrawerToolbarSpacer has been removed. See DrawerAppContent.

Drawer App Content Props

NameTypeDefaultRequiredDescription
belowTopAppBarbooleannullfalsePositions the modal lower, below the TopAppBar.
classNamestringundefinedfalseThe css class name to be passed through to the component markup.

Drawer App Content Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the DrawerAppContent

Drawer Content Props

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

Drawer Content Render Props

NameTypeDefaultRequiredDescription
childrenReact.ReactNodenullfalseContent to be rendered inside the drawer. Most commonly a list, but accepts any valid markup.

Drawer Header Props

NameTypeDefaultRequiredDescription
classNamestringundefinedfalseThe css class name to be passed through to the component markup.
subtitlestringempty stringfalseSubtitle of Drawer Header
titlestringempty stringfalseTitle of Drawer Header

Drawer Header Render Props

NameTypeDefaultRequiredDescription
avatarReact.ReactNodenullfalseMost commonly an avatar style image, but accepts any valid markup.
childrenReact.ReactNodenullfalseMost commonly a text or a Typography component, but accepts any valid markup.