Skip to content

Commit

Permalink
fix(logo): make logo independent of the aside state
Browse files Browse the repository at this point in the history
  • Loading branch information
kseniyakuzina committed Mar 4, 2024
1 parent 6ff7c81 commit 33a0556
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/components/AsideHeader/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {CompositeBar} from '../../CompositeBar/CompositeBar';

import headerDividerCollapsedIcon from '../../../../assets/icons/divider-collapsed.svg';

import {useAsideHeaderInnerContext} from '../AsideHeaderContext';
import {useAsideHeaderContext, useAsideHeaderInnerContext} from '../AsideHeaderContext';
import {b} from '../utils';

const DEFAULT_SUBHEADER_ITEMS: SubheaderMenuItem[] = [];

export const Header = () => {
const {logo, onItemClick, onClosePanel, headerDecoration, subheaderItems} =
useAsideHeaderInnerContext();
const {compact} = useAsideHeaderContext();
const {onClick: onLogoClickProp} = logo;
const onLogoClick = useCallback(
(event: React.MouseEvent<HTMLElement, MouseEvent>) => {
Expand All @@ -28,7 +29,12 @@ export const Header = () => {

return (
<div className={b('header', {['with-decoration']: headerDecoration})}>
<Logo {...logo} onClick={onLogoClick} iconWrapperClassName={b('logo-icon')} />
<Logo
{...logo}
onClick={onLogoClick}
iconWrapperClassName={b('logo-icon')}
compact={compact}
/>

<CompositeBar
type="subheader"
Expand Down
6 changes: 2 additions & 4 deletions src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {block} from '../utils/cn';
import {LogoProps as BaseLogoProps} from '../types';
import {Button, Icon} from '@gravity-ui/uikit';

import {useAsideHeaderContext} from '../AsideHeader/AsideHeaderContext';

import './Logo.scss';

const b = block('logo');
Expand All @@ -13,7 +11,7 @@ type LogoProps = BaseLogoProps & {
iconWrapperClassName?: string;
};

export const Logo: React.FC<LogoProps> = ({
export const Logo: React.FC<LogoProps & {compact?: boolean}> = ({
text,
icon,
iconSrc,
Expand All @@ -24,8 +22,8 @@ export const Logo: React.FC<LogoProps> = ({
wrapper,
onClick,
iconWrapperClassName,
compact,
}) => {
const {compact} = useAsideHeaderContext();
const hasWrapper = typeof wrapper === 'function';

let buttonIcon;
Expand Down

0 comments on commit 33a0556

Please sign in to comment.