@uifabric/experiments
Version:
Experimental React components for building experiences for Office 365.
68 lines • 4.13 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { Shimmer, ShimmerElementsGroup, ShimmerElementType as ElemType, ShimmerElementVerticalAlign as ElemVerticalAlign } from '@uifabric/experiments/lib/Shimmer';
import { Persona, PersonaSize, PersonaPresence } from 'office-ui-fabric-react/lib/Persona';
import { Toggle } from 'office-ui-fabric-react/lib/Toggle';
import { PersonaDetails } from './ExampleHelper';
var ShimmerLoadDataExample = /** @class */ (function (_super) {
tslib_1.__extends(ShimmerLoadDataExample, _super);
function ShimmerLoadDataExample(props) {
var _this = _super.call(this, props) || this;
_this._getContentOne = function (event, checked) {
var isDataLoadedOne = _this.state.isDataLoadedOne;
_this.setState({
isDataLoadedOne: checked,
contentOne: !isDataLoadedOne ? 'Congratulations!!! You have successfully loaded the content. ' : ''
});
};
_this._getContentTwo = function (event, checked) {
var isDataLoadedTwo = _this.state.isDataLoadedTwo;
_this.setState({
isDataLoadedTwo: checked,
examplePersona: !isDataLoadedTwo ? tslib_1.__assign({}, PersonaDetails) : {}
});
};
_this._getCustomElements = function () {
return (React.createElement("div", {
// tslint:disable-next-line:jsx-ban-props
style: { display: 'flex' } },
React.createElement(ShimmerElementsGroup, { shimmerElements: [{ type: ElemType.circle, height: 40 }, { type: ElemType.gap, widthInPixel: 16, height: 40 }] }),
React.createElement(ShimmerElementsGroup, { flexWrap: true, width: '100%', shimmerElements: [
{ type: ElemType.line, widthInPercentage: 100, height: 10, verticalAlign: ElemVerticalAlign.bottom },
{ type: ElemType.line, widthInPercentage: 90, height: 8 },
{ type: ElemType.gap, widthInPercentage: 10, height: 20 }
] })));
};
_this.state = {
isDataLoadedOne: false,
isDataLoadedTwo: false,
contentOne: '',
examplePersona: {}
};
return _this;
}
ShimmerLoadDataExample.prototype.render = function () {
var _a = this.state, isDataLoadedOne = _a.isDataLoadedOne, isDataLoadedTwo = _a.isDataLoadedTwo, contentOne = _a.contentOne, examplePersona = _a.examplePersona;
return (React.createElement("div", { className: "shimmerBasicExample-container" },
React.createElement(Toggle, { checked: isDataLoadedOne, onChange: this._getContentOne, onText: "Toggle to show shimmer", offText: "Toggle to load content" }),
React.createElement(Shimmer, { isDataLoaded: isDataLoadedOne, ariaLabel: 'Loading content' },
React.createElement("div", {
// tslint:disable-next-line:jsx-ban-props
style: {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
lineHeight: '1',
minHeight: '16px' // Default height of Shimmer when no elements being provided.
} },
contentOne,
contentOne,
contentOne)),
React.createElement(Toggle, { checked: isDataLoadedTwo, onChange: this._getContentTwo, onText: "Toggle to show shimmer", offText: "Toggle to load content" }),
React.createElement(Shimmer, { customElementsGroup: this._getCustomElements(), widthInPixel: 300, isDataLoaded: isDataLoadedTwo },
React.createElement(Persona, tslib_1.__assign({}, examplePersona, { size: PersonaSize.size40, presence: PersonaPresence.away })))));
};
return ShimmerLoadDataExample;
}(React.Component));
export { ShimmerLoadDataExample };
//# sourceMappingURL=Shimmer.LoadData.Example.js.map