Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Banner and Notification components update #735

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/five-ties-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@microsoft/atlas-site': minor
---

Updating banner and notification components documentation and creating pattern pages for them.
5 changes: 5 additions & 0 deletions .changeset/funny-seahorses-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@microsoft/atlas-css': major
---

Updating banner and notification components.
72 changes: 58 additions & 14 deletions css/src/components/banner.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
$banner-background: $info-background !default;
$banner-padding: $spacer-5 !default;
// $banner-background: $info-background !default;
$banner-background: $secondary-background !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

$banner-padding: $spacer-3 !default;

$banner-font-size: $font-size-7 !default;
$banner-color: $info-dark !default;
$banner-font-size: $font-size-8 !default;
$banner-color: $text !default;

$banner-border-color: $border-white-high-contrast !default;
$banner-button-font-size: $font-size-9 !default;

$banner-border-color: $control-border !default;
$banner-border-width: $border-width !default;

$banner-dismiss-margin: $spacer-2 !default;

$banner-icon-inline-spacing: 0.75em !default;
$banner-icon-block-spacing: 0.2em !default;

.banner {
@extend %layout-gap;

display: grid;
position: relative;
grid-template: auto / 1fr auto;
grid-template-areas: 'banner-content dismiss';
align-items: flex-start;
outline-color: $text;
background-color: $banner-background;
color: $banner-color;
font-size: $banner-font-size;
line-height: $line-height-normal;
grid-template: auto / auto 1fr auto;
grid-template-areas: 'icon banner-content dismiss';
padding-block: $banner-padding;
word-wrap: break-word;
word-break: break-word;
border-block: $banner-border-width solid $banner-border-color;

@each $name, $color-set in $colors {
$base: nth($color-set, $color-index-base);
$dark: nth($color-set, $color-index-dark);
$background: nth($color-set, $color-index-background);

&.banner-#{$name} {
border-color: $dark;
background-color: $background;

&.is-loading::before {
border-color: transparent transparent $dark $dark;
}

.banner-icon {
color: $dark;
}
}
}

&.is-loading {
color: transparent;

Expand All @@ -50,25 +76,43 @@ $banner-dismiss-margin: $spacer-2 !default;
.banner-content {
grid-area: banner-content;

a:not(.button) {
color: currentColor;
.banner-title {
font-weight: $weight-semibold;
text-decoration: underline;
margin-inline-end: $banner-icon-inline-spacing;
}

.theme-high-contrast & {
color: $hyperlink;
}
a:not(.button) {
text-decoration: underline;

&:hover {
text-decoration-thickness: 0.15em;
}
}

.button {
font-size: $banner-button-font-size;
}

p {
max-width: $reading-max-width;
}
}

.banner-icon {
grid-area: icon;
flex-shrink: 0;
margin-inline-end: $banner-icon-inline-spacing;
}

.banner-dismiss {
@include dismiss-square;

grid-area: dismiss;
margin-inline-start: $banner-dismiss-margin;
margin-inline-start: $banner-icon-inline-spacing;
}

.banner-icon,
.banner-dismiss {
margin-block-start: $banner-icon-block-spacing;
}
}
66 changes: 34 additions & 32 deletions css/src/components/notification.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
$notification-background: $secondary-background !default;
$notification-padding: $spacer-5 !default;
$notification-padding-vertical: 0.5em !default;
Copy link
Contributor

@homing1 homing1 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there can be more vertical and horizontal padding, same for banner.

image

$notification-padding-horizontal: 0.75em !default;

$notification-font-size: $font-size-7 !default;
$notification-font-size: $font-size-8 !default;
$notification-color: $text !default;

$notification-button-font-size: $font-size-9 !default;

$notification-border-color: $control-border !default;
$notification-border-width: $border-width !default;
$notification-border-radius: $border-radius !default;

$notification-icon-inline-spacing: 0.375em !default;
$notification-icon-inline-spacing: 0.75em !default;
$notification-icon-block-spacing: 0.2em !default;

$notification-dismiss-margin: $spacer-2 !default;

.notification {
display: grid;
position: relative;
padding: $notification-padding;
grid-template: auto / 1fr auto;
grid-template-areas: 'notification-content dismiss';
align-items: flex-start;
border: $notification-border-width solid $notification-border-color;
border-radius: $notification-border-radius;
outline-color: $text;
background-color: $notification-background;
color: $notification-color;
font-size: $notification-font-size;
line-height: $line-height-normal;
padding-inline: $notification-padding-horizontal;
padding-block: $notification-padding-vertical;
grid-template: auto / auto 1fr auto;
grid-template-areas: 'icon notification-content dismiss';
word-wrap: break-word;
word-break: break-word;

Expand All @@ -37,71 +40,70 @@ $notification-dismiss-margin: $spacer-2 !default;
&.notification-#{$name} {
border-color: $dark;
background-color: $background;
color: $dark;

&.is-loading::before {
border-color: transparent transparent $dark $dark;
}

.notification-icon {
color: $dark;
}
}
}

&.is-loading {
color: transparent;

> :first-child {
margin-inline-start: calc($notification-padding + 0.375em);
margin-inline-start: calc($notification-padding-vertical + 0.375em);
}

&::before {
@include loader;

position: absolute;
inset-block-start: $notification-padding;
inset-inline-start: $notification-padding;
inset-block-start: $notification-padding-vertical;
inset-inline-start: $notification-padding-horizontal;
border-color: transparent transparent $notification-color $notification-color;
}
}

.notification-content {
grid-area: notification-content;

.notification-title,
a:not(.button) {
color: currentColor;
.notification-title {
font-weight: $weight-semibold;
margin-inline-end: $notification-icon-inline-spacing;
}

a:not(.button) {
text-decoration: underline;

.theme-high-contrast & {
color: $hyperlink;
}

&:hover {
text-decoration-thickness: 0.15em;
}
}

.notification-title {
display: flex;
align-items: center;
justify-content: flex-start;
margin-block-end: $layout-1;

.icon {
flex-shrink: 0;
align-self: start;
margin-inline-end: $notification-icon-inline-spacing;
margin-block-start: $notification-icon-block-spacing;
}
.button {
font-size: $notification-button-font-size;
}
}

.notification-icon {
grid-area: icon;
flex-shrink: 0;
margin-inline-end: $notification-icon-inline-spacing;
}

.notification-dismiss {
@include dismiss-square;

grid-area: dismiss;
margin-inline-start: $notification-dismiss-margin;
margin-inline-start: $notification-icon-inline-spacing;
}

.notification-icon,
.notification-dismiss {
margin-block-start: $notification-icon-block-spacing;
}
}
2 changes: 2 additions & 0 deletions integration/tests/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const pathnames = [
'/patterns/article-header.html',
'/patterns/chat.html',
'/patterns/thread-history.html',
'/patterns/banner.html',
'/patterns/notification.html',
'/tokens/overview.html',
'/tokens/animation.html',
'/tokens/border.html',
Expand Down
55 changes: 54 additions & 1 deletion site/src/components/banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Banner
description: The Banner component in the Atlas Design System
template: standard
figmaEmbed: https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FuVA2amRR71yJZ0GS6RI6zL%2F%25F0%259F%258C%259E-Atlas-Design-Library%3Fnode-id%3D35687%253A253899%26t%3DMgxlZCy8on3CKZ9O-1
classType: Component
classPrefixes:
- banner
Expand All @@ -26,6 +25,42 @@ Here is an example of a standard usage of banner component.
</div>
```

### Banner with title

You can add a title to the banner.

```html
<div class="banner">
<div class="banner-content">
<p>
<span class="banner-title">Descriptive title</span>
A banner about something happening in the world <a href="#">Link</a>
</p>
</div>
</div>
```

### Banner with icon

You can add an icon to the banner in front of the main content.

```html
<div class="banner">
<span class="banner-icon">
<span class="icon" aria-hidden="true">
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" class="fill-current-color">
<path
d="M8 0C8.73438 0 9.44271 0.09375 10.125 0.28125C10.8073 0.46875 11.4427 0.739583 12.0312 1.09375C12.6198 1.44792 13.1589 1.86458 13.6484 2.34375C14.138 2.82292 14.5573 3.36198 14.9062 3.96094C15.2552 4.5599 15.5234 5.19792 15.7109 5.875C15.8984 6.55208 15.9948 7.26042 16 8C16 8.73438 15.9062 9.44271 15.7188 10.125C15.5312 10.8073 15.2604 11.4427 14.9062 12.0312C14.5521 12.6198 14.1354 13.1589 13.6562 13.6484C13.1771 14.138 12.638 14.5573 12.0391 14.9062C11.4401 15.2552 10.8021 15.5234 10.125 15.7109C9.44792 15.8984 8.73958 15.9948 8 16C7.26562 16 6.55729 15.9062 5.875 15.7188C5.19271 15.5312 4.55729 15.2604 3.96875 14.9062C3.38021 14.5521 2.84115 14.1354 2.35156 13.6562C1.86198 13.1771 1.44271 12.638 1.09375 12.0391C0.744792 11.4401 0.476562 10.8021 0.289062 10.125C0.101562 9.44792 0.00520833 8.73958 0 8C0 7.26562 0.09375 6.55729 0.28125 5.875C0.46875 5.19271 0.739583 4.55729 1.09375 3.96875C1.44792 3.38021 1.86458 2.84115 2.34375 2.35156C2.82292 1.86198 3.36198 1.44271 3.96094 1.09375C4.5599 0.744792 5.19792 0.476562 5.875 0.289062C6.55208 0.101562 7.26042 0.00520833 8 0ZM9 12V10H7V12H9ZM9 9V4H7V9H9Z"
/>
</svg>
</span>
</span>
<div class="banner-content">
<p>A banner about something happening in the world <a href="#">Link</a></p>
</div>
</div>
```

### Loading banner

Ensure the user knows they need to wait for some event in order to interact with a banner.
Expand Down Expand Up @@ -64,3 +99,21 @@ Banner can be made dismissable with the [`dismiss` component](./dismiss.md).
</button>
</div>
```

## Semantic colors

| State | Class | Example |
| ------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Default | `.banner` | <div class="banner"><div class="banner-content"><p class="margin-top-none">Default banner <a href="#">Link</a></p></div></div> |
| Success | `.banner .banner-success` | <div class="banner banner-success"><div class="banner-content"><p class="margin-top-none">Success banner <a href="#">Link</a></p></div></div> |
| Danger | `.banner .banner-danger` | <div class="banner banner-danger"><div class="banner-content"><p class="margin-top-none">Danger banner <a href="#">Link</a></p></div></div> |
| Warning | `.banner .banner-warning` | <div class="banner banner-warning"><div class="banner-content"><p class="margin-top-none">Warning banner <a href="#">Link</a></p></div></div> |
| Info | `.banner .banner-info` | <div class="banner banner-info"><div class="banner-content"><p class="margin-top-none">Informational banner <a href="#">Link</a></p></div></div> |

```html-no-indent
<div class="banner banner-success">
<div class="banner-content">
<p>Success banner.</p>
</div>
</div>
```
Loading
Loading