import * as React from 'react'; import { CollapsibleSection, ICollapsibleSectionTitleProps, ICollapsibleSectionTitleStylesReturnType, } from '@uifabric/experiments'; import { ITextProps, Label, Spinner } from 'office-ui-fabric-react'; import { ISlotRender, IHTMLSlot } from '@uifabric/foundation'; // Mock async data container component interface IAsyncDataProps { render: (data?: string) => JSX.Element; data?: string; } class AsyncData extends React.Component { constructor(props: IAsyncDataProps) { super(props); this.state = { loading: true }; } public componentDidMount() { setTimeout(() => this.setState({ loading: false }), 3000); } public render() { const { loading } = this.state; const { render, data } = this.props; return render(loading ? undefined : data); } } const titleTextStyles: ICollapsibleSectionTitleProps['styles'] = ( props, theme, ): ICollapsibleSectionTitleStylesReturnType => ({ text: [ theme.fonts.large, { fontWeight: 800, }, ], }); // TODO: use extendsComponent to create variants and clean up these examples const titleTextRender: ISlotRender = (props, DefaultComponent) => ( data ? : } /> ); const bodyRender: ISlotRender = (props, DefaultComponent) => ( (
{data ? : }
)} /> ); export class SlotsAsyncExample extends React.Component<{}, {}> { public render(): JSX.Element { return (
Data loaded
); } }