Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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": "office-ui-fabric-react",
"comment": "Deprecating 'borderStyle' prop of Shimmer subcomponents Line, Circle, Gap in favor of leveraging mergeStyles API.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "v-vibr@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ export function getStyles(props: IShimmerCircleStyleProps): IShimmerCircleStyles
const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

const styles: IRawStyle = !!borderStyle ? borderStyle : {};
const borderStyles: IRawStyle = !!borderStyle ? borderStyle : {};

return {
root: [
classNames.root,
styles,
{
width: `${height}px`,
height: `${height}px`,
Expand All @@ -31,7 +30,8 @@ export function getStyles(props: IShimmerCircleStyleProps): IShimmerCircleStyles
borderColor: 'Window'
}
}
}
},
borderStyles
],
svg: [
classNames.svg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ export interface IShimmerCircleProps extends React.AllHTMLAttributes<HTMLElement
*/
height?: number;

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

/**
* Theme provided by High-Order Component.
*/
Expand All @@ -34,6 +29,12 @@ export interface IShimmerCircleProps extends React.AllHTMLAttributes<HTMLElement
* Call to provide customized styling that will layer on top of the variant rules.
*/
styles?: IStyleFunctionOrObject<IShimmerCircleStyleProps, IShimmerCircleStyles>;

/**
* Use to set custom styling of the shimmerCircle borders.
* @deprecated Use 'styles' prop to leverage mergeStyle API.
*/
borderStyle?: IRawStyle;
}

export interface IShimmerCircleStyleProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {
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,24 +52,25 @@ 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): IRawStyle | undefined => {
private _getBorderStyles = (
elem: IShimmerElement,
rowHeight?: number
): IShimmerCircleStyles | IShimmerGapStyles | IShimmerLineStyles => {
const elemHeight: number | undefined = elem.height;
const dif: number = rowHeight && elemHeight ? rowHeight - elemHeight : 0;

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 @@ -11,12 +11,11 @@ export function getStyles(props: IShimmerGapStyleProps): IShimmerGapStyles {
const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

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.

classNames [](start = 8, length = 10)

nit: rename these to globalClassNames so it is clearer e.g. in line 18


const styles: IRawStyle = !!borderStyle ? borderStyle : {};
const borderStyles: IRawStyle = !!borderStyle ? borderStyle : {};

return {
root: [
classNames.root,
styles,
{
backgroundColor: palette.white,
height: `${height}px`,
Expand All @@ -30,7 +29,8 @@ export function getStyles(props: IShimmerGapStyleProps): IShimmerGapStyles {
borderColor: 'Window'
}
}
}
},
borderStyles
]
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export interface IShimmerGapProps extends React.AllHTMLAttributes<HTMLElement> {
*/
width?: number | string;

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

/**
* Theme provided by High-Order Component.
*/
Expand All @@ -40,6 +35,12 @@ export interface IShimmerGapProps extends React.AllHTMLAttributes<HTMLElement> {
* Call to provide customized styling that will layer on top of the variant rules.
*/
styles?: IStyleFunctionOrObject<IShimmerGapStyleProps, IShimmerGapStyles>;

/**
* Use to set custom styling of the shimmerGap borders.
* @deprecated Use 'styles' prop to leverage mergeStyle API.
*/
borderStyle?: IRawStyle;
}

export interface IShimmerGapStyleProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getStyles(props: IShimmerLineStyleProps): IShimmerLineStyles {
const { palette } = theme;
const classNames = getGlobalClassNames(GlobalClassNames, theme);

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

const sharedCornerStyles: IRawStyle = {
position: 'absolute',
Expand All @@ -25,7 +25,6 @@ export function getStyles(props: IShimmerLineStyleProps): IShimmerLineStyles {
return {
root: [
classNames.root,
styles,
{
height: `${height}px`,
boxSizing: 'content-box',
Expand All @@ -43,7 +42,8 @@ export function getStyles(props: IShimmerLineStyleProps): IShimmerLineStyles {
}
}
}
}
},
borderStyles
],
topLeftCorner: [
classNames.topLeftCorner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export interface IShimmerLineProps extends React.AllHTMLAttributes<HTMLElement>
*/
width?: number | string;

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

/**
* Theme provided by High-Order Component.
*/
Expand All @@ -40,6 +35,12 @@ export interface IShimmerLineProps extends React.AllHTMLAttributes<HTMLElement>
* Call to provide customized styling that will layer on top of the variant rules.
*/
styles?: IStyleFunctionOrObject<IShimmerLineStyleProps, IShimmerLineStyles>;

/**
* Use to set custom styling of the shimmerLine borders.
* @deprecated Use 'styles' prop to leverage mergeStyle API.
*/
borderStyle?: IRawStyle;
}

export interface IShimmerLineStyleProps {
Expand Down