test(progress): reproducible CI screenshot (#16704)

This commit is contained in:
Manu MA
2018-12-12 14:58:22 +01:00
committed by GitHub
parent 060794e9c8
commit c60adf8bd4
2 changed files with 26 additions and 5 deletions

View File

@ -3,6 +3,7 @@
// Progress bar // Progress bar
// -------------------------------------------------- // --------------------------------------------------
// Host has no background by default - this will be added to the progress-buffer-bar // Host has no background by default - this will be added to the progress-buffer-bar
:host { :host {
/** /**
* @prop --background: Same as --buffer-background when using a determinate progress bar, otherwise it styles the background of the ion-progress-bar itself. * @prop --background: Same as --buffer-background when using a determinate progress bar, otherwise it styles the background of the ion-progress-bar itself.
@ -32,8 +33,6 @@
background: var(--buffer-background); background: var(--buffer-background);
} }
// Set the bars to full width and height
// QUESTION: Can this be simplified?
.progress, .progress,
.progress-indeterminate, .progress-indeterminate,
.indeterminate-bar-primary, .indeterminate-bar-primary,
@ -50,6 +49,7 @@
// Determinate progress bar // Determinate progress bar
// -------------------------------------------------- // --------------------------------------------------
.progress, .progress,
.progress-buffer-bar { .progress-buffer-bar {
@include transform-origin(start, top); @include transform-origin(start, top);
@ -58,6 +58,7 @@
// Progress and background bar // Progress and background bar
// -------------------------------------------------- // --------------------------------------------------
.progress, .progress,
.progress-indeterminate { .progress-indeterminate {
background: var(--progress-background); background: var(--progress-background);
@ -66,7 +67,6 @@
} }
.progress-buffer-bar { .progress-buffer-bar {
// It's currently here because --buffer-background has an alpha // It's currently here because --buffer-background has an alpha
// Otherwise the buffer circles would be seen through // Otherwise the buffer circles would be seen through
background: #fff; background: #fff;
@ -82,12 +82,14 @@
// MD based animation on indeterminate type // MD based animation on indeterminate type
// -------------------------------------------------- // --------------------------------------------------
.indeterminate-bar-primary { .indeterminate-bar-primary {
@include position(0, 0, 0, -145.166611%); @include position(0, 0, 0, -145.166611%);
animation: primary-indeterminate-translate 2s infinite linear; animation: primary-indeterminate-translate 2s infinite linear;
.progress-indeterminate { .progress-indeterminate {
animation: primary-indeterminate-scale 2s infinite linear; animation: primary-indeterminate-scale 2s infinite linear;
animation-play-state: inherit;
} }
} }
@ -97,11 +99,13 @@
.progress-indeterminate { .progress-indeterminate {
animation: secondary-indeterminate-scale 2s infinite linear; animation: secondary-indeterminate-scale 2s infinite linear;
animation-play-state: inherit;
} }
} }
// Buffer style // Buffer style
// -------------------------------------------------- // --------------------------------------------------
.buffer-circles { .buffer-circles {
background: radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%) repeat-x 5px center; background: radial-gradient(ellipse at center, var(--buffer-background) 0%, var(--buffer-background) 30%, transparent 30%) repeat-x 5px center;
background-size: 10px 10px; background-size: 10px 10px;
@ -113,6 +117,7 @@
// If reversed is set to true, the animation will be reversed // If reversed is set to true, the animation will be reversed
// and the bars starting at the top right // and the bars starting at the top right
// -------------------------------------------------- // --------------------------------------------------
:host(.progress-bar-reversed) { :host(.progress-bar-reversed) {
.progress, .progress,
.progress-buffer-bar { .progress-buffer-bar {
@ -127,9 +132,21 @@
} }
} }
// Progress paused
// --------------------------------------------------
:host(.progress-paused) {
.indeterminate-bar-secondary,
.indeterminate-bar-primary,
.buffer-circles {
animation-play-state: paused;
}
}
// Animation Keyframes // Animation Keyframes
// -------------------------------------------------- // --------------------------------------------------
// Source: https://github.com/material-components/material-components-web/blob/master/packages/mdc-linear-progress/_keyframes.scss // Source: https://github.com/material-components/material-components-web/blob/master/packages/mdc-linear-progress/_keyframes.scss
@keyframes primary-indeterminate-translate { @keyframes primary-indeterminate-translate {
0% { 0% {
transform: translateX(0); transform: translateX(0);

View File

@ -1,6 +1,6 @@
import { Component, ComponentInterface, Prop } from '@stencil/core'; import { Component, ComponentInterface, Prop } from '@stencil/core';
import { Color, Mode } from '../../interface'; import { Color, Config, Mode } from '../../interface';
import { clamp } from '../../utils/helpers'; import { clamp } from '../../utils/helpers';
import { createColorClasses } from '../../utils/theme'; import { createColorClasses } from '../../utils/theme';
@ -14,6 +14,8 @@ import { createColorClasses } from '../../utils/theme';
}) })
export class ProgressBar implements ComponentInterface { export class ProgressBar implements ComponentInterface {
@Prop({ context: 'config' }) config!: Config;
/** /**
* The mode determines which platform styles to use. * The mode determines which platform styles to use.
*/ */
@ -52,6 +54,7 @@ export class ProgressBar implements ComponentInterface {
hostData() { hostData() {
const { color, type, reversed, value } = this; const { color, type, reversed, value } = this;
const paused = this.config.getBoolean('_testing');
return { return {
'role': 'progressbar', 'role': 'progressbar',
'aria-valuenow': type === 'determinate' ? value : null, 'aria-valuenow': type === 'determinate' ? value : null,
@ -60,6 +63,7 @@ export class ProgressBar implements ComponentInterface {
class: { class: {
...createColorClasses(color), ...createColorClasses(color),
[`progress-bar-${type}`]: true, [`progress-bar-${type}`]: true,
'progress-paused': paused,
'progress-bar-reversed': reversed, 'progress-bar-reversed': reversed,
} }
}; };