Skip to content
Open
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
2 changes: 1 addition & 1 deletion .storybook/themeCFPB.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { create } from 'storybook/theming/create';
import CfpbLogo from '../src/assets/images/cfpb-logo.png';
import CfpbLogo from '../src/assets/images/cfpb-header/logo-237w.png?url';

const colors = {
black: '#101820',
Expand Down
Binary file added src/assets/images/cfpb-header/logo-161w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/cfpb-header/logo-237w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/cfpb-header/logo-322w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/cfpb-header/logo-483w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/cfpb-header/logo-644w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 10 additions & 12 deletions src/components/Header/responsive-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,27 @@ $max-width: $breakpoint - 0.0625em;
align-items: center;
}

// Slot widths match logo `sizes` on consumerfinance.gov: 161px ≤900px, 237px above.
.o-header__logo {
min-width: 237px;
min-width: 161px;

@media (min-width: $breakpoint) {
min-width: 237px;
}

@media (max-width: $max-width) {
border-left: 1px solid var(--gray-40);
padding-left: 15px;
.o-header__logo-img {
height: 40px;
}
}
}

.o-header__logo-img {
height: 34px;
display: block;
height: auto;
width: auto;
max-width: 100%;
margin-top: 10px;
margin-bottom: 10px;
vertical-align: middle;
}

@media (min-width: $breakpoint) {
.o-header__logo-img {
height: 50px;
}
}

.menu-toggle {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/responsive-menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe('ResponsiveMenu', () => {
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();

expect(screen.getByTestId('CfpbLogoLink')).toBeInTheDocument();
expect(screen.getByAltText('CFPB Logo')).toBeInTheDocument();
expect(
screen.getByAltText('Consumer Financial Protection Bureau'),
).toBeInTheDocument();
});

it('renders with custom links', () => {
Expand Down
27 changes: 25 additions & 2 deletions src/components/Header/responsive-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import React, { JSX, useCallback, useState } from 'react';
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
import CFPBLogo from '../../assets/images/cfpb-logo.png';
import logo161w from '../../assets/images/cfpb-header/logo-161w.png?url';
import logo237w from '../../assets/images/cfpb-header/logo-237w.png?url';
import logo322w from '../../assets/images/cfpb-header/logo-322w.png?url';
import logo474w from '../../assets/images/cfpb-header/logo-474w.png?url';
import logo483w from '../../assets/images/cfpb-header/logo-483w.png?url';
import logo644w from '../../assets/images/cfpb-header/logo-644w.png?url';
import { Button } from '../Buttons/button';
import { Icon } from '../Icon/icon';
import Link from '../Link/link';
import type { JSXElement } from '../../types/jsx-element';
import './responsive-menu.scss';

/** Matches consumerfinance.gov header logo `srcset` (see static/img on the live site). */
const CFPB_HEADER_LOGO_SRCSET = [
`${logo161w} 161w`,
`${logo322w} 322w`,
`${logo483w} 483w`,
`${logo644w} 644w`,
`${logo237w} 237w`,
`${logo474w} 474w`,
].join(', ');

interface CfpbLogoProperties {
href?: string;
}
Expand All @@ -22,7 +37,15 @@ export function CfpbLogo({
aria-label='Home'
className='o-header__logo'
>
<img className='o-header__logo-img' src={CFPBLogo} alt='CFPB Logo' />
<img
alt='Consumer Financial Protection Bureau'
className='o-header__logo-img'
height={50}
sizes='(max-width: 900px) 161px, 237px'
src={logo237w}
srcSet={CFPB_HEADER_LOGO_SRCSET}
width={237}
/>
</Link>
);
}
Expand Down
Loading