File tree 4 files changed +124
-0
lines changed
examples/with-office-ui-fabric-react
4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ [ ![ Deploy to now] ( https://deploy.now.sh/static/button.svg )] ( https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-office-ui-fabric-react )
2
+
3
+ # Office UI Fabric React example
4
+
5
+ ## How to use
6
+
7
+ ### Using ` create-next-app `
8
+
9
+ Execute [ ` create-next-app ` ] ( https://github.com/segmentio/create-next-app ) with [ Yarn] ( https://yarnpkg.com/lang/en/docs/cli/create/ ) or [ npx] ( https://github.com/zkat/npx#readme ) to bootstrap the example:
10
+
11
+ ``` bash
12
+ npx create-next-app --example with-office-ui-fabric-react with-office-ui-fabric-react-app
13
+ # or
14
+ yarn create next-app --example with-office-ui-fabric-react with-office-ui-fabric-react-app
15
+ ```
16
+
17
+ ### Download manually
18
+
19
+ Download the example:
20
+
21
+ ``` bash
22
+ curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-office-ui-fabric-react
23
+ cd with-office-ui-fabric-react
24
+ ```
25
+
26
+ Install it and run:
27
+
28
+ ``` bash
29
+ npm install
30
+ npm run dev
31
+ # or
32
+ yarn
33
+ yarn dev
34
+ ```
35
+
36
+ Deploy it to the cloud with [ now] ( https://zeit.co/now ) ([ download] ( https://zeit.co/download ) )
37
+
38
+ ``` bash
39
+ now
40
+ ```
41
+
42
+ ## The idea behind the example
43
+
44
+ This example shows how to use Office UI Fabric React in Next.js.
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " with-office-ui-fabric-react" ,
3
+ "version" : " 1.0.0" ,
4
+ "dependencies" : {
5
+ "next" : " ^8.03" ,
6
+ "office-ui-fabric-react" : " ^6.154.0" ,
7
+ "react" : " ^16.8.4" ,
8
+ "react-dom" : " ^16.8.4"
9
+ },
10
+ "devDependencies" : {},
11
+ "license" : " ISC" ,
12
+ "scripts" : {
13
+ "dev" : " node server.js" ,
14
+ "build" : " next build" ,
15
+ "start" : " NODE_ENV=production node server.js"
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ import { useState } from 'react'
2
+ import { Fabric } from 'office-ui-fabric-react/lib-commonjs/Fabric'
3
+ import { DefaultButton , PrimaryButton } from 'office-ui-fabric-react/lib-commonjs/Button'
4
+ import { Dialog , DialogType , DialogFooter } from 'office-ui-fabric-react/lib-commonjs/Dialog'
5
+
6
+ export default ( ) => {
7
+ const [ isOpen , setIsOpen ] = useState ( false )
8
+ const openDialog = ( ) => setIsOpen ( true )
9
+ const closeDialog = ( ) => setIsOpen ( false )
10
+ return (
11
+ < Fabric >
12
+ < p > Welcome to next.js!</ p >
13
+ < DefaultButton primary onClick = { openDialog } > Open Dialog</ DefaultButton >
14
+ < Dialog
15
+ hidden = { ! isOpen }
16
+ onDismiss = { closeDialog }
17
+ dialogContentProps = { {
18
+ type : DialogType . normal ,
19
+ title : 'Test Dialog'
20
+ } }
21
+ modalProps = { {
22
+ isBlocking : true
23
+ } }
24
+ >
25
+ < p > This is a test dialog.</ p >
26
+ < DialogFooter >
27
+ < PrimaryButton onClick = { closeDialog } text = 'OK' />
28
+ < DefaultButton onClick = { closeDialog } text = 'Cancel' />
29
+ </ DialogFooter >
30
+ </ Dialog >
31
+ </ Fabric >
32
+ )
33
+ }
Original file line number Diff line number Diff line change
1
+ const { createServer } = require ( 'http' )
2
+ const { parse } = require ( 'url' )
3
+ const next = require ( 'next' )
4
+
5
+ const library = require ( 'office-ui-fabric-react/lib-commonjs/Utilities' )
6
+ const responsiveLib = require ( 'office-ui-fabric-react/lib-commonjs/utilities/decorators/withResponsiveMode' )
7
+
8
+ library . setSSR ( true )
9
+ library . setRTL ( false )
10
+ // Assume a large screen.
11
+ responsiveLib . setResponsiveMode ( responsiveLib . ResponsiveMode . large )
12
+
13
+ // Hack to prevent issues with office-ui-fabric-react SSR support.
14
+ process . __currentId__ = 0
15
+ // --
16
+
17
+ const port = parseInt ( process . env . PORT , 10 ) || 3000
18
+ const dev = process . env . NODE_ENV !== 'production'
19
+ const app = next ( { dev } )
20
+ const handle = app . getRequestHandler ( )
21
+
22
+ app . prepare ( ) . then ( ( ) => {
23
+ createServer ( ( req , res ) => {
24
+ const parsedUrl = parse ( req . url , true )
25
+ handle ( req , res , parsedUrl )
26
+ } ) . listen ( port , err => {
27
+ if ( err ) throw err
28
+ console . log ( `> Ready on http://localhost:${ port } ` )
29
+ } )
30
+ } )
You can’t perform that action at this time.
0 commit comments