-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
297 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/IdeaModule.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.ideaModule { | ||
margin: 0; | ||
|
||
.container { | ||
margin: 0; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/IdeaModule.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { FC } from 'react' | ||
import styles from './IdeaModule.module.scss' | ||
import { IdeaModuleContext } from './context' | ||
import { IIdeaModuleProps } from './types' | ||
import { useIdeaModule } from './useIdeaModule' | ||
import { FluentProvider, IdPrefixProvider } from '@fluentui/react-components' | ||
import { customLightTheme } from 'pp365-shared-library' | ||
|
||
export const IdeaModule: FC<IIdeaModuleProps> = (props) => { | ||
const { state, setState, fluentProviderId } = useIdeaModule(props) | ||
|
||
return ( | ||
<div className={styles.ideaModule}> | ||
<IdeaModuleContext.Provider value={{ props, state, setState }}> | ||
<IdPrefixProvider value={fluentProviderId}> | ||
<FluentProvider theme={customLightTheme}> | ||
<div className={styles.container}> | ||
<h1>Bring your ideas to life. Here you can create, share and collaborate on ideas.</h1> | ||
<p>With the new Idea module, you can create and share ideas with your team. You can also collaborate on ideas with your team members.</p> | ||
</div> | ||
</FluentProvider> | ||
</IdPrefixProvider> | ||
</IdeaModuleContext.Provider> | ||
</div> | ||
) | ||
} | ||
|
||
IdeaModule.defaultProps = { | ||
configurationList: 'Idékonfigurasjon' | ||
} |
17 changes: 17 additions & 0 deletions
17
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createContext, useContext } from 'react' | ||
import { IIdeaModuleProps, IIdeaModuleState } from './types' | ||
|
||
export interface IIdeaModuleContext { | ||
props: IIdeaModuleProps | ||
state: IIdeaModuleState | ||
setState: (newState: Partial<IIdeaModuleState>) => void | ||
} | ||
|
||
export const IdeaModuleContext = createContext<IIdeaModuleContext>(null) | ||
|
||
/** | ||
* Hook to get the `ProjectProvisionContext` | ||
*/ | ||
export function useProjectProvisionContext() { | ||
return useContext(IdeaModuleContext) | ||
} |
2 changes: 2 additions & 0 deletions
2
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './IdeaModule' | ||
export * from './types' |
25 changes: 25 additions & 0 deletions
25
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { IBaseComponentProps } from '../types' | ||
|
||
export interface IIdeaModuleProps extends IBaseComponentProps { | ||
configurationList: string | ||
} | ||
|
||
export interface IIdeaModuleState { | ||
loading?: boolean | ||
isRefetching?: boolean | ||
configuration?: ConfigurationItem[] | ||
ideas?: Record<string, any> | ||
} | ||
|
||
export interface IIdeaModuleHashState { | ||
ideaId?: string | ||
} | ||
|
||
export class ConfigurationItem { | ||
title: string | ||
description: string | ||
ideaProcessingList: string | ||
ideaRegistrationList: string | ||
ideaProcessingChoices: string | ||
ideaRegistrationChoices: string | ||
} |
18 changes: 18 additions & 0 deletions
18
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/useIdeaModule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useId } from '@fluentui/react-components' | ||
import { IIdeaModuleProps } from './types' | ||
import { useIdeaModuleState } from './useIdeaModuleState' | ||
|
||
/** | ||
* Component logic hook for `IdeaModule` component. | ||
* | ||
clear */ | ||
export function useIdeaModule(props: IIdeaModuleProps) { | ||
const { state, setState } = useIdeaModuleState() | ||
const fluentProviderId = useId('fp-idea-module') | ||
|
||
return { | ||
state, | ||
setState, | ||
fluentProviderId | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/useIdeaModuleDataFetch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useEffect } from 'react' | ||
import { IIdeaModuleProps, IIdeaModuleState } from './types' | ||
|
||
/** | ||
* Component data fetch hook for `IdeaModule`. This hook is responsible for | ||
* fetching data and setting state. | ||
* | ||
* @param props Props | ||
* @param refetch Timestamp for refetch. Changes to this variable refetches the data in `useEffect` | ||
* @param setState Set state callback | ||
*/ | ||
export function useIdeaModuleDataFetch( | ||
props: IIdeaModuleProps, | ||
refetch: number, | ||
setState: (newState: Partial<IIdeaModuleState>) => void | ||
) { | ||
useEffect(() => { | ||
Promise.all([props.dataAdapter.getConfiguration(props.configurationList)]).then( | ||
([configuration]) => { | ||
setState({ | ||
configuration, | ||
ideas: configuration, | ||
loading: false, | ||
isRefetching: false | ||
}) | ||
} | ||
) | ||
}, [refetch]) | ||
} |
27 changes: 27 additions & 0 deletions
27
SharePointFramework/PortfolioWebParts/src/components/IdeaModule/useIdeaModuleState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable prefer-spread */ | ||
import { useState } from 'react' | ||
import { IIdeaModuleState } from './types' | ||
|
||
/** | ||
* Component state hook for `IIdeaModule`. | ||
* | ||
* @param props Props | ||
*/ | ||
export function useIdeaModuleState() { | ||
const [state, $setState] = useState<IIdeaModuleState>({ | ||
loading: true, | ||
configuration: [], | ||
ideas: {} | ||
}) | ||
|
||
/** | ||
* Set state like `setState` in class components where | ||
* the new state is merged with the current state. | ||
* | ||
* @param newState New state | ||
*/ | ||
const setState = (newState: Partial<IIdeaModuleState>) => | ||
$setState((currentState) => ({ ...currentState, ...newState })) | ||
|
||
return { state, setState } as const | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
SharePointFramework/PortfolioWebParts/src/webparts/ideaModule/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable quotes */ | ||
import { IPropertyPaneConfiguration, PropertyPaneTextField } from '@microsoft/sp-property-pane' | ||
import * as strings from 'PortfolioWebPartsStrings' | ||
import { BasePortfolioWebPart } from '../basePortfolioWebPart' | ||
import { IIdeaModuleProps, IdeaModule } from 'components/IdeaModule' | ||
|
||
export default class IdeaModuleWebPart extends BasePortfolioWebPart<IIdeaModuleProps> { | ||
public render(): void { | ||
this.renderComponent<IIdeaModuleProps>(IdeaModule) | ||
} | ||
|
||
public async onInit(): Promise<void> { | ||
await super.onInit() | ||
} | ||
|
||
public getPropertyPaneConfiguration(): IPropertyPaneConfiguration { | ||
return { | ||
pages: [ | ||
{ | ||
header: { | ||
description: 'Idémodul' | ||
}, | ||
groups: [ | ||
{ | ||
groupName: strings.GeneralGroupName, | ||
groupFields: [ | ||
PropertyPaneTextField('configurationList', { | ||
label: 'Konfigurasjon liste', | ||
description: 'Navn på Idékonfigurasjonsliste' | ||
}) | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
SharePointFramework/PortfolioWebParts/src/webparts/ideaModule/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", | ||
"id": "20f151a9-6891-4408-a6d6-77e749b9e3e7", | ||
"alias": "IdeaModuleWebPart", | ||
"componentType": "WebPart", | ||
"version": "1.10.0", | ||
"manifestVersion": 2, | ||
"requiresCustomScript": false, | ||
"hiddenFromToolbox": true, | ||
"supportedHosts": [ | ||
"SharePointWebPart" | ||
], | ||
"preconfiguredEntries": [ | ||
{ | ||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", | ||
"group": { | ||
"default": "Other" | ||
}, | ||
"title": { | ||
"default": "Idémodul" | ||
}, | ||
"description": { | ||
"default": " " | ||
}, | ||
"officeFabricIconFontName": "Lightbulb", | ||
"properties": { | ||
"title": "Idémodul" | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.