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 Diffstat component #950

Merged
merged 7 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
23 changes: 23 additions & 0 deletions docs/content/components/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,26 @@ Counters can also be used in `Box` headers to indicate the number of items in a
</ul>
</div>
```

## Diffstat

Diffstats show how many deletions or additions a diff has. It's typically a row of 5 blocks that get colored with green or red.

```html live
<span class="diffstat tooltipped tooltipped-e" aria-label="6 changes: 3 additions &amp; 3 deletions">
6
<span class="diffstat-block-added"></span><span class="diffstat-block-added"></span><span class="diffstat-block-deleted"></span><span class="diffstat-block-deleted"></span><span class="diffstat-block-neutral"></span>
</span>
```

Use the `text-green` and `text-red` utilities to add addtitional information about the size of the diff.

```html live
<span class="diffstat">
<span class="text-green">+7</span>
<span class="text-red">−2</span>
<span class="tooltipped tooltipped-e" aria-label="9 lines changed">
<span class="diffstat-block-added"></span><span class="diffstat-block-added"></span><span class="diffstat-block-added"></span><span class="diffstat-block-deleted"></span><span class="diffstat-block-neutral"></span>
</span>
</span>
```
32 changes: 32 additions & 0 deletions src/labels/diffstat.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// diffstat
//
// Green/red blocks showing additions and deletions

.diffstat {
font-size: $h6-size;
font-weight: $font-weight-bold;
color: $text-gray;
white-space: nowrap;
cursor: default;
}

.diffstat-block-deleted,
.diffstat-block-added,
.diffstat-block-neutral {
display: inline-block;
width: $spacer-2;
height: $spacer-2;
margin-left: 1px;
}

.diffstat-block-deleted {
background-color: $red-600;
}

.diffstat-block-added {
background-color: darken($green-400, 5%);
simurai marked this conversation as resolved.
Show resolved Hide resolved
}

.diffstat-block-neutral {
background-color: $gray-300;
}
1 change: 1 addition & 0 deletions src/labels/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import "./labels.scss";
@import "./states.scss";
@import "./counters.scss";
@import "./diffstat.scss";