Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new sample, react-menu-footer-classic-modern
- Loading branch information
Showing
64 changed files
with
33,661 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
samples/react-menu-footer-classic-modern/Classic/.gitignore
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,16 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Dependency directories | ||
node_modules | ||
|
||
# Build generated files | ||
build | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Styles Generated Code | ||
*.scss.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,6 @@ | ||
|
||
Here is the script to run on a publishing site: | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.2/react.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/15.6.2/react-dom.min.js"></script> | ||
<script src="/sites/pubsite/Style%20Library/Scripts/bundleClassic.js"></script> |
48 changes: 48 additions & 0 deletions
48
samples/react-menu-footer-classic-modern/Classic/client/bootHeaderFooter.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,48 @@ | ||
import HeaderFooterDataService from './common/services/HeaderFooterDataService'; | ||
import IHeaderFooterData from './common/model/IHeaderFooterData'; | ||
import ComponentManager from './common/components/ComponentManager'; | ||
|
||
export class bootstrapper { | ||
|
||
public onInit(): void { | ||
|
||
// Create the div elements to hold the header and footer | ||
const header = document.createElement("div"); | ||
const footer = document.createElement("div"); | ||
|
||
// Insert the header and footer on the page | ||
const workspace = document.getElementById('s4-workspace'); | ||
if (workspace) { | ||
|
||
workspace.parentElement.insertBefore(header,workspace); | ||
workspace.appendChild(footer); | ||
|
||
// For now this is hard-coded | ||
// -- UPLOAD JSON WITH MENU CONTENTS AND PUT THE URL HERE -- | ||
const url = 'https://<tenant>.sharepoint.com/sites/scripts/Style%20Library/HeaderFooterData.json.txt'; | ||
|
||
// Get the header and footer data and render it | ||
HeaderFooterDataService.get(url) | ||
.then ((data: IHeaderFooterData) => { | ||
ComponentManager.render(header, footer, data); | ||
}) | ||
.catch ((error: string) => { | ||
console.log(`Error in CustomHeaderFooterApplicationCustomizer: ${error}`); | ||
}); | ||
|
||
} else { | ||
|
||
// The elemement we want to attach to is missing | ||
console.log('Error in CustomHeaderFooterApplicationCustomizer: Unable to find element to attach header and footer'); | ||
|
||
} | ||
} | ||
} | ||
|
||
// In-line code starts here | ||
(<any>window).ExecuteOrDelayUntilBodyLoaded(() => { | ||
if (window.location.search.indexOf('IsDlg=1') < 0) { | ||
let b = new bootstrapper(); | ||
b.onInit(); | ||
} | ||
}) |
35 changes: 35 additions & 0 deletions
35
...les/react-menu-footer-classic-modern/Classic/client/common/components/ComponentManager.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,35 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
import { IHeaderProps, Header } from './Header'; | ||
import { IFooterProps, Footer } from './Footer'; | ||
|
||
import IHeaderFooterData from '../model/IHeaderFooterData'; | ||
|
||
import { languageManager } from '../../languageManager'; | ||
|
||
export default class ComponentManager { | ||
|
||
public static render(headerDomElement: HTMLElement, footerDomElement: HTMLElement, | ||
data: IHeaderFooterData): void { | ||
|
||
const strings = languageManager.GetStrings(); | ||
|
||
// If there is a header DOM element, make the react element and render it | ||
if (headerDomElement) { | ||
const reactElt: React.ReactElement<IHeaderProps> = React.createElement(Header, { | ||
links: data.headerLinks | ||
}); | ||
ReactDOM.render(reactElt, headerDomElement); | ||
} | ||
|
||
// If there is a footer DOM element, make the react element and render it | ||
if (footerDomElement) { | ||
const reactElt: React.ReactElement<IFooterProps> = React.createElement(Footer, { | ||
message: strings.FooterMessage, | ||
links: data.footerLinks | ||
}); | ||
ReactDOM.render(reactElt, footerDomElement); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
samples/react-menu-footer-classic-modern/Classic/client/common/components/Footer.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,34 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
import ILink from '../model/ILink'; | ||
|
||
require ('./HeaderFooter.scss'); | ||
|
||
export interface IFooterProps { | ||
message: string; | ||
links: ILink[]; | ||
} | ||
|
||
export class Footer extends React.Component<IFooterProps, {}> { | ||
|
||
constructor(props: IFooterProps) { | ||
super(props); | ||
} | ||
|
||
public render(): JSX.Element { | ||
return ( | ||
<div className="bottomNav"> | ||
{/* Render the message */} | ||
<span>{this.props.message}</span> | ||
{/* Render links */} | ||
<ul className="test"> | ||
{this.props.links.map(l => ( | ||
<li><a href={l.url}>{l.name}</a></li> | ||
))} | ||
</ul> | ||
{/* End links */} | ||
</div> | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
samples/react-menu-footer-classic-modern/Classic/client/common/components/Header.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,49 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
|
||
import ILink from '../model/ILink'; | ||
|
||
require ('./HeaderFooter.scss'); | ||
|
||
export interface IHeaderProps { | ||
links: ILink[]; | ||
} | ||
|
||
export class Header extends React.Component<IHeaderProps, {}> { | ||
|
||
constructor(props: IHeaderProps) { | ||
super(props); | ||
} | ||
|
||
public render(): JSX.Element { | ||
return ( | ||
<div className="topNav"> | ||
{/* Render hamburger menu */} | ||
<label htmlFor="show-menu" className="show-menu"> | ||
<div className="show-menu"><div className="hamburger"> | ||
<div></div><div></div><div></div> | ||
</div></div> | ||
</label> | ||
<input type="checkbox" id="show-menu" role="button" /> | ||
{/* Render the main menu */} | ||
<ul> | ||
{this.props.links.map(l => ( | ||
<li> | ||
<a href={l.url}>{l.name}</a> | ||
{/* Render a child menu */} | ||
<ul className="hidden"> | ||
{l.children ? l.children.map(m => ( | ||
<li> | ||
<a href={m.url}>{m.name}</a> | ||
</li> | ||
)) : null} | ||
</ul> | ||
{/* End child menu */} | ||
</li> | ||
))} | ||
</ul> | ||
{/* End main menu */} | ||
</div> | ||
); | ||
} | ||
} |
Oops, something went wrong.