import * as React from 'react'; import { Checkbox, css, ISize, fitContentToBounds, Icon } from '@fluentui/react'; import { SignalField, Signal, NewSignal, SharedSignal, MentionSignal, Tile, getTileLayout, renderTileWithLayout, } from '@fluentui/react-experiments'; import { lorem } from '@fluentui/example-data'; import * as TileExampleStylesModule from './Tile.Example.scss'; const ITEMS: { name: JSX.Element; activity: JSX.Element }[] = [ { name: <>{lorem(2)}, activity: ( <> 267 × 200 · 3.14 MB , , ]} > {lorem(6)} ), }, { name: <>{lorem(2)}, activity: ( <> 200 × 267 · 3.14 MB , , ]} > {lorem(6)} ), }, { name: <>{lorem(2)}, activity: ( <> 200 × 200 · 3.14 MB , , ]} > {lorem(6)} ), }, { name: <>{lorem(2)}, activity: ( <> 180 × 180 · 3.14 MB , , ]} > {lorem(6)} ), }, ]; const TileExampleStyles = TileExampleStylesModule as any; interface IImageTileProps { tileSize: ISize; originalImageSize: ISize; showBackground: boolean; nameplateOnlyOnHover: boolean; linkHref?: string; linkTarget?: string; item: typeof ITEMS[0]; } const ImageTile: React.FunctionComponent = (props: IImageTileProps): JSX.Element => { const tile = ( }>{props.item.name}} itemActivity={props.item.activity} background={ // Placeholder content } hideBackground={!props.showBackground} showBackgroundFrame={true} nameplateOnlyOnHover={props.nameplateOnlyOnHover} href={props.linkHref} target={props.linkTarget} /> ); const { backgroundSize } = getTileLayout(tile); const imageSize = fitContentToBounds({ contentSize: props.originalImageSize, boundsSize: backgroundSize || { width: 0, height: 0 }, mode: 'cover', }); return (
{renderTileWithLayout(tile, { background: ( ), })}
); }; export interface ITileMediaExampleState { imagesLoaded: boolean; nameplateOnlyOnHover: boolean; generateLinks: boolean; linkInNewTab: boolean; } export class TileMediaExample extends React.Component<{}, ITileMediaExampleState> { constructor(props: {}) { super(props); this.state = { imagesLoaded: true, nameplateOnlyOnHover: false, generateLinks: false, linkInNewTab: false, }; } public render(): JSX.Element { const { imagesLoaded, nameplateOnlyOnHover, generateLinks, linkInNewTab } = this.state; const exampleUrl = 'http://www.contoso.com/'; const linkHref = generateLinks ? exampleUrl : undefined; const linkTarget = generateLinks && linkInNewTab ? '_blank' : undefined; return (

Landscape

Portrait

Small Image

No preview

}>{ITEMS[3].name}} itemActivity={ITEMS[3].activity} foreground={} showBackgroundFrame={true} nameplateOnlyOnHover={this.state.nameplateOnlyOnHover} href={linkHref} target={linkTarget} />
); } private _onImagesLoadedChanged = (event: React.FormEvent, checked: boolean): void => { this.setState({ imagesLoaded: checked, }); }; private _onNameplateOnlyOnHoverChanged = (event: React.FormEvent, checked: boolean): void => { this.setState({ nameplateOnlyOnHover: checked, }); }; private _onGenerateLinksChanged = (event: React.FormEvent, checked: boolean): void => { this.setState({ generateLinks: checked, }); }; private _onLinkInNewTabChanged = (event: React.FormEvent, checked: boolean): void => { this.setState({ linkInNewTab: checked, }); }; }