Skip to content
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
7 changes: 4 additions & 3 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<!-- Storybook default: `padding: 1rem` on `.sb-show-main.sb-main-padded` (base-preview-head.html).
- Main canvas: CFPB 15px ($space-sm).
- Nested "All viewports" (`?responsivePreview=off`): body padding 0; `#storybook-root` uses
vertical inset for focus plus small horizontal inset so outlines are not clipped at edges.
Full-bleed stories pass `sbNestedCanvasPadding=flush` (via `parameters.sbNestedCanvasPadding`
in preview.js) to use zero inset instead. -->
vertical inset for focus plus 3px horizontal inset each side (6px narrower than the iframe
width when you measure `#storybook-root` children). Full-bleed stories pass
`sbNestedCanvasPadding=flush` (via `parameters.sbNestedCanvasPadding` in preview.js) for
zero inset instead. -->
<script>
(function applyCfpbStorybookCanvasPadding() {
var style = document.createElement('style');
Expand Down
7 changes: 6 additions & 1 deletion src/components/Banner/banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@
float: left;
}

// The inner node uses both `wrapper` and `wrapper--match-content`. DS layout applies
// overlapping padding from `.wrapper` (≥ med) and `.wrapper--match-content` (≥ sm);
// scope here so the gov banner gutters stay consistent inside Header and standalone.
.wrapper--match-content {
padding-left: $space-sm;
padding-right: $space-sm;

@media (width >= 600px) {
@include respond-to-min($bp-med-min) {
padding-left: $space-md;
padding-right: $space-md;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/Header/header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ export const Default: Story = {
links: ExampleLinks,
},
};

export const Basic: Story = {
render: (properties) => <Header {...properties} />,
args: {
links: [],
},
};
6 changes: 0 additions & 6 deletions src/components/Header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@ describe('Header', () => {
'o-header bottom-border',
);
});

it('Can be rendered without bottom border', () => {
const { container } = render(<Header withBottomBorder={false} />);
expect(container.firstChild.className).toBe('o-header-scope');
expect(container.firstChild.firstChild?.className).toBe('o-header');
});
});
10 changes: 2 additions & 8 deletions src/components/Header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ import './header.scss';
export interface HeaderProperties {
links?: JSX.Element[];
href?: string;
withBottomBorder?: boolean;
}

/**
* A header helps users identify where they are and provides a quick, organized way to reach the main sections of a website.
*
*/
export const Header = ({
links,
href,
withBottomBorder = true,
}: HeaderProperties): JSX.Element => {
const headerClasses = ['o-header'];
if (withBottomBorder) headerClasses.push('bottom-border');
export const Header = ({ links, href }: HeaderProperties): JSX.Element => {
const headerClasses = ['o-header', 'bottom-border'];

return (
<div className='o-header-scope'>
Expand Down
56 changes: 29 additions & 27 deletions src/components/Header/responsive-menu.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@use '/src/assets/styles/variables.scss' as *;
@use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;

$breakpoint: 56.3125em;
$breakpoint: $bp-med-min;
$menu-width: 100%;
$animation-duration: 0.3s;
$max-width: $breakpoint - 0.0625em;
$max-width: $bp-sm-max;

.o-header-scope {
.o-header__content {
Expand Down Expand Up @@ -32,22 +33,28 @@ $max-width: $breakpoint - 0.0625em;
}

.o-header__logo {
display: inline-block;
min-width: 237px;

.o-header__logo-img {
display: block;
}

@media (max-width: $max-width) {
border-left: 1px solid var(--gray-40);
padding-left: 15px;
.o-header__logo-img {
height: 40px;
margin-top: 10px;
margin-bottom: 10px;
vertical-align: middle;
}
}
}

.o-header__logo-img {
height: 34px;
margin-top: 10px;
margin-bottom: 10px;
vertical-align: middle;
@media (max-width: $max-width) {
button.menu-toggle + .o-header__logo {
border-left: 1px solid var(--gray-40);
}
}

@media (min-width: $breakpoint) {
Expand Down Expand Up @@ -92,7 +99,7 @@ $max-width: $breakpoint - 0.0625em;
.nav-items {
@media (max-width: $max-width) {
position: absolute;
top: 54px;
top: 60px;
left: -$menu-width - 15;
width: $menu-width;
background-color: var(--white);
Expand All @@ -109,13 +116,11 @@ $max-width: $breakpoint - 0.0625em;
width: 100%;

&.open {
display: flex;
left: 0;
}

@media (min-width: $breakpoint) {
position: static;
display: flex;
flex-direction: row;
justify-content: flex-end;
width: auto;
Expand Down Expand Up @@ -155,19 +160,23 @@ $max-width: $breakpoint - 0.0625em;
padding: 0;
}

&:hover {
position: relative;
@media (max-width: $max-width) {
&:hover::before,
&.nav-item.active::before {
position: absolute;
top: 0;
left: -15px;
height: 100%;
width: 5px;
content: '';
display: block;
}
}

&:hover {
@media (max-width: $max-width) {
&::before {
position: absolute;
top: 0;
left: -15px;
height: 100%;
width: 5px;
background-color: var(--green);
content: '';
display: block;
}
color: var(--black);
}
Expand All @@ -182,14 +191,7 @@ $max-width: $breakpoint - 0.0625em;

@media (max-width: $max-width) {
&::before {
position: absolute;
top: 0;
left: -15px;
height: 100%;
width: 5px;
background-color: var(--black);
content: ' ';
display: block;
}
}

Expand Down
Loading