@uifabric/experiments
Version:
Experimental React components for building experiences for Office 365.
95 lines • 4.85 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { Tile, getTileLayout, renderTileWithLayout } from '@uifabric/experiments/lib/Tile';
import { Checkbox } from 'office-ui-fabric-react/lib/Checkbox';
import { SignalField, NewSignal, CommentsSignal, TrendingSignal, SharedSignal } from '../../signals/Signals';
import { lorem } from '@uifabric/example-app-base';
import { css, fitContentToBounds } from '@uifabric/experiments/lib/Utilities';
import * as TileExampleStylesModule from './Tile.Example.scss';
// tslint:disable-next-line:no-any
var TileExampleStyles = TileExampleStylesModule;
var ITEMS = [
{
name: lorem(2),
activity: lorem(6)
},
{
name: lorem(2),
activity: lorem(6)
},
{
name: lorem(2),
activity: lorem(6)
},
{
name: lorem(2),
activity: lorem(6)
},
{
name: lorem(2),
activity: lorem(6)
}
];
var DocumentTileWithThumbnail = function (props) {
var tile = (React.createElement(Tile, { contentSize: {
width: 176,
height: 171
}, itemName: React.createElement(SignalField, { before: React.createElement(TrendingSignal, null) }, props.item.name), itemActivity: React.createElement(SignalField, { before: React.createElement(CommentsSignal, null, '12') }, props.item.activity), foreground: React.createElement("span", null), hideForeground: !props.showForeground, showForegroundFrame: true }));
var _a = getTileLayout(tile).foregroundSize, foregroundSize = _a === void 0 ? { width: 0, height: 0 } : _a;
var imageSize = fitContentToBounds({
contentSize: props.originalImageSize,
boundsSize: foregroundSize,
mode: 'contain'
});
return (React.createElement("div", { className: css(TileExampleStyles.tile, TileExampleStyles.largeTile) }, renderTileWithLayout(tile, {
foreground: (React.createElement("img", { src: "//placehold.it/" + Math.round(imageSize.width) + "x" + Math.round(imageSize.height), className: css(TileExampleStyles.tileImage) }))
})));
};
var TileDocumentExample = /** @class */ (function (_super) {
tslib_1.__extends(TileDocumentExample, _super);
function TileDocumentExample(props) {
var _this = _super.call(this, props) || this;
_this._onImagesLoadedChanged = function (event, checked) {
_this.setState({
imagesLoaded: checked
});
};
_this.state = {
imagesLoaded: true
};
return _this;
}
TileDocumentExample.prototype.render = function () {
var imagesLoaded = this.state.imagesLoaded;
return (React.createElement("div", null,
React.createElement(Checkbox, { label: "Show images as loaded", checked: imagesLoaded, onChange: this._onImagesLoadedChanged }),
React.createElement("h3", null, "Document thumbnail"),
React.createElement(DocumentTileWithThumbnail, { originalImageSize: {
width: 40,
height: 40
}, showForeground: imagesLoaded, item: ITEMS[0] }),
React.createElement(DocumentTileWithThumbnail, { originalImageSize: {
width: 200,
height: 150
}, showForeground: imagesLoaded, item: ITEMS[1] }),
React.createElement(DocumentTileWithThumbnail, { originalImageSize: {
width: 150,
height: 200
}, showForeground: imagesLoaded, item: ITEMS[2] }),
React.createElement(DocumentTileWithThumbnail, { originalImageSize: {
width: 16,
height: 16
}, showForeground: imagesLoaded, item: ITEMS[3] }),
React.createElement("h3", null, "Document icon"),
React.createElement("div", { className: css(TileExampleStyles.tile, TileExampleStyles.largeTile) },
React.createElement(Tile, { itemName: React.createElement(SignalField, { before: React.createElement(NewSignal, null) }, ITEMS[3].name), itemActivity: React.createElement(SignalField, { before: React.createElement(SharedSignal, null) }, ITEMS[3].activity), foreground: React.createElement("img", { src: "https://static2.sharepointonline.com/files/fabric/assets/brand-icons/document/svg/docx_48x1.svg", style: {
display: 'block',
width: '64px',
height: '64px',
margin: '16px'
} }), showForegroundFrame: true }))));
};
return TileDocumentExample;
}(React.Component));
export { TileDocumentExample };
//# sourceMappingURL=Tile.Document.Example.js.map