diff --git a/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_Default.png b/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_Default.png index e8120df7..5ac67f85 100644 Binary files a/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_Default.png and b/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_Default.png differ diff --git a/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_With_Scroll.png b/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_With_Scroll.png index 4b722c95..db3e3e06 100644 Binary files a/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_With_Scroll.png and b/packages/ui/.loki/reference/chrome_minimal_App_Sidebar_With_Scroll.png differ diff --git a/packages/ui/__tests__/AppSidebar/AppSidebarFavorites.test.tsx b/packages/ui/__tests__/AppSidebar/AppSidebarFavorites.test.tsx new file mode 100644 index 00000000..18240cc0 --- /dev/null +++ b/packages/ui/__tests__/AppSidebar/AppSidebarFavorites.test.tsx @@ -0,0 +1,12 @@ +import React from 'react' +import { render, screen } from '@testing-library/react' + +import { AppSidebarFavorites } from '../../src/AppSidebar' + +describe('AppSidebarFavorites', () => { + it('shows no favorites if empty', () => { + render({() => null}) + + expect(screen.getByTestId('sidebar-menu-no-favorites')).toBeInTheDocument() + }) +}) diff --git a/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.module.scss b/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.module.scss index 789f1fca..c018472b 100644 --- a/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.module.scss +++ b/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.module.scss @@ -40,7 +40,10 @@ } } - &:hover { + &:hover, + &:active { + color: inherit; + .favorite { display: block; } diff --git a/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.tsx b/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.tsx index 37f705b8..05d15676 100644 --- a/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.tsx +++ b/packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.tsx @@ -1,6 +1,7 @@ import React, { ReactElement, ReactNode, useContext } from 'react' import cn from 'classnames' import { Icon as FeatherIcon } from 'react-feather' +import { DataTestProp } from '@hazelcast/helpers' import { Icon } from '../../Icon' import { Tooltip } from '../../Tooltip' @@ -10,7 +11,6 @@ import { AppSidebarFavoriteButton } from '../AppSidebarFavoriteButton' import { appSidebarSectionContext } from '../AppSidebarSection/appSidebarSectionContext' import styles from './AppSidebarItem.module.scss' -import { DataTestProp } from '@hazelcast/helpers' const Component = ({ children }: { children: ReactNode }) => <>{children} @@ -60,6 +60,7 @@ export const AppSidebarItem = ({ disabled={disabled as boolean} disabledTooltip={disabledTooltip} bodyClassName={styles.content} + data-test="sidebar-menu-item-title" className={cn(styles.button, { [styles.active]: active }, className)} > <> diff --git a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.module.scss b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.module.scss index 9619f055..bd46a50c 100644 --- a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.module.scss +++ b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.module.scss @@ -30,7 +30,6 @@ $sideBarMenuSectionTransitionMaxHeight: 1000px; display: flex; flex-direction: column; gap: c.$grid; - padding: 0 c.$grid 0 0; } .icon { diff --git a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.tsx b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.tsx index 4cf427ed..a7e9ad97 100644 --- a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.tsx +++ b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSection.tsx @@ -1,5 +1,6 @@ import React, { ReactNode, useContext } from 'react' import cn from 'classnames' +import { DataTestProp } from '@hazelcast/helpers' import { appSidebarContext } from '../appSidebarContext' import { AppSidebarSectionExpandable, AppSidebarSectionExpandableProps } from './AppSidebarSectionExpandable' @@ -9,21 +10,22 @@ import styles from './AppSidebarSection.module.scss' export type AppSidebarSectionProps = { title: string children: ReactNode -} & ({ id?: never; active?: never; icon?: never; ariaLabel?: never } | AppSidebarSectionExpandableProps) +} & DataTestProp & + ({ id?: never; active?: never; icon?: never; ariaLabel?: never } | AppSidebarSectionExpandableProps) -export const AppSidebarSection = ({ id, icon, active, title, children, ariaLabel }: AppSidebarSectionProps) => { +export const AppSidebarSection = ({ id, icon, active, title, children, ariaLabel, 'data-test': dataTest }: AppSidebarSectionProps) => { const { isOpen } = useContext(appSidebarContext) if (id) { return ( - + {children} ) } return ( -
+

{title}

{children}
diff --git a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSectionExpandable.tsx b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSectionExpandable.tsx index f65df89f..fda9cc3f 100644 --- a/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSectionExpandable.tsx +++ b/packages/ui/src/AppSidebar/AppSidebarSection/AppSidebarSectionExpandable.tsx @@ -2,6 +2,7 @@ import React, { ReactNode, useContext, useEffect } from 'react' import cn from 'classnames' import { ChevronDown, ChevronUp, Icon as FeatherIcon } from 'react-feather' import createPersistedState from 'use-persisted-state' +import { DataTestProp } from '@hazelcast/helpers' import { useRefValue } from '../../hooks' import { Icon, IconProps } from '../../Icon' @@ -11,18 +12,26 @@ import { appSidebarSectionContext } from './appSidebarSectionContext' import styles from './AppSidebarSection.module.scss' -export interface AppSidebarSectionExpandableProps { +export type AppSidebarSectionExpandableProps = { id: string title: string active: boolean icon: FeatherIcon ariaLabel: string children: ReactNode -} +} & DataTestProp const kebabCase = (str: string) => str.toLowerCase().split(' ').join('-') -export const AppSidebarSectionExpandable = ({ id, active, icon, title, ariaLabel, children }: AppSidebarSectionExpandableProps) => { +export const AppSidebarSectionExpandable = ({ + id, + active, + icon, + title, + ariaLabel, + children, + 'data-test': dataTest = 'sidebar-menu-section-title', +}: AppSidebarSectionExpandableProps) => { const { isOpen, open: openSidebar } = useContext(appSidebarContext) const usePersistedMenuStorageState = createPersistedState(`isOpen::${title}`) @@ -63,7 +72,7 @@ export const AppSidebarSectionExpandable = ({ id, active, icon, title, ariaLabel active={active} className={styles.toggle} adornment={} - data-test="sidebar-menu-section-title" + data-test={dataTest} /> {/* detect whether an item is in an expandable section or not. */}