office-ui-fabric-react#Overlay TypeScript Examples
The following examples show how to use
office-ui-fabric-react#Overlay.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PeopleSearchContainer.tsx From spfx-msgraph-peoplesearch with MIT License | 4 votes |
/**
*
*
* @returns {React.ReactElement<IPeopleSearchContainerProps>}
* @memberof Directory
*/
public render(): React.ReactElement<IPeopleSearchContainerProps> {
const areResultsLoading = this.state.areResultsLoading;
const items = this.state.results[this.state.page - 1];
const hasError = this.state.hasError;
const errorMessage = this.state.errorMessage;
const { semanticColors }: IReadonlyTheme = this.props.themeVariant;
let renderWebPartTitle: JSX.Element = null;
let renderWebPartContent: JSX.Element = null;
let renderOverlay: JSX.Element = null;
let renderShimmerElements: JSX.Element = null;
let renderSearchBox: JSX.Element = null;
let renderPagination: JSX.Element = null;
// Loading behavior
if (areResultsLoading) {
if (!isEmpty(items.value)) {
renderOverlay = <div>
<Overlay isDarkThemed={false} theme={this.props.themeVariant as ITheme} className={styles.overlay}>
<Spinner size={SpinnerSize.medium} />
</Overlay>
</div>;
} else {
let templateContext = {
items: items,
resultCount: this.state.resultCount,
showPagination: this.props.showPagination,
showResultsCount: this.props.showResultsCount,
showBlank: this.props.showBlank && this.props.searchParameterOption !== SearchParameterOption.SearchBox,
showLPC: this.props.showLPC,
themeVariant: this.props.themeVariant,
pageSize: this.props.searchService.pageSize,
serviceScope: this.props.serviceScope
} as ITemplateContext;
templateContext = { ...templateContext, ...this.props.templateParameters };
renderShimmerElements = this.props.templateService.getShimmerTemplateComponent(this.props.selectedLayout, templateContext);
}
}
// WebPart title
renderWebPartTitle = <WebPartTitle displayMode={this.props.displayMode} title={this.props.webPartTitle} updateProperty={(value: string) => this.props.updateWebPartTitle(value)} />;
// WebPart content
if (isEmpty(items.value) && this.props.showBlank && this.props.selectedLayout !== ResultsLayoutOption.Debug && this.props.searchParameterOption !== SearchParameterOption.SearchBox) {
if (this.props.displayMode === DisplayMode.Edit) {
renderWebPartContent = <MessageBar messageBarType={MessageBarType.info}>{strings.ShowBlankEditInfoMessage}</MessageBar>;
}
else {
renderWebPartTitle = null;
}
} else {
let templateContext = {
items: items,
resultCount: this.state.resultCount,
showPagination: this.props.showPagination,
showResultsCount: this.props.showResultsCount,
showBlank: this.props.showBlank && this.props.searchParameterOption !== SearchParameterOption.SearchBox,
showLPC: this.props.showLPC,
themeVariant: this.props.themeVariant,
pageSize: this.props.searchService.pageSize,
serviceScope: this.props.serviceScope
} as ITemplateContext;
templateContext = { ...templateContext, ...this.props.templateParameters };
let renderSearchResultTemplate = this.props.templateService.getTemplateComponent(this.props.selectedLayout, templateContext);
if (this.props.searchParameterOption === SearchParameterOption.SearchBox) {
renderSearchBox = <PeopleSearchBox themeVariant={this.props.themeVariant} onSearch={(searchQuery) => { this.props.updateSearchParameter(searchQuery); }} searchInputValue={this.props.searchService.searchParameter} />;
}
if (this.props.showPagination) {
let prevPageEl: JSX.Element = null;
let nextPageEl: JSX.Element = null;
if (this.hasPreviousPage()) {
prevPageEl = <IconButton onClick={async () => await this._fetchPeopleSearchResults(this.state.page - 1)} iconProps={{ iconName: 'DoubleChevronLeft8' }} />;
}
if (this.hasNextPage()) {
nextPageEl = <IconButton onClick={async () => await this._fetchPeopleSearchResults(this.state.page + 1)} iconProps={{ iconName: 'DoubleChevronRight8' }} />;
}
renderPagination =
<div className={styles.searchPagination}>
{prevPageEl}
{nextPageEl}
</div>;
}
renderWebPartContent =
<React.Fragment>
{renderOverlay}
{renderSearchBox}
{renderSearchResultTemplate}
{renderPagination}
</React.Fragment>;
}
// Error Message
if (hasError) {
renderWebPartContent = <MessageBar messageBarType={MessageBarType.error}>{errorMessage}</MessageBar>;
}
return (
<div style={{backgroundColor: semanticColors.bodyBackground}}>
<div className={styles.peopleSearchWebPart}>
{renderWebPartTitle}
{renderShimmerElements ? renderShimmerElements : renderWebPartContent}
</div>
</div>
);
}