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 926156ee990..f207c9b2e68 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx +++ b/src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx @@ -28,7 +28,6 @@ import { KibanaNavLinks, SecurityGroup } from './collapsible_nav_list'; import contentSvg from '../../images/content.svg'; import { useExitPath } from '../../services/routing/routing'; -import { EuiThemeProvider } from '../../../../src/services'; const TopLinks: EuiPinnableListGroupItemProps[] = [ { @@ -161,23 +160,21 @@ const CollapsibleNavAll = () => { {/* Dark deployments section */} - - - + }, + ]} + /> 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 f31e9fdb9da..5b72849246e 100644 --- a/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx +++ b/src-docs/src/views/collapsible_nav/collapsible_nav_list.tsx @@ -11,7 +11,6 @@ import { import { EuiSpacer } from '../../../../src/components/spacer'; import { EuiButton, EuiButtonIcon } from '../../../../src/components/button'; import { EuiLink } from '../../../../src/components/link'; -import { EuiThemeProvider } from '../../../../src/services'; const deploymentsList: EuiListGroupProps['listItems'] = [ { @@ -62,13 +61,9 @@ export const DeploymentsGroup = ( initialIsOpen={false} background="dark" > -
- - - - Manage deployments - -
+ + + Manage deployments ); 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 3677d6e1e06..63e57b55dc6 100644 --- a/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap +++ b/src/components/collapsible_nav/__snapshots__/collapsible_nav.test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiCollapsibleNav close button can be hidden 1`] = ` -Array [ +
, -] +
+
`; -exports[`EuiCollapsibleNav does not render if isOpen is false 1`] = `null`; +exports[`EuiCollapsibleNav does not render if isOpen is false 1`] = `
`; exports[`EuiCollapsibleNav is rendered 1`] = ` -Array [ +
- You are in a modal dialog. Press Escape or tap/click outside the dialog on the shadowed overlay to close. + You are in a modal dialog. Press Escape or tap/click outside the dialog on the shadowed overlay to close. +

, -] +
+
`; exports[`EuiCollapsibleNav props accepts EuiFlyout props 1`] = ` -Array [ +
, + />
-
, +
, -] + /> +
`; exports[`EuiCollapsibleNav props button 1`] = ` -Array [ +
, -] +
+
`; exports[`EuiCollapsibleNav props dockedBreakpoint 1`] = ` -Array [ +
, -] +
+
`; exports[`EuiCollapsibleNav props isDocked 1`] = ` -Array [ +
, + />
, +
, -] + /> +
`; exports[`EuiCollapsibleNav props onClose 1`] = ` -Array [ +
, -] +
+
`; exports[`EuiCollapsibleNav props showButtonIfDocked 1`] = ` -Array [ +
, -] +
+ `; diff --git a/src/components/collapsible_nav/_collapsible_nav.scss b/src/components/collapsible_nav/_collapsible_nav.scss deleted file mode 100644 index 1a55a416ae4..00000000000 --- a/src/components/collapsible_nav/_collapsible_nav.scss +++ /dev/null @@ -1,5 +0,0 @@ -// Extends - -.euiCollapsibleNav:not([class*='push']) { - z-index: $euiZNavigation !important; // stylelint-disable-line declaration-no-important -} diff --git a/src/components/collapsible_nav/_index.scss b/src/components/collapsible_nav/_index.scss deleted file mode 100644 index a31c44be949..00000000000 --- a/src/components/collapsible_nav/_index.scss +++ /dev/null @@ -1,4 +0,0 @@ -@import 'variables'; - -@import 'collapsible_nav'; -@import 'collapsible_nav_group/index'; diff --git a/src/components/collapsible_nav/_variables.scss b/src/components/collapsible_nav/_variables.scss deleted file mode 100644 index 20d9200b330..00000000000 --- a/src/components/collapsible_nav/_variables.scss +++ /dev/null @@ -1,12 +0,0 @@ -// Sizing -$euiCollapsibleNavGroupLightBackgroundColor: $euiPageBackgroundColor !default; - -$euiCollapsibleNavGroupDarkBackgroundColor: lightOrDarkTheme( - shade($euiColorDarkestShade, 20%), - shade($euiColorLightestShade, 50%), -) !default; - -$euiCollapsibleNavGroupDarkHighContrastColor: makeGraphicContrastColor( - $euiColorPrimary, - $euiCollapsibleNavGroupDarkBackgroundColor -) !default; diff --git a/src/components/collapsible_nav/collapsible_nav.stories.tsx b/src/components/collapsible_nav/collapsible_nav.stories.tsx new file mode 100644 index 00000000000..77a89909ea2 --- /dev/null +++ b/src/components/collapsible_nav/collapsible_nav.stories.tsx @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { Meta, StoryObj } from '@storybook/react'; +import React, { useState } from 'react'; + +import { EuiButton } from '../button'; +import { EuiCollapsibleNav, EuiCollapsibleNavProps } from './collapsible_nav'; + +const meta: Meta = { + title: 'EuiCollapsibleNav', + component: EuiCollapsibleNav, + // TODO: Improve props inherited from EuiFlyout, ideally through + // a DRY import from `flyout.stories.tsx` once that's created +}; + +export default meta; +type Story = StoryObj; + +const StatefulCollapsibleNav = (props: Partial) => { + const [isOpen, setIsOpen] = useState(props.isOpen); + return ( + setIsOpen((isOpen) => !isOpen)}> + Toggle nav + + } + onClose={() => setIsOpen(false)} + /> + ); +}; + +export const Playground: Story = { + render: ({ ...args }) => , + args: { + children: 'Collapsible nav content', + isOpen: true, + isDocked: false, + dockedBreakpoint: 'l', + showButtonIfDocked: false, + size: 240, + }, +}; diff --git a/src/components/collapsible_nav/collapsible_nav.styles.ts b/src/components/collapsible_nav/collapsible_nav.styles.ts new file mode 100644 index 00000000000..b1344aced8e --- /dev/null +++ b/src/components/collapsible_nav/collapsible_nav.styles.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { css } from '@emotion/react'; +import { UseEuiTheme } from '../../services'; + +export const euiCollapsibleNavStyles = ({ euiTheme }: UseEuiTheme) => { + return { + euiCollapsibleNav: css``, // The majority of styles extend from EuiFlyout + push: css``, // No z-index needed + overlay: css` + z-index: ${euiTheme.levels.navigation}; + `, + }; +}; diff --git a/src/components/collapsible_nav/collapsible_nav.test.tsx b/src/components/collapsible_nav/collapsible_nav.test.tsx index 8290a998a8b..cf9239a6f27 100644 --- a/src/components/collapsible_nav/collapsible_nav.test.tsx +++ b/src/components/collapsible_nav/collapsible_nav.test.tsx @@ -7,8 +7,9 @@ */ import React from 'react'; -import { render, mount } from 'enzyme'; -import { requiredProps, takeMountedSnapshot } from '../../test'; +import { render } from '../../test/rtl'; +import { requiredProps } from '../../test'; +import { shouldRenderCustomStyles } from '../../test/internal'; import { EuiCollapsibleNav } from './collapsible_nav'; import { EuiOverlayMaskProps } from '../overlay_mask'; @@ -32,77 +33,59 @@ const flyoutProps = { }; describe('EuiCollapsibleNav', () => { + shouldRenderCustomStyles(); + test('is rendered', () => { - const component = mount( + const { container } = render( ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); describe('props', () => { test('onClose', () => { - const component = mount( + const { container } = render( {}} /> ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('size', () => { - const component = mount( + const { container } = render( ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('isDocked', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('dockedBreakpoint', () => { - const component = mount( + const { container } = render( ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('button', () => { - const component = mount( + const { container } = render( } /> ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('showButtonIfDocked', () => { - const component = mount( + const { container } = render( } @@ -111,43 +94,33 @@ describe('EuiCollapsibleNav', () => { /> ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('accepts EuiFlyout props', () => { - const component = mount( + const { container } = render( ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); describe('close button', () => { test('can be hidden', () => { - const component = mount( + const { container } = render( ); - expect( - takeMountedSnapshot(component, { - hasArrayOutput: true, - }) - ).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); test('does not render if isOpen is false', () => { - const component = render( {}} id="id" />); + const { container } = render( + {}} id="id" /> + ); - expect(component).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/src/components/collapsible_nav/collapsible_nav.tsx b/src/components/collapsible_nav/collapsible_nav.tsx index a8ebb4c3466..a2704d7f195 100644 --- a/src/components/collapsible_nav/collapsible_nav.tsx +++ b/src/components/collapsible_nav/collapsible_nav.tsx @@ -15,11 +15,13 @@ import React, { } from 'react'; import classNames from 'classnames'; import { + useEuiTheme, useGeneratedHtmlId, useIsWithinMinBreakpoint, useCombinedRefs, } from '../../services'; import { EuiFlyout, EuiFlyoutProps } from '../flyout'; +import { euiCollapsibleNavStyles } from './collapsible_nav.styles'; // Extend all the flyout props except `onClose` because we handle this internally export type EuiCollapsibleNavProps = Omit< @@ -85,8 +87,12 @@ export const EuiCollapsibleNav: FunctionComponent = ({ const windowIsLargeEnoughToPush = useIsWithinMinBreakpoint(dockedBreakpoint); const navIsDocked = isDocked && windowIsLargeEnoughToPush; + const flyoutType = navIsDocked ? 'push' : 'overlay'; const classes = classNames('euiCollapsibleNav', className); + const euiTheme = useEuiTheme(); + const styles = euiCollapsibleNavStyles(euiTheme); + const cssStyles = [styles.euiCollapsibleNav, styles[flyoutType]]; // Show a trigger button if one was passed but // not if navIsDocked and showButtonIfDocked is false @@ -111,6 +117,7 @@ export const EuiCollapsibleNav: FunctionComponent = ({ const flyout = ( = ({ focusTrapProps={focusTrapProps} {...rest} // Props dependent on internal docked status - type={navIsDocked ? 'push' : 'overlay'} + type={flyoutType} hideCloseButton={navIsDocked} pushMinBreakpoint={dockedBreakpoint} > diff --git a/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap b/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap index b4e3496cf35..0db13ad19fc 100644 --- a/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap +++ b/src/components/collapsible_nav/collapsible_nav_group/__snapshots__/collapsible_nav_group.test.tsx.snap @@ -3,7 +3,7 @@ exports[`EuiCollapsibleNavGroup is rendered 1`] = `
@@ -11,28 +11,28 @@ exports[`EuiCollapsibleNavGroup is rendered 1`] = ` exports[`EuiCollapsibleNavGroup props background dark is rendered 1`] = `
`; exports[`EuiCollapsibleNavGroup props background light is rendered 1`] = `
`; exports[`EuiCollapsibleNavGroup props background none is rendered 1`] = `
`; exports[`EuiCollapsibleNavGroup props iconProps renders data-test-subj 1`] = `
`; exports[`EuiCollapsibleNavGroup throws a warning if iconType is passed without a title 1`] = `
`; @@ -199,7 +199,7 @@ exports[`EuiCollapsibleNavGroup throws a warning if iconType is passed without a exports[`EuiCollapsibleNavGroup when isCollapsible is true accepts accordion props 1`] = `
= { + title: 'EuiCollapsibleNavGroup', + // @ts-ignore This still works for Storybook controls, even though Typescript complains + component: EuiCollapsibleNavGroup, + argTypes: { + // Only show when `title` is set + titleSize: { if: { arg: 'title' } }, + titleElement: { if: { arg: 'title' } }, + iconType: { if: { arg: 'title' } }, + iconSize: { if: { arg: 'title' } }, + iconProps: { if: { arg: 'title' } }, + // EuiAccordion props that should only show if `isCollapsible` + // (and `title`, but Storybook doesn't support multiple conditional controls) + buttonElement: { if: { arg: 'isCollapsible' } }, + buttonProps: { if: { arg: 'isCollapsible' } }, + buttonClassName: { if: { arg: 'isCollapsible' } }, + buttonContentClassName: { if: { arg: 'isCollapsible' } }, + buttonContent: { if: { arg: 'isCollapsible' } }, + arrowProps: { if: { arg: 'isCollapsible' } }, + extraAction: { if: { arg: 'isCollapsible' } }, + initialIsOpen: { if: { arg: 'isCollapsible' } }, + onToggle: { if: { arg: 'isCollapsible' } }, + paddingSize: { if: { arg: 'isCollapsible' } }, + arrowDisplay: { if: { arg: 'isCollapsible' } }, + forceState: { if: { arg: 'isCollapsible' } }, + isLoading: { if: { arg: 'isCollapsible' } }, + isLoadingMessage: { if: { arg: 'isCollapsible' } }, + isDisabled: { if: { arg: 'isCollapsible' } }, + element: { if: { arg: 'isCollapsible' } }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Accordion: Story = { + args: { + children: 'This is an accordion group with a title', + background: 'none', + title: 'Nav group - accordion', + iconType: 'logoElastic', + iconSize: 'l', + titleElement: 'h3', + titleSize: 'xxs', + initialIsOpen: true, + isCollapsible: true, + }, +}; + +export const NonAccordion: StoryObj = { + args: { + children: 'This is a group with a title', + background: 'none', + title: 'Nav group - non-accordion', + iconType: 'logoElastic', + iconSize: 'l', + titleElement: 'h3', + titleSize: 'xxs', + isCollapsible: false, + }, +}; + +export const NoTitle: Story = { + args: { + children: 'This is a group without a title', + background: 'none', + }, +}; diff --git a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.styles.ts b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.styles.ts new file mode 100644 index 00000000000..b7de2749a0f --- /dev/null +++ b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.styles.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { css } from '@emotion/react'; +import { UseEuiTheme, shade } from '../../../services'; +import { logicalCSS } from '../../../global_styling'; + +export const euiCollapsibleNavGroupStyles = ({ + euiTheme, + colorMode, +}: UseEuiTheme) => { + return { + euiCollapsibleNavGroup: css` + &:not(:first-child) { + ${logicalCSS('border-top', euiTheme.border.thin)} + } + `, + // Background colors + none: css``, + light: css` + background-color: ${euiTheme.colors.body}; + `, + dark: css` + background-color: ${colorMode === 'DARK' + ? shade(euiTheme.colors.lightestShade, 0.5) + : shade(euiTheme.colors.darkestShade, 0.2)}; + + .euiCollapsibleNavGroup__title, + .euiCollapsibleNavGroup__heading, + .euiAccordion__iconButton { + color: ${euiTheme.colors.ghost}; + } + `, + // Header padding + isCollapsible: css` + /* This class does not accept a custom className */ + .euiAccordion__triggerWrapper { + padding: ${euiTheme.size.base}; + } + `, + notCollapsible: css` + /* If the heading is not in an accordion, it needs the padding */ + .euiCollapsibleNavGroup__heading { + padding: ${euiTheme.size.base}; + } + `, + // Children padding + childrenWrapper: { + euiCollapsibleNavGroup__children: css` + padding: ${euiTheme.size.s}; + `, + withHeading: css` + ${logicalCSS('padding-top', 0)} + `, + }, + }; +}; diff --git a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.test.tsx b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.test.tsx index 39a89e9dec8..b7b5cb813d4 100644 --- a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.test.tsx +++ b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { render } from 'enzyme'; +import { render } from '../../../test/rtl'; import { requiredProps } from '../../../test/required_props'; import { shouldRenderCustomStyles } from '../../../test/internal'; @@ -20,32 +20,32 @@ describe('EuiCollapsibleNavGroup', () => { ); test('is rendered', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); describe('props', () => { test('title is rendered', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); test('iconType is rendered', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); test('iconSize is rendered', () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); test('iconProps renders data-test-subj', () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); describe('background', () => { BACKGROUNDS.forEach((color) => { test(`${color} is rendered`, () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); }); test('titleElement can change the rendered element to h2', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); test('titleSize can be larger', () => { - const component = render( + const { container } = render( ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); describe('when isCollapsible is true', () => { test('will render an accordion', () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); test('accepts accordion props', () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); @@ -147,7 +147,7 @@ describe('EuiCollapsibleNavGroup', () => { }); test('if iconType is passed without a title', () => { - const component = render( + const { container } = render( ); @@ -155,7 +155,7 @@ describe('EuiCollapsibleNavGroup', () => { expect(consoleStub.mock.calls[0][0]).toMatch( 'not render an icon without `title`' ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); }); diff --git a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx index 8849645c2cf..b65c1d44aa7 100644 --- a/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx +++ b/src/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.tsx @@ -9,22 +9,21 @@ import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react'; import classNames from 'classnames'; import { CommonProps, ExclusiveUnion } from '../../common'; -import { useGeneratedHtmlId } from '../../../services'; +import { + EuiThemeProvider, + useEuiTheme, + useGeneratedHtmlId, +} from '../../../services'; import { EuiAccordion, EuiAccordionProps } from '../../accordion'; import { EuiIcon, IconType, IconSize, EuiIconProps } from '../../icon'; import { EuiFlexGroup, EuiFlexItem } from '../../flex'; import { EuiTitle, EuiTitleProps, EuiTitleSize } from '../../title'; -type Background = 'none' | 'light' | 'dark'; -const backgroundToClassNameMap: { [color in Background]: string } = { - none: '', - light: 'euiCollapsibleNavGroup--light', - dark: 'euiCollapsibleNavGroup--dark', -}; -export const BACKGROUNDS = Object.keys( - backgroundToClassNameMap -) as Background[]; +import { euiCollapsibleNavGroupStyles } from './collapsible_nav_group.styles'; + +export const BACKGROUNDS = ['none', 'light', 'dark'] as const; +type Background = (typeof BACKGROUNDS)[number]; export interface EuiCollapsibleNavGroupInterface extends CommonProps { /** @@ -116,14 +115,15 @@ export const EuiCollapsibleNavGroup: FunctionComponent< const groupID = useGeneratedHtmlId({ conditionalId: id }); const titleID = `${groupID}__title`; - const classes = classNames( - 'euiCollapsibleNavGroup', - backgroundToClassNameMap[background], - { - 'euiCollapsibleNavGroup--withHeading': title, - }, - className - ); + const euiTheme = useEuiTheme(); + const styles = euiCollapsibleNavGroupStyles(euiTheme); + const cssStyles = [ + styles.euiCollapsibleNavGroup, + isCollapsible ? styles.isCollapsible : styles.notCollapsible, + background && styles[background], + ]; + + const classes = classNames('euiCollapsibleNavGroup', className); // Warn if consumer passes an iconType without a title if (iconType && !title) { @@ -132,8 +132,14 @@ export const EuiCollapsibleNavGroup: FunctionComponent< ); } + const childrenStyles = [ + styles.childrenWrapper.euiCollapsibleNavGroup__children, + title && styles.childrenWrapper.withHeading, + ]; const content = children && ( -
{children}
+
+ {children} +
); const headingClasses = 'euiCollapsibleNavGroup__heading'; @@ -157,27 +163,36 @@ export const EuiCollapsibleNavGroup: FunctionComponent< ) : undefined; + let render; if (isCollapsible && title) { - return ( + render = ( {content} ); } else { - return ( -
+ render = ( +
{titleContent &&
{titleContent}
} {content}
); } + + return background === 'dark' ? ( + + {render} + + ) : ( + render + ); }; diff --git a/src/components/index.scss b/src/components/index.scss index 999878192e4..2d60e75ee4c 100644 --- a/src/components/index.scss +++ b/src/components/index.scss @@ -2,7 +2,6 @@ @import 'accordion/index'; @import 'button/index'; -@import 'collapsible_nav/index'; @import 'color_picker/index'; @import 'combo_box/index'; @import 'context_menu/index'; diff --git a/upcoming_changelogs/6865.md b/upcoming_changelogs/6865.md new file mode 100644 index 00000000000..e072cc3de73 --- /dev/null +++ b/upcoming_changelogs/6865.md @@ -0,0 +1,3 @@ +**CSS-in-JS conversions** + +- Converted `EuiCollapsibleNav` and `EuiCollapsibleNavGroup` to Emotion