This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terra-navigation-side-menu] Added Drill-In view variant (#2161)
Co-authored-by: Sugan G <[email protected]> Co-authored-by: MadanKumarGovindaswamy <[email protected]>
- Loading branch information
1 parent
9fe1737
commit 83c138f
Showing
41 changed files
with
1,065 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...rra-framework-docs/src/terra-dev-site/doc/navigation-side-menu/example/DrillInExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames/bind'; | ||
import NavigationSideMenu, { VARIANTS } from 'terra-navigation-side-menu'; | ||
import { IconHospital } from 'terra-icon'; | ||
|
||
import styles from './NavigationSideMenuExample.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
class DrillInDefault extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.handleOnChange = this.handleOnChange.bind(this); | ||
|
||
this.state = { selectedMenuKey: 'menu', selectedChildKey: undefined }; | ||
} | ||
|
||
handleOnChange(event, changeData) { | ||
this.setState({ selectedMenuKey: changeData.selectedMenuKey, selectedChildKey: changeData.selectedChildKey }); | ||
} | ||
|
||
render() { | ||
const content = ( | ||
<NavigationSideMenu | ||
id="test-menu" | ||
menuItems={[ | ||
{ | ||
key: 'menu', text: 'Hospital Details', childKeys: ['submenu1', 'submenu2', 'submenu3', 'submenu4', 'submenu5'], | ||
}, | ||
{ | ||
key: 'submenu1', | ||
text: 'Hospital services', | ||
childKeys: ['subsubmenu1', 'subsubmenu2', 'subsubmenu3'], | ||
id: 'test-item-1', | ||
}, | ||
{ key: 'submenu2', text: 'Hospital events' }, | ||
{ | ||
key: 'submenu3', text: 'Hospital Accommodations', isDisabled: true, | ||
}, | ||
{ key: 'submenu4', text: 'Hospital Careers' }, | ||
{ key: 'submenu5', text: 'Hospital Info', childKeys: [] }, | ||
{ | ||
key: 'subsubmenu1', text: 'Imaging', id: 'test-item-2', | ||
}, | ||
{ key: 'subsubmenu2', text: 'Laboratory' }, | ||
{ | ||
key: 'subsubmenu3', text: 'Rehabilitation services', childKeys: ['rehab1', 'rehab2', 'rehab3'], icon: <IconHospital />, | ||
}, | ||
{ key: 'rehab1', text: 'Rehabilitation services 1' }, | ||
{ key: 'rehab2', text: 'Rehabilitation services 2' }, | ||
{ key: 'rehab3', text: 'Rehabilitation services 3', childKeys: [] }, | ||
]} | ||
onChange={this.handleOnChange} | ||
selectedMenuKey={this.state.selectedMenuKey} | ||
selectedChildKey={this.state.selectedChildKey} | ||
ariaLabel="Sub Menu List" | ||
variant={VARIANTS.DRILL_IN} | ||
/> | ||
); | ||
|
||
return ( | ||
<div className={cx('content-wrapper')}> | ||
{content} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default DrillInDefault; |
91 changes: 91 additions & 0 deletions
91
packages/terra-framework-docs/src/terra-dev-site/test/navigation-side-menu/DrillIn.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames/bind'; | ||
import NavigationSideMenu, { VARIANTS } from 'terra-navigation-side-menu'; | ||
import { IconHospital } from 'terra-icon'; | ||
import styles from './NavigationSideMenuDocCommon.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
class DrillInExample extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.handleOnChange = this.handleOnChange.bind(this); | ||
this.resetMenuState = this.resetMenuState.bind(this); | ||
this.fakeRoutingBack = this.fakeRoutingBack.bind(this); | ||
|
||
this.state = { selectedMenuKey: 'menu', selectedChildKey: undefined }; | ||
} | ||
|
||
handleOnChange(event, changeData) { | ||
this.setState({ selectedMenuKey: changeData.selectedMenuKey, selectedChildKey: changeData.selectedChildKey }); | ||
} | ||
|
||
resetMenuState() { | ||
this.setState({ selectedMenuKey: 'menu', selectedChildKey: undefined }); | ||
} | ||
|
||
fakeRoutingBack() { | ||
this.setState({ selectedMenuKey: 'fake-parent', selectedChildKey: undefined }); | ||
} | ||
|
||
render() { | ||
let content; | ||
if (this.state.selectedMenuKey === 'fake-parent') { | ||
content = ( | ||
<div className={cx('content')}> | ||
<button type="button" onClick={this.resetMenuState}> | ||
Child Route | ||
</button> | ||
<p>Parent Route</p> | ||
</div> | ||
); | ||
} else { | ||
content = ( | ||
<NavigationSideMenu | ||
id="test-menu" | ||
menuItems={[ | ||
{ | ||
key: 'menu', text: 'Hospital Details', childKeys: ['submenu1', 'submenu2', 'submenu3', 'submenu4', 'submenu5'], | ||
}, | ||
{ | ||
key: 'submenu1', | ||
text: 'Hospital services', | ||
childKeys: ['subsubmenu1', 'subsubmenu2', 'subsubmenu3'], | ||
id: 'test-item-1', | ||
}, | ||
{ key: 'submenu2', text: 'Hospital events' }, | ||
{ | ||
key: 'submenu3', text: 'Hospital Accommodations', | ||
}, | ||
{ key: 'submenu4', text: 'Hospital Careers' }, | ||
{ key: 'submenu5', text: 'Hospital Info', childKeys: [] }, | ||
{ | ||
key: 'subsubmenu1', text: 'Imaging', id: 'test-item-2', | ||
}, | ||
{ key: 'subsubmenu2', text: 'Laboratory' }, | ||
{ | ||
key: 'subsubmenu3', text: 'Rehabilitation services', childKeys: ['rehab1', 'rehab2', 'rehab3'], icon: <IconHospital />, | ||
}, | ||
{ key: 'rehab1', text: 'Rehabilitation services 1' }, | ||
{ key: 'rehab2', text: 'Rehabilitation services 2' }, | ||
{ key: 'rehab3', text: 'Rehabilitation services 3', childKeys: [] }, | ||
]} | ||
onChange={this.handleOnChange} | ||
routingStackBack={this.fakeRoutingBack} | ||
selectedMenuKey={this.state.selectedMenuKey} | ||
selectedChildKey={this.state.selectedChildKey} | ||
variant={VARIANTS.DRILL_IN} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={cx('content-wrapper')}> | ||
{content} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default DrillInExample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.