Skip to content

Commit

Permalink
feat: add custom logo prop to the application menu component
Browse files Browse the repository at this point in the history
  • Loading branch information
mclaberge authored and AlexisH committed Jun 3, 2021
1 parent a9a4987 commit 005ee1e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const LogoWrapper = styled(Link)`
font-weight: var(--font-bold);
height: 100%;
${focus}
> * {
height: 100%;
}
`;

interface HeadbandProps {
Expand All @@ -48,6 +51,8 @@ interface HeadbandProps {
logoHref?: string;
/** What will be displayed inside the mobile drawer */
mobileDrawerContent?: ReactNode;

customLogo?: ReactNode;
}

export function ApplicationMenu({
Expand All @@ -56,13 +61,14 @@ export function ApplicationMenu({
className,
logoHref = '/',
mobileDrawerContent,
customLogo,
}: HeadbandProps): ReactElement {
const { device, isMobile } = useDeviceContext();

return (
<Header className={className} device={device}>
<LogoWrapper to={logoHref} aria-label="Home">
<Logo name={appName} mobile={isMobile} />
{ customLogo ?? <Logo name={appName} mobile={isMobile} /> }
</LogoWrapper>

<Content mobileDrawerContent={mobileDrawerContent}>
Expand Down
5 changes: 5 additions & 0 deletions packages/storybook/asset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ declare module "*.png" {
const value: string;
export default value;
}

declare module "*.svg" {
const content: any;
export default content;
}
11 changes: 10 additions & 1 deletion packages/storybook/stories/application-menu.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ApplicationMenu } from '@equisoft/design-elements-react';
import { Story } from '@storybook/react';
import React, { ReactElement } from 'react';
import React, { ReactElement, VoidFunctionComponent } from 'react';
import { MobileDecorator } from './utils/device-context-decorator';
import { RouterDecorator } from './utils/router-decorator';
import CustomLogoSvg from './assets/customLogo.svg';

export default {
title: 'Application Menu',
Expand Down Expand Up @@ -33,6 +34,14 @@ export const WithAppName: Story = () => (
</ApplicationMenu>
);

const CustomLogo: VoidFunctionComponent = () => <img src={CustomLogoSvg} />;

export const WithCustomLogo: Story = () => (
<ApplicationMenu customLogo={<CustomLogo />}>
<p>Hello world</p>
</ApplicationMenu>
);

export const WithMobileDrawer: Story = () => (
<ApplicationMenu mobileDrawerContent={drawerContent}>
<p>Hello world</p>
Expand Down
45 changes: 45 additions & 0 deletions packages/storybook/stories/assets/customLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 005ee1e

Please sign in to comment.