Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 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
8 changes: 4 additions & 4 deletions apps/fabric-website/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (argv) {
module.exports = function(argv) {
const path = require('path');
const resources = require('../../scripts/tasks/webpack-resources');
const version = require('./package.json').version;
Expand Down Expand Up @@ -36,11 +36,11 @@ module.exports = function (argv) {

externals: [
{
'react': 'React'
react: 'React'
},
{
'react-dom': 'ReactDOM'
},
}
],

resolve: {
Expand All @@ -52,4 +52,4 @@ module.exports = function (argv) {
},
isProductionArg /* only production */
);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Removing use of borderStyle prop of Shimmer subcomponents Line, Circle, Gap in favor of using mergeStyles API.",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "v-vibr@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ export class ShimmerCircleBase extends BaseComponent<IShimmerCircleProps, {}> {
}

public render(): JSX.Element {
const { height, styles, borderStyle, theme } = this.props;
const { height, styles, theme } = this.props;
this._classNames = getClassNames(styles!, {
theme: theme!,
height,
borderStyle
height
});

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { IShimmerCircleStyleProps, IShimmerCircleStyles } from './ShimmerCircle.types';
import { IStyleSet, getGlobalClassNames, HighContrastSelector } from '../../../Styling';
import { getGlobalClassNames, HighContrastSelector } from '../../../Styling';

const GlobalClassNames = {
root: 'ms-ShimmerCircle-root',
svg: 'ms-ShimmerCircle-svg'
};

export function getStyles(props: IShimmerCircleStyleProps): IShimmerCircleStyles {
const { height, borderStyle, theme } = props;
const { height, theme } = props;

const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

const styles: IStyleSet = !!borderStyle ? borderStyle : {};

return {
root: [
classNames.root,
styles,
{
width: `${height}px`,
height: `${height}px`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { IStyle, IStyleSet, ITheme } from '../../../Styling';
import { IStyle, ITheme } from '../../../Styling';
import { IRefObject, IStyleFunctionOrObject } from '../../../Utilities';

export interface IShimmerCircle {}
Expand All @@ -20,11 +20,6 @@ export interface IShimmerCircleProps extends React.AllHTMLAttributes<HTMLElement
*/
height?: number;

/**
* Used to
*/
borderStyle?: IStyleSet;

/**
* Theme provided by High-Order Component.
*/
Expand All @@ -38,7 +33,6 @@ export interface IShimmerCircleProps extends React.AllHTMLAttributes<HTMLElement

export interface IShimmerCircleStyleProps {
height?: number;
borderStyle?: IStyleSet;
theme: ITheme;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import {
IShimmerElementsGroupStyleProps,
IShimmerElementsGroupStyles
} from './ShimmerElementsGroup.types';
import { IStyleSet } from '../../../Styling';
import { IRawStyle } from '../../../Styling';
import { ShimmerElementType, ShimmerElementsDefaultHeights, IShimmerElement } from '../Shimmer.types';
import { ShimmerLine } from '../ShimmerLine/ShimmerLine';
import { IShimmerLineStyles } from '../ShimmerLine/ShimmerLine.types';
import { ShimmerGap } from '../ShimmerGap/ShimmerGap';
import { IShimmerGapStyles } from '../ShimmerGap/ShimmerGap.types';
import { ShimmerCircle } from '../ShimmerCircle/ShimmerCircle';
import { IShimmerCircleStyles } from '../ShimmerCircle/ShimmerCircle.types';

const getClassNames = classNamesFunction<IShimmerElementsGroupStyleProps, IShimmerElementsGroupStyles>();

Expand Down Expand Up @@ -49,28 +52,29 @@ export class ShimmerElementsGroupBase extends BaseComponent<IShimmerElementsGrou
const { type, ...filteredElem } = elem;
switch (elem.type) {
case ShimmerElementType.circle:
return (
<ShimmerCircle key={index} {...filteredElem} borderStyle={this._getBorderStyles(elem, rowHeight)} />
);
return <ShimmerCircle key={index} {...filteredElem} styles={this._getBorderStyles(elem, rowHeight)} />;
case ShimmerElementType.gap:
return <ShimmerGap key={index} {...filteredElem} borderStyle={this._getBorderStyles(elem, rowHeight)} />;
return <ShimmerGap key={index} {...filteredElem} styles={this._getBorderStyles(elem, rowHeight)} />;
case ShimmerElementType.line:
return <ShimmerLine key={index} {...filteredElem} borderStyle={this._getBorderStyles(elem, rowHeight)} />;
return <ShimmerLine key={index} {...filteredElem} styles={this._getBorderStyles(elem, rowHeight)} />;
}
}
)
) : (
<ShimmerLine height={ShimmerElementsDefaultHeights.line} />
<ShimmerLine height={ShimmerElementsDefaultHeights.line} styles={{ root: [{ borderWidth: '0px' }] }} />
);

return renderedElements;
};

private _getBorderStyles = (elem: IShimmerElement, rowHeight?: number): IStyleSet | undefined => {
private _getBorderStyles = (
elem: IShimmerElement,
rowHeight?: number
): IShimmerCircleStyles | IShimmerGapStyles | IShimmerLineStyles => {
const elemHeight: number | undefined = elem.height;
const dif: number = rowHeight && elemHeight ? rowHeight - elemHeight : 0;

let borderStyle: IStyleSet | undefined;
let borderStyle: IRawStyle | undefined;

if (!elem.verticalAlign || elem.verticalAlign === 'center') {
borderStyle = {
Expand All @@ -89,7 +93,9 @@ export class ShimmerElementsGroupBase extends BaseComponent<IShimmerElementsGrou
};
}

return borderStyle;
return {
root: [{ ...borderStyle }]
};
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export class ShimmerGapBase extends BaseComponent<IShimmerGapProps, {}> {
}

public render(): JSX.Element {
const { height, styles, width, borderStyle, theme } = this.props;
const { height, styles, width, theme } = this.props;

this._classNames = getClassNames(styles!, {
theme: theme!,
height,
borderStyle
height
});

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { IShimmerGapStyleProps, IShimmerGapStyles } from './ShimmerGap.types';
import { IStyleSet, getGlobalClassNames, HighContrastSelector } from '../../../Styling';
import { getGlobalClassNames, HighContrastSelector } from '../../../Styling';

const GlobalClassNames = {
root: 'ms-ShimmerGap-root'
};

export function getStyles(props: IShimmerGapStyleProps): IShimmerGapStyles {
const { height, borderStyle, theme } = props;
const { height, theme } = props;

const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

const styles: IStyleSet = !!borderStyle ? borderStyle : {};

return {
root: [
classNames.root,
styles,
{
backgroundColor: palette.white,
height: `${height}px`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { IStyle, IStyleSet, ITheme } from '../../../Styling';
import { IStyle, ITheme } from '../../../Styling';
import { IRefObject, IStyleFunctionOrObject } from '../../../Utilities';

export interface IShimmerGap {}
Expand All @@ -26,11 +26,6 @@ export interface IShimmerGapProps extends React.AllHTMLAttributes<HTMLElement> {
*/
width?: number | string;

/**
* Sets custom styling of the gap.
*/
borderStyle?: IStyleSet;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dzearing are you okay with removing this prop? It is technically a breaking change...

An alternative is just to change the type to any and add @deprecated. (Would be even nicer if we could use TS 3.0's unknown type instead for deprecation).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unless it was a blocking bug, this should be @deprecated and not removed.


/**
* Theme provided by High-Order Component.
*/
Expand All @@ -44,7 +39,6 @@ export interface IShimmerGapProps extends React.AllHTMLAttributes<HTMLElement> {

export interface IShimmerGapStyleProps {
height?: number;
borderStyle?: IStyleSet;
theme: ITheme;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export class ShimmerLineBase extends BaseComponent<IShimmerLineProps, {}> {
}

public render(): JSX.Element {
const { height, styles, width, borderStyle, theme } = this.props;
const { height, styles, width, theme } = this.props;

this._classNames = getClassNames(styles!, {
theme: theme!,
height,
borderStyle
height
});

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IShimmerLineStyleProps, IShimmerLineStyles } from './ShimmerLine.types';
import { IStyleSet, getGlobalClassNames, HighContrastSelector } from '../../../Styling';
import { IRawStyle, getGlobalClassNames, HighContrastSelector } from '../../../Styling';

const GlobalClassNames = {
root: 'ms-ShimmerLine-root',
Expand All @@ -10,22 +10,19 @@ const GlobalClassNames = {
};

export function getStyles(props: IShimmerLineStyleProps): IShimmerLineStyles {
const { height, borderStyle, theme } = props;
const { height, theme } = props;

const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

const styles: IStyleSet = !!borderStyle ? borderStyle : { borderWidth: '0px' };

const sharedCornerStyles: IStyleSet = {
const sharedCornerStyles: IRawStyle = {
position: 'absolute',
fill: palette.white
};

return {
root: [
classNames.root,
styles,
{
height: `${height}px`,
boxSizing: 'content-box',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { IStyle, IStyleSet, ITheme } from '../../../Styling';
import { IStyle, ITheme } from '../../../Styling';
import { IRefObject, IStyleFunctionOrObject } from '../../../Utilities';

export interface IShimmerLine {}
Expand All @@ -26,11 +26,6 @@ export interface IShimmerLineProps extends React.AllHTMLAttributes<HTMLElement>
*/
width?: number | string;

/**
* Sets custom styling of the rectangle.
*/
borderStyle?: IStyleSet;

/**
* Theme provided by High-Order Component.
*/
Expand All @@ -44,7 +39,6 @@ export interface IShimmerLineProps extends React.AllHTMLAttributes<HTMLElement>

export interface IShimmerLineStyleProps {
height?: number;
borderStyle?: IStyleSet;
theme: ITheme;
}

Expand Down