GithubHelp home page GithubHelp logo

gurdasnijor / office-ui-fabric-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/fluentui

1.0 2.0 0.0 20.69 MB

React components for building experiences for Office and Office 365.

Home Page: https://developer.microsoft.com/en-us/fabric#/components

License: Other

HTML 0.31% JavaScript 1.39% TypeScript 90.09% CSS 8.22%

office-ui-fabric-react's Introduction

The React-based front-end framework for building experiences for Office and Office 365.

npm version Build Status

Fabric React is a responsive, mobile-first collection of robust components designed to make it quick and simple for you to create web experiences using the Office Design Language.

Contents

Using Fabric React

Here is a step by step tutorial on how to build a simple React app with an Office UI Fabric React component.

Integrating components into your project depends heavily on your setup. The recommended setup is to use a bundler such as Webpack which can resolve NPM package imports in your code and can bundle the specific things you import.

Within an npm project, you should install the package and save it as a dependency:

npm install --save office-ui-fabric-react

This will add the fabric-react project as a dependency in your package.json file, and will drop the project under node_modules/office-ui-fabric-react.

The library includes commonjs entry points under the lib folder. To use a control, you should be able to import it and use it in your render method:

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';

ReactDOM.render(
  <PrimaryButton>
    I am a button.
  </PrimaryButton>,
  document.body.firstChild
);

Browser support

Fabric React supports many commonly used browsers. See the browser support doc for more information.

Server-side rendering

If you need to render Fabric components on the server side in a node environment, there is a way to do this. The basic idea is that you need to tell the styles loader to pipe styles into a variable, which you can later use to inject into your page. Example:

import { configureLoadStyles } from '@microsoft/load-themed-styles';

// Store registered styles in a variable used later for injection.
let _allStyles = '';

// Push styles into variables for injecting later.
configureLoadStyles((styles: string) => {
  _allStyles += styles;
});

import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';
import { Button } from 'office-ui-fabric-react/lib/Button';

let body = ReactDOMServer.renderToString(<Button>hello</Button>);

console.log(
  `
  <html>
  <head>
    <style>${ _allStyles}</style>
  </head>
  <body>
    ${ body}
  </body>
  </html>
  `);

Note: we are evaluating a more robust theming and style loading approach, which will allow a much more flexible server rendering approach, so this syntax may be simplified in the future.

Advanced usage

For advanced usage including info about module vs. path-based imports, using an AMD bundler like Require, and deployment features, see our advanced documentation.

Contribute to Fabric React

Please take a look at our contribution guidelines for more info.

Building the repo

Before you get started, make sure you have node.js and git installed.

To view the documentation including examples, contracts, component status, and to add functionality or fix issues locally, you can:

  1. git clone https://github.com/OfficeDev/office-ui-fabric-react.git
  2. npm install
  3. npm start

This will start a demo page from the office-ui-fabric-react package folder, which will open a web browser with the example page. You can make changes to the code which will automatically build and refresh the page using live-reload.

To build and run tests for all packages in the repo, you can run npm run build from the root.

To build individual packages within the packages/*/ folders, you can use npm run build in each individually. Note that because the packages are symlinked together, you must manage building dependencies in the right order, or use the rush tool to build to the specific package you want. (See advanced tips below.)

Testing

For testing see our testing documentation.

Advanced building tips

The repo contains many packages, each which may have dependencies on each other. You can use the rush tool to build projects in the correct order, if you have it globally installed.

npm install -g @microsoft/rush

To use rush to build, you can run rush build, which will incrementally build the entire repo (only build what has changed since the last build.)

To can also build up to a specific project using the --to <package> argument. For example, to build up to office-ui-fabric-react, you can run:

rush build --to office-ui-fabric-react

Licenses

All files on the Office UI Fabric React GitHub repository are subject to the MIT license. Please read the License file at the root of the project.

Usage of the fonts and icons referenced in Office UI Fabric is subject to the terms of the assets license agreement.

Changelog

We use GitHub Releases to manage our releases, including the changelog between every release. View a complete list of additions, fixes, and changes on the releases page.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

office-ui-fabric-react's People

Contributors

aditima avatar aleksandrjpersonal avatar atneik avatar betrue-final-final avatar c-w avatar christiango avatar cmalonzo avatar cschleiden avatar dzearing avatar erichdev avatar gokunymbus avatar jahnp avatar johannao76 avatar joschect avatar jspurlin avatar kellygorr avatar kristoferbrown avatar leddie24 avatar lynamemi avatar mdahamiwal avatar micahgodbolt avatar mloughry avatar montselozanod avatar pablonete avatar phkuo avatar rachelcl9 avatar rickyp-ms avatar thomasmichon avatar yiminwu avatar zoarif avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.