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

Progress bars: center labels vertically and set height on parent .progress #22703

Merged
merged 9 commits into from
Aug 11, 2017
10 changes: 5 additions & 5 deletions docs/components/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ Add labels to your progress bars by placing text within the `.progress-bar`.

### Height

We only set a `height` value on the `.progress-bar`, so if you change that value the outer `.progress` will automatically resize accordingly.
We only set a `height` value on the `.progress`, so if you change that value the inner `.progress-bar` will automatically resize accordingly.

{% example html %}
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%; height: 1px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress" style="height: 1px;">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%; height: 20px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endexample %}

Expand Down
15 changes: 10 additions & 5 deletions scss/_progress.scss
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
// Progress animations
Copy link
Member

Choose a reason for hiding this comment

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

You can drop these newly added comments—they don't add any new context that the code itself doesn't already tell you :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh whoops, sorry. I was editing the npm package for testing in my project, and those snuck into the dist scss files.

@keyframes progress-bar-stripes {
from { background-position: $progress-height 0; }
to { background-position: 0 0; }
}

// Basic progress bar
.progress {
display: flex;
align-items: center;
height: $progress-height;
overflow: hidden; // force rounded corners by cropping it
font-size: $progress-font-size;
line-height: $progress-height;
Copy link
Member

Choose a reason for hiding this comment

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

Probably safe to remove this? Or we might need to change the value at least.

Copy link
Contributor Author

@davethegr8 davethegr8 May 26, 2017

Choose a reason for hiding this comment

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

ah, it looks like align-items is indeed safe to remove, but the height is needed (empty bars will collapse to zero with no explicit height).

Copy link
Member

Choose a reason for hiding this comment

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

Height is good to stay here, but I meant we can probably remove the line-height.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, gotcha, removing. (align-items seems to also be safe with having it on the .progress-bar)

text-align: center;
background-color: $progress-bg;
@include border-radius($progress-border-radius);
@include box-shadow($progress-box-shadow);
}

.progress-bar {
height: $progress-height;
line-height: $progress-height;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
Copy link
Member

Choose a reason for hiding this comment

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

This isn't necessary as far as I can tell. See https://jsbin.com/wahusavehu/edit?html,css,output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, I'll remove height. :)

color: $progress-bar-color;
background-color: $progress-bar-bg;
@include transition($progress-bar-transition);
Copy link
Contributor

@tmorehouse tmorehouse Nov 2, 2017

Choose a reason for hiding this comment

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

@davethegr8 @mdo
Any particular reason why the transition was removed from progress in this PR?

I see that $progress-bar-transition still exists in _variables.scss.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, probably an oversight on my part.

}

// Striped
.progress-bar-striped {
@include gradient-striped();
background-size: $progress-height $progress-height;
}

// Animated
.progress-bar-animated {
animation: progress-bar-stripes $progress-bar-animation-timing;
}