import * as React from 'react' ; import * as ReactDom from 'react-dom' ; import { Version } from '@microsoft/sp-core-library' ; import { BaseClientSideWebPart , IPropertyPaneConfiguration } from '@microsoft/sp-webpart-base' ; import { RecentlyVisitedSites , IRecentlyVisitedSitesProps } from './components' ; import { MSGraphClient } from '@microsoft/sp-http' ; import { ThemeProvider , ThemeChangedEventArgs , IReadonlyTheme , ISemanticColors } from '@microsoft/sp-component-base' ; export interface IRecentlyVisitedSitesWebPartProps { title : string ; } export default class RecentlyVisitedSitesWebPart extends BaseClientSideWebPart < IRecentlyVisitedSitesWebPartProps > { private graphClient : MSGraphClient ; private _themeProvider : ThemeProvider ; private _themeVariant : IReadonlyTheme | undefined ; public onInit ( ) { this . _themeProvider = this . context . serviceScope . consume ( ThemeProvider . serviceKey ) ; this . _themeVariant = this . _themeProvider . tryGetTheme ( ) ; this . _themeProvider . themeChangedEvent . add ( this , this . _handleThemeChangedEvent ) ; return new Promise < void > ( ( resolve , reject ) : void => { this . context . msGraphClientFactory . getClient ( ) . then ( ( client ) : void => { this . graphClient = client ; resolve ( ) ; } , err => reject ( err ) ) ; } ) ; } public render ( ) { const element = React . createElement ( RecentlyVisitedSites , { title : this . properties . title , graphClient : this . graphClient , displayMode : this . displayMode , themeVariant : this . _themeVariant , updateProperty : ( value ) => { this . properties . title = value ; } } ) ; ReactDom . render ( element , this . domElement ) ; } protected get dataVersion ( ) : Version { return Version . parse ( '1.0' ) ; } protected getPropertyPaneConfiguration ( ) { return { pages : [ ] } ; } protected _handleThemeChangedEvent = ( args ) : void => { this . _themeVariant = args . theme ; this . render ( ) ; } ; }