Skip to content

Commit

Permalink
fix(progress-bar): inner bar for percentage 0 (#1563)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturo Castillo Delgado authored Feb 2, 2023
1 parent af003f7 commit 4f9c0c4
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`ProgressBar check props 1`] = `
</div>
<div class="progress-bar__wrapper" part="wrapper">
<div aria-label="testLabel" aria-valuemax="100" aria-valuemin="0" aria-valuenow="18" aria-valuetext="18%" class="progress-bar__outer" id="progress-bar-1" part="outer" role="progressbar">
<div class="progress-bar__inner" part="inner" style="width: 18%; border: 1px solid transparent; background: var(--background); animation: showProgress 3s ease-in-out;"></div>
<div class="progress-bar__inner" part="inner" style="--progress: 18%;"></div>
</div>
<slot name="icon"></slot>
</div>
Expand Down Expand Up @@ -63,9 +63,7 @@ exports[`ProgressBar should match snapshot 1`] = `
</div>
</div>
<div class="progress-bar__wrapper" part="wrapper">
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="0" aria-valuetext="0%" class="progress-bar__outer" id="progress-bar-0" part="outer" role="progressbar">
<div class="progress-bar__inner" part="inner" style="width: 0%; border: 1px solid transparent; background: var(--background); animation: showProgress 3s ease-in-out;"></div>
</div>
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="0" aria-valuetext="0%" class="progress-bar__outer" id="progress-bar-0" part="outer" role="progressbar"></div>
<slot name="icon"></slot>
</div>
</div>
Expand Down
15 changes: 11 additions & 4 deletions packages/components/src/components/progress-bar/progress-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,29 @@
margin-left: 0;
overflow: hidden;
position: relative;
border-radius: 100px;
border-radius: var(--telekom-radius-pill);
background-color: var(--background-color);
}

.progress-bar__inner {
position: absolute;
top: 0;
left: 0;
width: var(--progress, 0);
height: var(--progress-bar-inner-size);
display: flex;
position: absolute;
align-items: center;
white-space: nowrap;
justify-content: flex-end;
animation-fill-mode: both;
border-radius: 100px;
border-radius: var(--telekom-radius-pill);
border: 1px solid transparent;
background: var(--background);
transition: width var(--telekom-motion-duration-immediate)
var(--telekom-motion-easing-standard);
}

.progress-bar--disabled .progress-bar__inner {
background: var(--background-disabled);
}

.progress-bar__status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ describe('ProgressBar', () => {
// Does not effect coverage
it('test function progressStyle()', () => {
const style = {
width: '20%',
border: '1px solid transparent',
background: 'magenta',
animation: 'showProgress 3s ease-in-out',
'--progress': '20%',
};
element.percentage = 20;
element.customColor = 'magenta';
expect(JSON.stringify(element.progressStyle())).toBe(JSON.stringify(style));
});

Expand Down
25 changes: 12 additions & 13 deletions packages/components/src/components/progress-bar/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,12 @@ export class ProgressBar {
`;

progressStyle = () => {
const customColor = this.customColor
? { '--background': this.customColor }
: {};
return {
width: this.disabled ? '100%' : `${this.percentage}%`,
border: '1px solid transparent',
background: this.customColor
? this.customColor
: this.disabled
? 'var(--background-disabled)'
: `var(--background)`,
animation: this.disabled ? 'none' : 'showProgress 3s ease-in-out',
'--progress': this.disabled ? '100%' : `${this.percentage}%`,
...customColor,
};
};

Expand Down Expand Up @@ -151,11 +148,13 @@ export class ProgressBar {
aria-label={this.label}
id={this.progressBarId}
>
<div
part="inner"
class="progress-bar__inner"
style={this.progressStyle()}
></div>
{this.percentage > 0 && (
<div
part="inner"
class="progress-bar__inner"
style={this.progressStyle()}
></div>
)}
</div>
<slot name="icon"></slot>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ export const Template = (args, { argTypes }) => ({
<div style="display: inline-flex; align-items: center;">
<span style="margin-right: 8px;">9.356</span>
<scale-progress-bar
custom-color="var(--telekom-color-ui-extra-strong)"
variant="info"
style="width: 120px;"
style="width: 120px; --background: var(--telekom-color-ui-extra-strong)"
stroke-width="6"
percentage="90"
show-status="false"
Expand All @@ -94,9 +93,8 @@ export const Template = (args, { argTypes }) => ({
<div style="display: inline-flex; align-items: center;">
<span style="margin-right: 8px;">3.356</span>
<scale-progress-bar
custom-color="var(--telekom-color-ui-extra-strong)"
variant="info"
style="width: 120px;"
style="width: 120px; --background: var(--telekom-color-ui-extra-strong)"
stroke-width="6"
percentage="30"
show-status="false"
Expand All @@ -123,9 +121,8 @@ export const Template = (args, { argTypes }) => ({
<div style="display: inline-flex; align-items: center;">
<span style="margin-right: 8px;">6.356</span>
<scale-progress-bar
custom-color="var(--telekom-color-ui-extra-strong)"
variant="info"
style="width: 120px;"
style="width: 120px; --background: var(--telekom-color-ui-extra-strong)"
stroke-width="6"
percentage="60"
show-status="false"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/visual-tests/src/brand-header.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ describe('Brand Header', () => {
const firstLink = await global.page.evaluateHandle(
`document.querySelector("#root > div > scale-app-shell").shadowRoot.querySelector("scale-app-header nav.header__nav > div > div.header__nav-menu-wrapper > div.header__nav-menu-main > ul > scale-nav-main:nth-child(1) > li > a")`
);
// TODO we probably want to make sure `hover` is not affecting the `focus` snapshot?
// https://github.com/telekom/scale/pull/1565/files#diff-900e1daba44b830c5fb035a03c58deea10a791e34e9eadb54a5ba5db7f40e48d
await firstLink.hover();
expect(await previewHtml.screenshot()).toMatchImageSnapshot();
await firstLink.focus();
Expand Down

0 comments on commit 4f9c0c4

Please sign in to comment.