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

add badge code and guidance #81

Merged
merged 5 commits into from
May 31, 2019
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
33 changes: 33 additions & 0 deletions docs/_components/badges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Badges
lead: >
Badges are used to encourage user behavior throughout the site.
---

Badges can help signal to the user that they had completed a workflow desired by Login.gov. Primarily, these are used on our user account page to encourage more secure practices.

Badges are comprised with a div using the `lg-verification-badge` class and a small SVG image alongside a `span` of text.

## An unphishable badge example

The unphishable badge is used to indicate that an account is only using security keys as its MFA method.

{% capture example %}
<div class="lg-verification-badge">
Copy link
Contributor

Choose a reason for hiding this comment

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

I restructured this to be an img and span inside a div to make it easier to use the vertical-alignment controls.

Copy link
Author

Choose a reason for hiding this comment

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

ah that makes sense

<img src="{{ site.baseurl }}/assets/img/alerts/unphishable.svg" width="16" height="16" class="text-middle" alt="unphishable icon" id="unphishable_badge" />
<span>Unphishable</span>
</div>
{% endcapture %}
{% include helpers/code-example.html code=example %}

## A verified account badge example

A verfied account badge is used to indicate that an account has completed the identity verification process.

{% capture example %}
<div class="lg-verification-badge">
<img src="{{ site.baseurl }}/assets/img/alerts/success-badge.svg" width="16" height="16" class="text-middle" alt="verification icon" id="verified_account_badge" />
<span>Verified Account</span>
</div>
{% endcapture %}
{% include helpers/code-example.html code=example %}
1 change: 1 addition & 0 deletions src/img/alerts/success-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/img/alerts/unphishable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/scss/components/_verification-badge.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.lg-verification-badge {

background-color: map-get($site-palette, 'site-white');
border: units(1px) solid map-get($site-palette, 'site-green');
border-radius: $theme-border-radius-xxl;
box-sizing: border-box;
display: inline-block;
padding: units(1) units(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

USWDS has some globally available spacing units so I swapped the space variables to these. https://v2.designsystem.digital.gov/design-tokens/spacing-units/

Copy link
Author

Choose a reason for hiding this comment

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

ah nice!

white-space: nowrap;

img {
margin-right: units(1);
}

span {
vertical-align: text-top;
}
}

@media #{$theme-site-margins-breakpoint} {
.lg-verification-badge {
margin: units(-1) 0 0;
position: static;
text-align: right;
}
}
1 change: 1 addition & 0 deletions src/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
@import 'components/sidenav';
@import 'components/typography';
@import 'components/tooltips';
@import 'components/verification-badge';
1 change: 1 addition & 0 deletions src/scss/uswds-theme/_color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $site-palette: (
'site-dark-green': #116523,
'site-green': #18852e,
'site-light-green': #ebfcef,
'site-white': #ffffff,
);

$project-color-shortcodes: $site-palette;
Expand Down
1 change: 1 addition & 0 deletions src/scss/uswds-theme/_spacing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Border radius
$theme-border-radius-sm: 2px;
$theme-border-radius-md: 0.5;
$theme-border-radius-lg: 1;
$theme-border-radius-xxl: 24px !default;

/*
----------------------------------------
Expand Down