Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logo): make logo independent of the aside state #205

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/AsideHeader/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {CompositeBar} from '../../CompositeBar/CompositeBar';
import {Logo} from '../../Logo';
import {ASIDE_HEADER_COMPACT_WIDTH, HEADER_DIVIDER_HEIGHT} from '../../constants';
import {SubheaderMenuItem} from '../../types';
import {useAsideHeaderInnerContext} from '../AsideHeaderContext';
import {useAsideHeaderContext, useAsideHeaderInnerContext} from '../AsideHeaderContext';
import {b} from '../utils';

import headerDividerCollapsedIcon from '../../../../assets/icons/divider-collapsed.svg';
Expand All @@ -16,6 +16,7 @@ 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 @@ -27,7 +28,7 @@ export const Header = () => {

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

<CompositeBar
type="subheader"
Expand Down
5 changes: 2 additions & 3 deletions src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import React from 'react';

import {Button, Icon} from '@gravity-ui/uikit';

import {useAsideHeaderContext} from '../AsideHeader/AsideHeaderContext';
import {LogoProps} from '../types';
import {block} from '../utils/cn';

import './Logo.scss';

const b = block('logo');

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

let buttonIcon;
Expand Down
Loading