From ad89de820102cac92a95439e185a6f0b208a1614 Mon Sep 17 00:00:00 2001 From: Hugo Bernier Date: Fri, 17 Apr 2020 21:27:14 -0400 Subject: [PATCH] Before fixing crazy resize behavor --- samples/react-calendar-feed/README.md | 2 +- .../EventCard/EventCard.module.scss | 5 ---- .../FilmstripLayout.module.scss | 2 ++ .../CalendarFeedSummaryWebPart.manifest.json | 2 +- .../CalendarFeedSummaryWebPart.ts | 27 +++++++++++++++++++ .../components/CalendarFeedSummary.tsx | 6 ++++- .../components/CalendarFeedSummary.types.ts | 3 ++- 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/samples/react-calendar-feed/README.md b/samples/react-calendar-feed/README.md index ad492e5f9..3fe9f1bc8 100644 --- a/samples/react-calendar-feed/README.md +++ b/samples/react-calendar-feed/README.md @@ -59,7 +59,7 @@ Version|Date|Comments 3.0|November 9, 2018|Converted to SPFx 1.7; Added SharePoint Calendar feed 4.0|January 16, 2019|Converted to SPFx 1.7.1; Removed NPM libraries associated with issue #708. 5.0|August 17, 2019|Converted to SPFx 1.9.1; Refreshed carousel code; Addresses #735, #909. Also added **Convert from UTC** option to handle feeds which do not provide time zone information. -5.1|April 16, 2020|Converted to SPFx 1.10.0 +5.1|April 16, 2020|Converted to SPFx 1.10.0; Fixed issue with UTC mode when in narrow view. Updated resizing behaviour and styles to match OOB calendar view. ## Disclaimer diff --git a/samples/react-calendar-feed/src/shared/components/EventCard/EventCard.module.scss b/samples/react-calendar-feed/src/shared/components/EventCard/EventCard.module.scss index 41d57512d..2eecf9a57 100644 --- a/samples/react-calendar-feed/src/shared/components/EventCard/EventCard.module.scss +++ b/samples/react-calendar-feed/src/shared/components/EventCard/EventCard.module.scss @@ -176,8 +176,3 @@ word-wrap: normal; height: 18px; } - -// :global(.slick-slide) .cardWrapper { -// padding-left:8px; -// padding-right:8px; -// } diff --git a/samples/react-calendar-feed/src/shared/components/filmstripLayout/FilmstripLayout.module.scss b/samples/react-calendar-feed/src/shared/components/filmstripLayout/FilmstripLayout.module.scss index 5c029fca3..2ff548c6e 100644 --- a/samples/react-calendar-feed/src/shared/components/filmstripLayout/FilmstripLayout.module.scss +++ b/samples/react-calendar-feed/src/shared/components/filmstripLayout/FilmstripLayout.module.scss @@ -8,6 +8,8 @@ &.filmStrip { margin-bottom: 27px; + margin-left: -10px; + margin-right: -10px; :global(.slick-slide) { box-sizing: border-box; diff --git a/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.manifest.json b/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.manifest.json index dd02eb48f..6aefb0b92 100644 --- a/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.manifest.json +++ b/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.manifest.json @@ -3,7 +3,7 @@ "id": "acef6c3f-852a-42e3-8a4b-7ea191ae9687", "alias": "CalendarFeedSummaryWebPart", "componentType": "WebPart", - + "supportsThemeVariants": true, "version": "*", "manifestVersion": 2, "supportedHosts": ["SharePointWebPart"], diff --git a/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.ts b/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.ts index 38d8e03d9..0b2005907 100644 --- a/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.ts +++ b/samples/react-calendar-feed/src/webparts/calendarFeedSummary/CalendarFeedSummaryWebPart.ts @@ -34,6 +34,9 @@ import { ICalendarFeedSummaryWebPartProps } from "./CalendarFeedSummaryWebPart.t import CalendarFeedSummary from "./components/CalendarFeedSummary"; import { ICalendarFeedSummaryProps } from "./components/CalendarFeedSummary.types"; +// Support for theme variants +import { ThemeProvider, ThemeChangedEventArgs, IReadonlyTheme, ISemanticColors } from '@microsoft/sp-component-base'; + // this is the same width that the SharePoint events web parts use to render as narrow const MaxMobileWidth: number = 480; @@ -46,6 +49,9 @@ export default class CalendarFeedSummaryWebPart extends BaseClientSideWebPart { return new Promise((resolve, _reject) => { + // Consume the new ThemeProvider service + this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey); + + // If it exists, get the theme variant + this._themeVariant = this._themeProvider.tryGetTheme(); + + // Register a handler to be notified if the theme variant changes + this._themeProvider.themeChangedEvent.add(this, this._handleThemeChangedEvent); let { cacheDuration, @@ -90,6 +104,8 @@ export default class CalendarFeedSummaryWebPart extends BaseClientSideWebPart | undefined = this._themeVariant && this._themeVariant.semanticColors; + // see if we need to render a mobile view const isNarrow: boolean = this.domElement.clientWidth <= MaxMobileWidth; @@ -104,6 +120,7 @@ export default class CalendarFeedSummaryWebPart extends BaseClientSideWebPart { this.properties.title = value; }, @@ -355,4 +372,14 @@ export default class CalendarFeedSummaryWebPart extends BaseClientSideWebPart +
+