Skip to content

Commit

Permalink
Merge pull request #5358 from Sandeep-FED/dev-new
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoabernier authored Jan 13, 2025
2 parents 4f2eded + eed28bb commit 6f75d1f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 27 deletions.
4 changes: 2 additions & 2 deletions samples/react-modern-carousel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Create a SharePoint custom list `Award Recognition` in the SPO site with below c
| Version | Date | Comments |
| ------- | ---------------- | ----------------------------------- |
| 1.0 | March 16, 2024 | Initial release |
| 1.1 | October 19, 2024 | Upgrade to SPFx 1.20 & misc changes |
| 1.1 | October 19, 2024 | Upgrade to SPFx 1.20 & misc. changes |
| 2.0 | November 1, 2024 | New feature: card styles & animations |

## Minimal Path to Awesome⚡
Expand Down Expand Up @@ -85,7 +85,7 @@ Key features demonstrated by this solution:
## References

- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development.
- [SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [PnP JS](https://pnp.github.io/pnpjs/)
- [PnP React Hooks](https://superioone.github.io/pnp-react-hooks/)
- [SwiperJS](https://swiperjs.com)
Expand Down
27 changes: 17 additions & 10 deletions samples/react-modern-carousel/src/components/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,20 @@ export const Carousel = (): JSX.Element => {
const moduleType =
contextInfo.cardType === "coverEffect" ? EffectCoverflow : EffectCards

console.log("module type", moduleType)
console.log("card style", contextInfo.cardStyle)

const cardStyles =
contextInfo.cardStyle === "rounded"
? {
width: "400px",
height: "400px",
borderRadius: "100%",
}
: {
width: "300px",
height: "400px",
borderRadius: "9px",
}

return (
<div className={styles.container}>
Expand All @@ -76,8 +89,8 @@ export const Carousel = (): JSX.Element => {
coverflowEffect={{
rotate: 0,
stretch: 0,
depth: 100,
modifier: 2.5,
depth: 120,
modifier: 3.5,
}}
keyboard={{ enabled: true }}
mousewheel={{
Expand All @@ -100,13 +113,7 @@ export const Carousel = (): JSX.Element => {
>
{awardList?.map((user, index) => (
<SwiperSlide key={index}>
<Card
style={{
width: "300px",
height: "400px",
borderRadius: "8px",
}}
>
<Card style={cardStyles}>
<CardPreview style={{ height: "inherit" }}>
<img src={user.ImageUrl} alt={user.Title} />
</CardPreview>
Expand Down
30 changes: 17 additions & 13 deletions samples/react-modern-carousel/src/components/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import * as React from "react";
import { Text } from "@fluentui/react-components";
import styles from "../webparts/awardRecognition/components/AwardRecognition.module.scss";
import * as React from "react"
import { Text } from "@fluentui/react-components"
import styles from "../webparts/awardRecognition/components/AwardRecognition.module.scss"
import { ContentProps } from "../types/ContentProps"
import { useContext } from "react";
import { WebpartContext } from "../webparts/awardRecognition/components/AwardRecognition";
import { useContext } from "react"
import { WebpartContext } from "../webparts/awardRecognition/components/AwardRecognition"

export const Content = ({ user }: ContentProps): JSX.Element => {
const contextInfo = useContext(WebpartContext);
const contextInfo = useContext(WebpartContext)

return (
<section className={styles.contentWrapper}>
<Text size={600} weight="semibold">
<Text size={600} weight='semibold' className={styles.webpartTitle}>
{contextInfo.webpartTitle}
</Text>
<div className={styles.contentDescriptionWrapper}>
<Text size={400} weight="semibold" className={styles.contentTitle}>
<Text size={400} weight='semibold' className={styles.contentTitle}>
{contextInfo.contentTitle}
</Text>
<Text size={300}>{contextInfo.contentDescription}</Text>
<Text size={300} className={styles.contentDescription}>
{contextInfo.contentDescription}
</Text>
</div>

<div className={styles.userInfo}>
<Text size={800} weight="semibold" className={styles.userName}>
<Text size={800} weight='semibold' className={styles.userName}>
{user?.Title}
</Text>
<Text size={400}>{user?.Designation}</Text>
<Text size={400} className={styles.designation}>
{user?.Designation}
</Text>
</div>
</section>
);
};
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IAwardRecognitionWebPartProps {
hookOptions: PnpHookGlobalOptions
animationChoice: string
cardType: string
cardStyle: string
}

export default class AwardRecognitionWebPart extends BaseClientSideWebPart<IAwardRecognitionWebPartProps> {
Expand All @@ -42,6 +43,7 @@ export default class AwardRecognitionWebPart extends BaseClientSideWebPart<IAwar
userDisplayName: this.context.pageContext.user.displayName,
animationChoice: this.properties.animationChoice,
cardType: this.properties.cardType,
cardStyle: this.properties.cardStyle,
})

// Use helper function to create React elements.
Expand Down Expand Up @@ -177,6 +179,18 @@ export default class AwardRecognitionWebPart extends BaseClientSideWebPart<IAwar
}),
],
},
{
groupName: strings.CardsStyleGroupName,
groupFields: [
PropertyPaneChoiceGroup("cardStyle", {
label: "Choose card styles",
options: [
{ key: "rounded", text: "Rounded" },
{ key: "roundedSquare", text: "Rounded Square" },
],
}),
],
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ $primaryColor: "[theme: themePrimary, default: #0078d7]";
.container {
display: flex;
}

.webpartTitle {
font-family: var(--fontFamilyCustomFont1500, var(--fontFamilyBase));
}
.contentWrapper {
display: grid;
gap: 3rem;
}
.contentTitle,
.userName {
color: $primaryColor;
font-family: var(--fontFamilyCustomFont1500, var(--fontFamilyBase));
}
.contentDescription,
.designation {
font-family: var(--fontFamilyCustomFont800, var(--fontFamilyBase));
}
.asideWrapper {
width: 30%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const AwardRecognition = (
<WebpartContext.Provider value={props}>
<FluentProvider
theme={webLightTheme}
style={{ width: "100%", background: "none" }}
style={{ width: "100%", background: "none", margin: "0 2rem" }}
>
<Carousel />
</FluentProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface IAwardRecognitionProps {
userDisplayName: string
animationChoice: string
cardType: string
cardStyle: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ define([], function () {
PropertyPaneDescription: "Configure this webpart",
BasicGroupName: "Basic settings",
CarouselControlsGroupName: "Control carousel settings",
CardsStyleGroupName: "Card styles",
WebpartFieldLabel: "Heading",
ContentTitleFieldLabel: "Sub heading",
ContentDescriptionFieldLabel: "Sub heading description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare interface IAwardRecognitionWebPartStrings {
PropertyPaneDescription: string
BasicGroupName: string
CarouselControlsGroupName: string
CardsStyleGroupName: string
ContentDescriptionFieldLabel: string
ContentTitleFieldLabel: string
WebpartFieldLabel: string
Expand Down

0 comments on commit 6f75d1f

Please sign in to comment.