diff --git a/README.md b/README.md index e3b74b0d..c56533c2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ npm install --dev @gravity-ui/uikit@^3.0.2 @bem-react/classname@1.6.0 react@^16. - PageLayout - PageLayoutAside - AsideFallback +- Logo +- MobileLogo ## Optimization diff --git a/src/components/AsideHeader/components/Header.tsx b/src/components/AsideHeader/components/Header.tsx index c7431c11..787aadb0 100644 --- a/src/components/AsideHeader/components/Header.tsx +++ b/src/components/AsideHeader/components/Header.tsx @@ -3,7 +3,7 @@ import React, {useCallback} from 'react'; import {Icon} from '@gravity-ui/uikit'; import {CompositeBar} from '../../CompositeBar/CompositeBar'; -import {Logo} from '../../Logo/Logo'; +import {Logo} from '../../Logo'; import {ASIDE_HEADER_COMPACT_WIDTH, HEADER_DIVIDER_HEIGHT} from '../../constants'; import {SubheaderMenuItem} from '../../types'; import {useAsideHeaderInnerContext} from '../AsideHeaderContext'; diff --git a/src/components/Logo/__stories__/Logo.stories.tsx b/src/components/Logo/__stories__/Logo.stories.tsx new file mode 100644 index 00000000..a8929096 --- /dev/null +++ b/src/components/Logo/__stories__/Logo.stories.tsx @@ -0,0 +1,22 @@ +import React from 'react'; + +import type {Meta, StoryFn} from '@storybook/react'; + +import {Logo} from '..'; +import type {LogoProps} from '../../types'; + +import logoIcon from '../../../../.storybook/assets/logo.svg'; + +export default { + title: 'components/Logo', + component: Logo, + args: { + text: 'Service', + icon: logoIcon, + href: '#', + onClick: () => alert('click on logo'), + }, +} as Meta; + +const ShowcaseTemplate: StoryFn = (args) => ; +export const Showcase = ShowcaseTemplate.bind({}); diff --git a/src/components/Logo/index.ts b/src/components/Logo/index.ts new file mode 100644 index 00000000..d97c6951 --- /dev/null +++ b/src/components/Logo/index.ts @@ -0,0 +1 @@ +export * from './Logo'; diff --git a/src/components/MobileHeader/MobileHeader.tsx b/src/components/MobileHeader/MobileHeader.tsx index 31c26e04..85025d50 100644 --- a/src/components/MobileHeader/MobileHeader.tsx +++ b/src/components/MobileHeader/MobileHeader.tsx @@ -3,12 +3,12 @@ import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {useForwardRef} from '../../hooks/useForwardRef'; import {Content, RenderContentType} from '../Content'; import {Drawer, DrawerItem, DrawerItemProps} from '../Drawer/Drawer'; +import {MobileLogo} from '../MobileLogo'; import {LogoProps} from '../types'; import {block} from '../utils/cn'; import {Burger} from './Burger/Burger'; import {BurgerMenu, BurgerMenuInnerProps} from './BurgerMenu/BurgerMenu'; -import {Logo} from './Logo/Logo'; import { BURGER_PANEL_ITEM_ID, EVENT_NAMES, @@ -212,7 +212,7 @@ export const MobileHeader = React.forwardRef( closeTitle={burgerCloseTitle} openTitle={burgerOpenTitle} /> - +
{sideItemRenderContent?.({size})}
diff --git a/src/components/MobileHeader/Logo/Logo.scss b/src/components/MobileLogo/MobileLogo.scss similarity index 81% rename from src/components/MobileHeader/Logo/Logo.scss rename to src/components/MobileLogo/MobileLogo.scss index 27618562..25727158 100644 --- a/src/components/MobileHeader/Logo/Logo.scss +++ b/src/components/MobileLogo/MobileLogo.scss @@ -1,8 +1,8 @@ -@use '../../variables'; +@use '../variables'; -@import '../../../../styles/mixins'; +@import '../../../styles/mixins'; -$block: '.#{variables.$ns}mobile-header-logo'; +$block: '.#{variables.$ns}mobile-logo'; #{$block} { display: flex; diff --git a/src/components/MobileHeader/Logo/Logo.tsx b/src/components/MobileLogo/MobileLogo.tsx similarity index 86% rename from src/components/MobileHeader/Logo/Logo.tsx rename to src/components/MobileLogo/MobileLogo.tsx index b2aac596..7bab9ef4 100644 --- a/src/components/MobileHeader/Logo/Logo.tsx +++ b/src/components/MobileLogo/MobileLogo.tsx @@ -2,18 +2,18 @@ import React from 'react'; import {Icon} from '@gravity-ui/uikit'; -import {LogoProps} from '../../types'; -import {block} from '../../utils/cn'; +import {LogoProps} from '../types'; +import {block} from '../utils/cn'; -import './Logo.scss'; +import './MobileLogo.scss'; -const b = block('mobile-header-logo'); +const b = block('mobile-logo'); -interface LogoInnerProps extends LogoProps { +export interface MobileLogoProps extends LogoProps { compact: boolean; } -export const Logo: React.FC = ({ +export const MobileLogo: React.FC = ({ text, compact, icon, diff --git a/src/components/MobileLogo/__stories__/MobileLogo.stories.tsx b/src/components/MobileLogo/__stories__/MobileLogo.stories.tsx new file mode 100644 index 00000000..bdcb057f --- /dev/null +++ b/src/components/MobileLogo/__stories__/MobileLogo.stories.tsx @@ -0,0 +1,22 @@ +import React from 'react'; + +import type {Meta, StoryFn} from '@storybook/react'; + +import {MobileLogo} from '..'; +import type {MobileLogoProps} from '..'; + +import logoIcon from '../../../../.storybook/assets/logo.svg'; + +export default { + title: 'components/MobileLogo', + component: MobileLogo, + args: { + text: 'Service', + icon: logoIcon, + href: '#', + onClick: () => alert('click on logo'), + }, +} as Meta; + +const ShowcaseTemplate: StoryFn = (args) => ; +export const Showcase = ShowcaseTemplate.bind({}); diff --git a/src/components/MobileLogo/index.ts b/src/components/MobileLogo/index.ts new file mode 100644 index 00000000..73d711f7 --- /dev/null +++ b/src/components/MobileLogo/index.ts @@ -0,0 +1 @@ +export * from './MobileLogo'; diff --git a/src/components/index.ts b/src/components/index.ts index db57f1b8..f02c9fe8 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -11,4 +11,6 @@ export * from './Title'; export * from './HotkeysPanel'; export * from './Settings'; export * from './MobileHeader'; +export * from './Logo'; +export * from './MobileLogo'; export * from './types';