diff --git a/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/BirthdaysPerMonthWebPart.ts b/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/BirthdaysPerMonthWebPart.ts index 2b893c8eb..68b283233 100644 --- a/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/BirthdaysPerMonthWebPart.ts +++ b/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/BirthdaysPerMonthWebPart.ts @@ -1,61 +1,50 @@ -import * as React from 'react'; -import * as ReactDom from 'react-dom'; -import { Version } from '@microsoft/sp-core-library'; +import * as React from "react"; +import * as ReactDom from "react-dom"; +import { Version } from "@microsoft/sp-core-library"; import { IPropertyPaneConfiguration, - PropertyPaneTextField -} from '@microsoft/sp-property-pane'; -import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; + PropertyPaneTextField, +} from "@microsoft/sp-property-pane"; +import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base"; -import * as strings from 'BirthdaysPerMonthWebPartStrings'; -import BirthdaysPerMonth from './components/BirthdaysPerMonth'; -import { IBirthdaysPerMonthProps } from './components/IBirthdaysPerMonthProps'; -import '../../../assets/dist/tailwind.css'; +import * as strings from "BirthdaysPerMonthWebPartStrings"; +import "../../../assets/dist/tailwind.css"; +import { + BirthdaysPerMonth, + IBirthdaysPerMonthProps, +} from "./components/BirthdaysPerMonth"; export interface IBirthdaysPerMonthWebPartProps { description: string; } export default class BirthdaysPerMonthWebPart extends BaseClientSideWebPart { - private _isDarkTheme: boolean = false; - private _environmentMessage: string = ''; + private _environmentMessage: string = ""; public render(): void { - const element: React.ReactElement = React.createElement( - BirthdaysPerMonth, - { + const element: React.ReactElement = + React.createElement(BirthdaysPerMonth, { description: this.properties.description, isDarkTheme: this._isDarkTheme, environmentMessage: this._environmentMessage, hasTeamsContext: !!this.context.sdks.microsoftTeams, - userDisplayName: this.context.pageContext.user.displayName - } - ); + userDisplayName: this.context.pageContext.user.displayName, + }); ReactDom.render(element, this.domElement); } protected onInit(): Promise { - this._environmentMessage = this._getEnvironmentMessage(); - return super.onInit(); } - private _getEnvironmentMessage(): string { - if (!!this.context.sdks.microsoftTeams) { // running in Teams - return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment; - } - - return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment; - } - protected onDispose(): void { ReactDom.unmountComponentAtNode(this.domElement); } protected get dataVersion(): Version { - return Version.parse('1.0'); + return Version.parse("1.0"); } protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { @@ -63,20 +52,20 @@ export default class BirthdaysPerMonthWebPart extends BaseClientSideWebPart { - public render(): React.ReactElement { - const { - description, - isDarkTheme, - environmentMessage, - hasTeamsContext, - userDisplayName - } = this.props; +interface IBirthdaysPerMonthProps {} - return ( -
-
- -

Well done, {escape(userDisplayName)}!

-
{environmentMessage}
-
Web part property value: {escape(description)}
-
-
-

Welcome to SharePoint Framework!

-

- The SharePoint Framework (SPFx) is a extensibility model for Microsoft Viva, Microsoft Teams and SharePoint. It's the easiest way to extend Microsoft 365 with automatic Single Sign On, automatic hosting and industry standard tooling. -

-

Learn more about SPFx development:

- -
-
- ); - } -} +const BirthdaysPerMonth = () => { + return ( +
+
+ +

Well done, Ari!

+
+
+

Welcome to SharePoint Framework!

+

+ The SharePoint Framework (SPFx) is a extensibility model for Microsoft + Viva, Microsoft Teams and SharePoint. It's the easiest way to + extend Microsoft 365 with automatic Single Sign On, automatic hosting + and industry standard tooling. +

+

Learn more about SPFx development:

+ +
+
+ ); +}; + +export { IBirthdaysPerMonthProps, BirthdaysPerMonth }; diff --git a/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/components/IBirthdaysPerMonthProps.ts b/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/components/IBirthdaysPerMonthProps.ts deleted file mode 100644 index 7945a78cc..000000000 --- a/samples/react-birthdays-per-month/src/webparts/birthdaysPerMonth/components/IBirthdaysPerMonthProps.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface IBirthdaysPerMonthProps { - description: string; - isDarkTheme: boolean; - environmentMessage: string; - hasTeamsContext: boolean; - userDisplayName: string; -}