Skip to content

Commit

Permalink
Replace hero grid layout with CSS grid-based layout
Browse files Browse the repository at this point in the history
  • Loading branch information
contolini committed Nov 1, 2021
1 parent b0e984d commit 1c67936
Showing 1 changed file with 22 additions and 60 deletions.
82 changes: 22 additions & 60 deletions packages/cfpb-layout/src/molecules/heroes.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@
background-color: @gray-5;

&_wrapper {
padding-top: unit( @grid_gutter-width / @base-font-size-px, em );
padding-bottom: unit( @grid_gutter-width / @base-font-size-px, em );
// Manually enable CSS grid for IE. IE's grid implementation differs
// slightly from the spec so we manually enable it per component
// instead of using autoprefixer to enable it for the entire site.
display: -ms-grid;
display: grid;
max-width: ( @grid_wrapper-width - @grid_gutter-width );
margin: 0 auto;
padding-top: @grid_gutter-width;
padding-bottom: @grid_gutter-width;

.respond-to-min( @bp-sm-min, {
// IE specific fix.
display: table;

@supports( display: flex ) {
display: flex;
}
-ms-grid-columns: 7fr 5fr;
grid-template-columns: 7fr 5fr;
padding-right: ( @grid_gutter-width / 2);
padding-left: ( @grid_gutter-width / 2);

min-height: @hero-desktop-height - ( @grid_gutter-width * 2 );
} );
Expand All @@ -30,11 +35,10 @@
}

&_text {
.grid_column( 1, 1 );
padding-right: ( @grid_gutter-width / 2 );
padding-left: ( @grid_gutter-width / 2 );

.respond-to-min( @bp-sm-min, {
.grid_column( 7, 12 );

// IE specific fix
display: table-cell;
vertical-align: middle;
Expand Down Expand Up @@ -66,12 +70,12 @@
}

&_image-wrapper {
.grid_column( 1, 1 );

box-sizing: border-box;
overflow: hidden;

.respond-to-min( @bp-sm-min, {
.grid_column( 5, 12 );
padding-right: ( @grid_gutter-width / 2 );
padding-left: ( @grid_gutter-width / 2 );

// IE specific fix.
display: table-cell;
Expand All @@ -89,8 +93,6 @@
}

&_image {
.u-flexible-container-mixin( 16, 9 );

background-position: center;
background-repeat: no-repeat;
background-size: contain;
Expand All @@ -104,17 +106,13 @@
&__bleeding {
.respond-to-min( @bp-sm-min, {

.m-hero_wrapper {
position: relative;
}

.m-hero_image-wrapper {
width: 100%;
margin-top: unit( @grid_gutter-width / @base-font-size-px, em ) * -1;
margin-bottom: unit( @grid_gutter-width / @base-font-size-px, em ) * -1;

// IE specific fix.
position: absolute;
height: 100%;

@supports ( display: flex ) {
position: relative;
Expand All @@ -127,7 +125,6 @@
padding-bottom: 0 !important;
height: 100%;
width: 100%;
position: absolute;
background-size: cover;
}
} );
Expand All @@ -153,14 +150,6 @@
// Overwrite the image that is set in the markup because
// we are showing the image container below instead.
background-image: none !important;

// Remove wrapper bottom padding.
padding-bottom: 0;
}

.m-hero_image-wrapper {
position: relative;
border-width: 0;
}
} );

Expand All @@ -176,18 +165,6 @@

.u-jumbo-text();

.respond-to-max( @bp-xs-max, {
.m-hero_wrapper {
// Remove wrapper bottom padding.
padding-bottom: 0;
}

.m-hero_image-wrapper {
border-width: 0;
position: relative;
}
} );

.respond-to-min( @bp-sm-min, {
.m-hero_wrapper {
background-position: 50%;
Expand All @@ -206,20 +183,11 @@

.u-jumbo-text();

.respond-to-max( @bp-xs-max, {
.m-hero_wrapper {
// Remove wrapper bottom padding.
padding-bottom: 0;
}

.m-hero_image-wrapper {
position: relative;
border-width: 0;
}
} );

.respond-to-min( @bp-sm-min, {
.m-hero_wrapper {
-ms-grid-columns: 1fr 1fr;
grid-template-columns: 1fr 1fr;

border: 1px solid @gray-40;
border-top: none;
// Position the hero image all the way to the right
Expand All @@ -231,12 +199,6 @@
.m-hero_image {
display: none;
}

// Set the hero's text and image to 50%
.m-hero_text,
.m-hero_image-wrapper {
.grid_column( 6, 12 );
}
} );

.respond-to-min( @bp-lg-min, {
Expand Down

0 comments on commit 1c67936

Please sign in to comment.