diff --git a/src-docs/src/components/guide_components.scss b/src-docs/src/components/guide_components.scss index 3950197f7de..249c88f7ff0 100644 --- a/src-docs/src/components/guide_components.scss +++ b/src-docs/src/components/guide_components.scss @@ -5,6 +5,10 @@ $guideZLevelHighest: $euiZLevel9 + 1000; .guideBody { background: linear-gradient(90deg, $euiPageBackgroundColor 50%, $euiColorEmptyShade 50%); + + &--overflowHidden { + overflow: hidden; + } } .guidePage { diff --git a/src-docs/src/services/full_screen/full_screen.tsx b/src-docs/src/services/full_screen/full_screen.tsx index b28db7f134c..716e0e93c1a 100644 --- a/src-docs/src/services/full_screen/full_screen.tsx +++ b/src-docs/src/services/full_screen/full_screen.tsx @@ -4,6 +4,7 @@ import React, { FunctionComponent, ReactElement, ReactNode, + useEffect, } from 'react'; import { EuiFocusTrap } from '../../../../src/components/focus_trap'; @@ -20,6 +21,16 @@ export const GuideFullScreen: FunctionComponent<{ }) => { const [fullScreen, setFullScreen] = useState(isFullScreen); + // Watch for fullScreen status and appropriately add/remove body classes for hiding scroll + useEffect(() => { + if (fullScreen) { + document.body.classList.add('guideBody--overflowHidden'); + } + return () => { + document.body.classList.remove('guideBody--overflowHidden'); + }; + }, [fullScreen]); + return ( setFullScreen(true)} iconType="fullScreen"> diff --git a/src-docs/src/views/collapsible_nav/collapsible_nav.tsx b/src-docs/src/views/collapsible_nav/collapsible_nav.tsx index 10ad5cec714..1846d214457 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav.tsx +++ b/src-docs/src/views/collapsible_nav/collapsible_nav.tsx @@ -4,6 +4,8 @@ import { EuiCollapsibleNav } from '../../../../src/components/collapsible_nav'; import { EuiButton, EuiButtonToggle } from '../../../../src/components/button'; import { EuiTitle } from '../../../../src/components/title'; import { EuiSpacer } from '../../../../src/components/spacer'; +import { EuiText } from '../../../../src/components/text'; +import { EuiCode } from '../../../../src/components/code'; export default () => { const [navIsOpen, setNavIsOpen] = useState(false); @@ -11,34 +13,37 @@ export default () => { return ( <> - setNavIsOpen(!navIsOpen)} - aria-label="Toggle main navigation" - aria-controls="guideCollapsibleNavExampleNav" - aria-expanded={navIsOpen} - aria-pressed={navIsOpen}> - Toggle nav - - {navIsOpen && ( - setNavIsOpen(false)}> -
- -

I am some nav

-
- - { - setNavIsDocked(!navIsDocked); - }} - /> -
-
+ setNavIsOpen(!navIsOpen)}> + Toggle nav +
+ } + isDocked={navIsDocked} + onClose={() => setNavIsOpen(false)}> +
+ +

I am some nav

+
+ + { + setNavIsDocked(!navIsDocked); + }} + /> +
+ + + {navIsDocked && ( + +

+ The button gets hidden by default when nav is docked unless you set{' '} + hideButtonIfDocked = false. +

+
)} ); diff --git a/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx b/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx index 1f378e0be34..4f663f4830f 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx +++ b/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx @@ -3,7 +3,6 @@ import _ from 'lodash'; import { EuiCollapsibleNav, - EuiCollapsibleNavToggle, EuiCollapsibleNavGroup, } from '../../../../src/components/collapsible_nav'; import { @@ -30,8 +29,15 @@ import { } from './collapsible_nav_list'; import { EuiShowFor } from '../../../../src/components/responsive'; -const TopLinks = [ - { label: 'Home', iconType: 'home', isActive: true, 'aria-current': true }, +const TopLinks: EuiPinnableListGroupItemProps[] = [ + { + label: 'Home', + iconType: 'home', + isActive: true, + 'aria-current': true, + href: '#/navigation/collapsible-nav', + pinnable: false, + }, ]; const KibanaLinks: EuiPinnableListGroupItemProps[] = KibanaNavLinks.map( link => { @@ -132,17 +138,115 @@ export default () => { return `Unpin ${listItem.label}`; } + const collapsibleNav = ( + setNavIsOpen(!navIsOpen)}> + + ); + const leftSectionItems = [ - - setNavIsOpen(!navIsOpen)}> - - , + collapsibleNav, Elastic, ]; @@ -169,109 +273,6 @@ export default () => { ]} /> - {navIsOpen && ( - setNavIsOpen(false)}> - {/* Dark deployments section */} - - {DeploymentsGroup} - - - {/* Shaded pinned section always with a home item */} - - - - - - - - - {/* BOTTOM */} - - {/* Kibana section */} - - toggleAccordion(isOpen, 'Kibana') - }> - - - - {/* Security callout */} - {SecurityGroup} - - {/* Learn section */} - - toggleAccordion(isOpen, 'Learn') - }> - - - - {/* Docking button only for larger screens that can support it*/} - - - { - setNavIsDocked(!navIsDocked); - localStorage.setItem( - 'navIsDocked', - JSON.stringify(!navIsDocked) - ); - }} - iconType={navIsDocked ? 'lock' : 'lockOpen'} - /> - - - - - )} - )} diff --git a/src-docs/src/views/collapsible_nav/collapsible_nav_example.js b/src-docs/src/views/collapsible_nav/collapsible_nav_example.js index e94d31b86c0..b8fe9777d8b 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav_example.js +++ b/src-docs/src/views/collapsible_nav/collapsible_nav_example.js @@ -40,7 +40,7 @@ export const CollapsibleNavExample = { EuiNavDrawer {' '} - which will be deprecated in the coming months. + which will be deprecated soon.

@@ -77,13 +77,12 @@ export const CollapsibleNavExample = { ), props: { EuiCollapsibleNav }, demo: , - snippet: ` setNavIsOpen(!navIsOpen)}>Toggle nav -{navIsOpen && ( - setNavIsOpen(false)} - /> -)}`, + snippet: ` setNavIsOpen(!navIsOpen)}>Toggle nav} + isOpen={navIsOpen} + isDocked={navIsDocked} + onClose={() => setNavIsOpen(false)} +/>`, }, { title: 'Collapsible nav group', @@ -163,6 +162,7 @@ export const CollapsibleNavExample = { isCollapsible={true} initialIsOpen={true}> -

EuiCollapsibleNavToggle

-

- This example also introduces the{' '} - EuiCollapsibleNavToggle component, which is used to - simply wrap around your external nav trigger to show/hide in certain - docked and mobile states. -

), demo: , diff --git a/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx b/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx index dda87842154..c64b3661cf3 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx +++ b/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx @@ -30,6 +30,7 @@ export const TopNavLinks: EuiPinnableListGroupItemProps[] = [ label: 'Home', iconType: 'home', isActive: true, + pinnable: false, }, { label: 'Dashboards', pinned: true }, { label: 'Dev tools', pinned: true }, @@ -103,7 +104,7 @@ export default () => ( listItems={TopNavLinks} onPinClick={() => {}} maxWidth="none" - color="subdued" + color="text" gutterSize="none" size="s" /> diff --git a/src-docs/src/views/list_group/pinnable_list_group.tsx b/src-docs/src/views/list_group/pinnable_list_group.tsx index 8f0ba4f7564..4716de39ef8 100644 --- a/src-docs/src/views/list_group/pinnable_list_group.tsx +++ b/src-docs/src/views/list_group/pinnable_list_group.tsx @@ -34,6 +34,10 @@ const someListItems: EuiPinnableListGroupItemProps[] = [ 'aria-label': 'bell', }, }, + { + label: 'Item with pinnability turned off', + pinnable: false, + }, ]; export default () => ( diff --git a/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap b/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap index 81f4736c38b..9c6136cdc25 100644 --- a/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap +++ b/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap @@ -1,6 +1,26 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiCollapsibleNav can be docked 1`] = ` +exports[`EuiCollapsibleNav is rendered 1`] = `null`; + +exports[`EuiCollapsibleNav props button 1`] = ` + +
  • + + + Not pinnable + + +
  • `; @@ -169,9 +184,9 @@ exports[`EuiPinnableListGroup is rendered 1`] = ` +
  • + + + Not pinnable + + +
  • `; diff --git a/src/components/list_group/pinnable_list_group/pinnable_list_group.test.tsx b/src/components/list_group/pinnable_list_group/pinnable_list_group.test.tsx index a658231b09b..7957953c655 100644 --- a/src/components/list_group/pinnable_list_group/pinnable_list_group.test.tsx +++ b/src/components/list_group/pinnable_list_group/pinnable_list_group.test.tsx @@ -36,6 +36,11 @@ const someListItems: EuiPinnableListGroupItemProps[] = [ label: 'Link with href', href: '#', }, + { + label: 'Not pinnable', + href: '#', + pinnable: false, + }, ]; describe('EuiPinnableListGroup', () => { diff --git a/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx b/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx index 891e27d1cc1..c1b1a551d07 100644 --- a/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx +++ b/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx @@ -23,7 +23,15 @@ const pinnedExtraAction: EuiListGroupItemProps['extraAction'] = { }; export type EuiPinnableListGroupItemProps = EuiListGroupItemProps & { + /** + * Saves the pinned status and changes the visibility of the pin icon + */ pinned?: boolean; + /** + * Passing `onPinClick` to the full EuiPinnableListGroup, will make every item pinnable. + * Set this property to `false` to turn off individual item pinnability + */ + pinnable?: boolean; }; export interface EuiPinnableListGroupProps @@ -64,7 +72,7 @@ export const EuiPinnableListGroup: FunctionComponent< pinnedExtraActionLabel: string ) => listItems.map(item => { - const { pinned, ...itemProps } = item; + const { pinned, pinnable = true, ...itemProps } = item; // Make some declarations of props for the nav implementation itemProps.className = classNames( 'euiPinnableListGroup__item', @@ -72,7 +80,7 @@ export const EuiPinnableListGroup: FunctionComponent< ); // Add the pinning action unless the item has it's own extra action - if (onPinClick && !itemProps.extraAction) { + if (onPinClick && !itemProps.extraAction && pinnable) { // Different displays for pinned vs unpinned if (pinned) { itemProps.extraAction = { @@ -85,8 +93,8 @@ export const EuiPinnableListGroup: FunctionComponent< } else { itemProps.extraAction = { ...pinExtraAction, - title: pinTitle ? pinTitle(item) : pinnedExtraActionLabel, - 'aria-label': pinTitle ? pinTitle(item) : pinnedExtraActionLabel, + title: pinTitle ? pinTitle(item) : pinExtraActionLabel, + 'aria-label': pinTitle ? pinTitle(item) : pinExtraActionLabel, }; } // Return the item on click