Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/merge-styles",
"comment": "Add `animation` to `IRawStyleBase` for use in style sets.",
"type": "minor"
}
],
"packageName": "@uifabric/merge-styles",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Complete ProgressIndicator conversion to mergeStyles. Add `barHeight` to enable changing height of progress bar.",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "[email protected]"
}
8 changes: 8 additions & 0 deletions packages/merge-styles/src/IRawStyleBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ export interface IRawStyleBase extends IRawFontStyle {
*/
alignmentBaseline?: ICSSRule | string;

/**
* The animation CSS property is a shorthand property for the various animation properties:
* `animation-name`, `animation-duration`, `animation-timing-function`, `animation-delay`,
* `animation-iteration-count`, `animation-direction`, `animation-fill-mode`, and
* `animation-play-state`.
*/
animation?: ICSSRule | string;

/**
* Defines a length of time to elapse before an animation starts, allowing an animation to begin execution some time after it is applied.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import * as React from 'react';
import {
BaseComponent,
css
classNamesFunction,
customizable,
} from '../../Utilities';
import { IProgressIndicatorProps } from './ProgressIndicator.types';
import * as stylesImport from './ProgressIndicator.scss';
const styles: any = stylesImport;
import {
IProgressIndicatorProps,
IProgressIndicatorStyleProps,
IProgressIndicatorStyles,
} from './ProgressIndicator.types';

const getClassNames = classNamesFunction<IProgressIndicatorStyleProps, IProgressIndicatorStyles>();

// if the percentComplete is near 0, don't animate it.
// This prevents animations on reset to 0 scenarios
const ZERO_THRESHOLD = 0.01;

/**
* ProgressIndicator with no default styles.
* [Use the `getStyles` API to add your own styles.](https://github.com/OfficeDev/office-ui-fabric-react/wiki/Styling)
*/
@customizable('ProgressIndicator', ['theme'])
export class ProgressIndicatorBase extends BaseComponent<IProgressIndicatorProps, {}> {
public static defaultProps = {
label: '',
Expand All @@ -24,13 +34,28 @@ export class ProgressIndicatorBase extends BaseComponent<IProgressIndicatorProps
this._warnDeprecations({
title: 'label'
});

}

public render() {
const { title, description, className, ariaValueText } = this.props;
const {
ariaValueText,
barHeight,
className,
description,
getStyles,
theme,
title,
} = this.props;

let { label, percentComplete } = this.props;

const classNames = getClassNames(getStyles, {
theme: theme!,
className,
barHeight,
indeterminate: percentComplete === undefined ? true : false,
});

// Handle deprecated value.
if (title) {
label = title;
Expand All @@ -40,27 +65,27 @@ export class ProgressIndicatorBase extends BaseComponent<IProgressIndicatorProps
percentComplete = Math.min(100, Math.max(0, percentComplete! * 100));
}

const progressBarStyles = {
width: percentComplete !== undefined ? percentComplete + '%' : undefined,
transition: (percentComplete !== undefined && percentComplete < ZERO_THRESHOLD) ? 'none' : undefined,
};

return (
<div className={ css('ms-ProgressIndicator', styles.root, className) }>
<div className={ css('ms-ProgressIndicator-itemName', styles.itemName) }>{ label }</div>
<div className={ css('ms-ProgressIndicator-itemProgress', styles.itemProgress) }>
<div className={ css('ms-ProgressIndicator-progressTrack', styles.progressTrack) } />
<div className={ classNames.root }>
<div className={ classNames.itemName }>{ label }</div>
<div className={ classNames.itemProgress }>
<div className={ classNames.progressTrack } />
<div
className={ css(
'ms-ProgressIndicator-progressBar',
styles.progressBar,
percentComplete && percentComplete > ZERO_THRESHOLD && 'smoothTransition',
percentComplete === undefined && styles.indeterminate
) }
style={ percentComplete !== undefined ? { width: percentComplete + '%' } : undefined }
className={ classNames.progressBar }
style={ progressBarStyles }
role='progressbar'
aria-valuemin={ 0 }
aria-valuemax={ 100 }
aria-valuenow={ percentComplete }
aria-valuenow={ Math.floor(percentComplete!) }
aria-valuetext={ ariaValueText }
/>
</div>
<div className={ css('ms-ProgressIndicator-itemDescription', styles.itemDescription) }>{ description }</div>
<div className={ classNames.itemDescription }>{ description }</div>
</div>
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,40 +1,131 @@
import { IProgressIndicatorStyleProps, IProgressIndicatorStyles } from './ProgressIndicator.types';
import {
FontSizes,
FontWeights,
HighContrastSelector,
keyframes,
noWrap,
} from '../../Styling';
import { getRTL } from '../../Utilities';
import {
IProgressIndicatorStyleProps,
IProgressIndicatorStyles,
} from './ProgressIndicator.types';

const IndeterminateProgress = keyframes({
'0%': {
left: '-30%',
},
'100%': {
left: '100%',
}
});
const IndeterminateProgressRTL = keyframes({
'100%': {
right: '-30%',
},
'0%': {
right: '100%',
}
});

export const getStyles = (
props: IProgressIndicatorStyleProps
): IProgressIndicatorStyles => {
const { className } = props;
const isRTL = getRTL();
const {
className,
indeterminate,
theme,
barHeight = 2,
} = props;

const { palette, semanticColors } = theme;

const marginBetweenText = 8;
const textHeight = 18;

return ({
root: [
'ms-ProgressIndicator',
{},
{
fontWeight: FontWeights.regular,
},
className
],

itemName: [
'ms-ProgressIndicator-itemName',
{}
noWrap,
{
color: semanticColors.bodyText,
fontSize: FontSizes.medium,
paddingTop: marginBetweenText / 2,
lineHeight: textHeight + 2,
}
],

itemDescription: [
'ms-ProgressIndicator-itemDescription',
{}
{
color: semanticColors.bodySubtext,
fontSize: FontSizes.xSmall,
lineHeight: textHeight,
}
],

itemProgress: [
'ms-ProgressIndicator-itemProgress',
{}
{
position: 'relative',
overflow: 'hidden',
height: barHeight,
padding: `${marginBetweenText}px 0`,
}
],

progressTrack: [
'ms-ProgressIndicator-progressTrack',
{}
{
position: 'absolute',
width: '100%',
height: barHeight,
backgroundColor: palette.neutralLight,

selectors: {
[HighContrastSelector]: {
borderBottom: '1px solid WindowText',
}
}
}
],

progressBar: [
'ms-ProgressIndicator-progressBar',
{},
{
backgroundColor: palette.themePrimary,
height: barHeight,
position: 'absolute',
transition: 'width .3s ease',
width: 0,

selectors: {
[HighContrastSelector]: {
backgroundColor: 'WindowText',
}
}
},
!indeterminate && {
transition: 'width .15s linear'
},
indeterminate && [
{
position: 'absolute',
minWidth: '33%',
background: `linear-gradient(to right, transparent 0%, ${palette.themePrimary} 50%, transparent 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 may not work in RTL. I'm not sure we will flip "to right" in the linear-gradient... Test in RTL, workaround is (getRTL() ? 'left': 'right')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The gradient is symmetrical so it doesn't currently make a difference between to right or to left, but if it were to change it'd be nice to flip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does flip.
image

animation: `${IndeterminateProgress} 3s infinite`,
},
isRTL && { animation: `${IndeterminateProgressRTL} 3s infinite` },
],
],
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export interface IProgressIndicatorProps extends React.Props<ProgressIndicatorBa
* @deprecated
*/
title?: string;

/**
* Height of the ProgressIndicator
* @default 2
*/
barHeight?: number;
}

export interface IProgressIndicatorStyleProps {
Expand All @@ -67,7 +73,7 @@ export interface IProgressIndicatorStyleProps {
*/
className?: string;
indeterminate?: boolean;
smoothTransition?: boolean;
barHeight?: number;
}

export interface IProgressIndicatorStyles {
Expand Down
Loading