Skip to content

Commit

Permalink
feat(banner): Update content to be leading as default and add support…
Browse files Browse the repository at this point in the history
… for optional centered.

BREAKING CHANGE: Dom structure change, see README.md

PiperOrigin-RevId: 332891202
  • Loading branch information
EstebanG23 authored and Copybara-Service committed Sep 21, 2020
1 parent 4e93439 commit 8d5b84f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
20 changes: 20 additions & 0 deletions packages/mdc-banner/README.md
Expand Up @@ -71,6 +71,26 @@ const banner = new MDCBanner(document.querySelector('.mdc-banner'));

### Variants

#### Centered

By default, banners are positioned as leading.

They can optionally be displayed centered by adding the `mdc-banner--centered` modifier class to the root element:

```html
<div class="mdc-banner mdc-banner--centered">
...
</div>
```

Alternatively, you can call the `position-centered` mixin from Sass:

```scss
.my-banner {
@include banner.position-centered;
}
```

#### Banner with graphic

Images can help communicate a banner’s message.
Expand Down
16 changes: 16 additions & 0 deletions packages/mdc-banner/_banner-theme.scss
Expand Up @@ -157,3 +157,19 @@ $mobile-breakpoint: 480px;
}
}
}

///
/// Sets the banner content to centered instead of leading.
///
@mixin position-centered($query: feature-targeting.all()) {
$feat-structure: feature-targeting.create-target($query, structure);

.mdc-banner__content {
@include feature-targeting.targets($feat-structure) {
left: 0;
margin-left: auto;
margin-right: auto;
right: 0;
}
}
}
9 changes: 4 additions & 5 deletions packages/mdc-banner/_banner.scss
Expand Up @@ -71,7 +71,6 @@ $_exit-duration: 250ms;
box-sizing: border-box;
display: none;
height: 0;
justify-content: center;
position: relative;
width: 100%;
}
Expand Down Expand Up @@ -113,15 +112,15 @@ $_exit-duration: 250ms;
}
}

.mdc-banner--centered {
@include banner-theme.position-centered($query: $query);
}

.mdc-banner__content {
@include feature-targeting.targets($feat-structure) {
display: flex;
left: 0;
margin-left: auto;
margin-right: auto;
min-height: 52px;
position: absolute;
right: 0;
transform: translateY(-100%);
width: 720px;
}
Expand Down

0 comments on commit 8d5b84f

Please sign in to comment.