Skip to content

Commit

Permalink
*fix app sidebar item adornment alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sodik committed Sep 19, 2024
1 parent 96f65ed commit db3f57b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions packages/ui/__stories__/AppSidebar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Story } from '@storybook/react'
import { Disc, HardDrive, Wifi, Activity, Droplet, Airplay } from 'react-feather'
import { Disc, AlertTriangle, HardDrive, Wifi, Activity, Droplet, Airplay } from 'react-feather'

import {
AppSidebar,
Expand All @@ -10,6 +10,7 @@ import {
AppSidebarProps,
AppSidebarFavorites,
} from '../src/AppSidebar'
import { Icon } from '../src/Icon'

export default {
title: 'App/Sidebar',
Expand All @@ -24,9 +25,10 @@ const Template: Story<Partial<AppSidebarProps>> = (props) => (
<AppSidebarItem title="Wan healthcheck replication" />
<AppSidebarItem title="Test 2" />
</AppSidebarSection>
<AppSidebarSection active={false} id="cluster" title="Cluster" ariaLabel="cluster" icon={HardDrive}>
<AppSidebarSection active id="cluster" title="Cluster" ariaLabel="cluster" icon={HardDrive}>
<AppSidebarItem id="2" title="Cluster-1" adornment={<AppSidebarMenuItemCounter>13</AppSidebarMenuItemCounter>} />
<AppSidebarItem title="Cluster-2" adornment={<AppSidebarMenuItemCounter>3</AppSidebarMenuItemCounter>} />
<AppSidebarItem title="Maps" adornment={<Icon size="small" icon={AlertTriangle} />} />
</AppSidebarSection>
<AppSidebarSection active={false} id="members" title="Memebers" ariaLabel="memebers" icon={Wifi}>
<AppSidebarItem title="Cluster-1" adornment={<AppSidebarMenuItemCounter>13</AppSidebarMenuItemCounter>} />
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/AppSidebar/AppSidebarItem/AppSidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type AppSidebarItemProps = {
onClick?: () => void
available?: boolean
adornment?: ReactNode
adornmentClassName?: string
} & DataTestProp &
({ disabled?: never; disabledTooltip?: never } | { disabled: boolean; disabledTooltip: string }) &
({ icon?: never; iconAriaLabel?: never } | { icon: FeatherIcon; iconAriaLabel: string })
Expand All @@ -38,6 +39,7 @@ export const AppSidebarItem = ({
color = 'light',
adornment,
available,
adornmentClassName,
'data-test': dataTest,
}: AppSidebarItemProps) => {
const { isOpen } = useContext(appSidebarContext)
Expand Down Expand Up @@ -65,7 +67,7 @@ export const AppSidebarItem = ({
{icon && <Icon size="medium" icon={icon} ariaLabel={iconAriaLabel} className={styles.icon} />}
{title}
{(adornment || available !== undefined) && (
<div className={styles.adornment}>
<div className={cn(styles.adornment, adornmentClassName)}>
{adornment}
{available !== undefined && <span className={cn(styles.status, { [styles.available]: available })} />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
height: c.$grid * 4;
padding: math.div(c.$grid, 2);
font-size: c.$fontSizeBodyTiny;
margin-right: c.$grid * 1.5;

&:hover {
color: #353d49;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ $sideBarMenuSectionTransitionMaxHeight: 1000px;

.toggle {
margin-bottom: c.$grid;

.adornment {
margin-right: -#{c.$grid * 1.5};
}
}

.transitionLeave {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const AppSidebarSectionExpandable = ({
onClick={handleClick}
active={active}
className={styles.toggle}
adornmentClassName={styles.adornment}
adornment={<Icon data-test="sidebar-menu-section-chevron" size="medium" containerClassName={styles.icon} {...chevronButtonProps} />}
data-test={dataTest}
/>
Expand Down

0 comments on commit db3f57b

Please sign in to comment.