项目作者: richardzcode

项目描述 :
Easy to use React components extend Office UI Fabric
高级语言: JavaScript
项目地址: git://github.com/richardzcode/of-simplify-react.git
创建时间: 2018-07-12T20:42:47Z
项目社区:https://github.com/richardzcode/of-simplify-react

开源协议:MIT License

下载


of-simplify-react

License: MIT
npm version
npm downloads
GitHub last commit

Easy to use React components extend Office UI Fabric

Install

  1. npm install of-simplify-react

Components

CommandBar

  • Write CommandBarItem like React component.
  • Style CommandBar and CommandBarItem like React component.
  • Handle onCommand event to reduce repetitive code.
  1. import React, { Component } from 'react';
  2. import OfSimplify, { CommandBar, CommandBarItem } from 'of-simplify-react';
  3. OfSimplify.initializeIcons(); // in order to show icons
  4. class App extends Component {
  5. constructor(props) {
  6. super(props);
  7. this.handleCommand = this.handleCommand.bind(this);
  8. }
  9. handleCommand(key) {
  10. console.log('menu item clicked: ' + key);
  11. }
  12. render() {
  13. <CommandBar onCommand={this.handleCommand} style={{ padding: '0.5em', display: 'flex', alignItems: 'flex-end' }}>
  14. <CommandBarItem key="home" icon="Home" style={{ icon: { fontWeight: 'bold' } }} checked>Home</CommandBarItem>
  15. <CommandBarItem key="cat" icon="Cat">Cat</CommandBarItem>
  16. <CommandBarItem key="coffee" icon="CoffeeScript">Coffee</CommandBarItem>
  17. <CommandBarItem key="preferences" overflow>Preferences</CommandBarItem>
  18. <CommandBarItem key="signOut" icon="SignOut" style={{ textDecoration: 'underline' }} far>Sign Out</CommandBarItem>
  19. </CommandBar>
  20. }
  21. }
  22. export default App;

AutoComplete

  • Simple auto-complete component combines TextField and List
  1. import React, { Component } from 'react';
  2. import { AutoComplete } from 'of-simplify-react';
  3. const directors = [
  4. { name: 'John Thompson' },
  5. { name: 'Bradford Smith' },
  6. { name: 'Satya Nadella' },
  7. { name: 'William Gates' },
  8. { name: 'Amy Hood' },
  9. { name: 'Christopher Caposseia' },
  10. { name: 'Kathleen Hogan' },
  11. { name: 'Jean-Philippe Courtois' },
  12. { name: 'Margaret Johnson' },
  13. { name: 'Kevin Scott' },
  14. { name: 'Sean Ventura' },
  15. { name: 'Reid Hoffman' },
  16. { name: 'Hugh Johnston' },
  17. { name: 'Teri List-Stoll' },
  18. { name: 'Charles Noski' },
  19. { name: 'Helmut Panke' },
  20. { name: 'Sandra Peterson' },
  21. { name: 'Charles Scharf' },
  22. { name: 'John Stanton' },
  23. { name: 'Padmasree Warrior' }
  24. ];
  25. const autoCompleteSearch= function(directors, q) {
  26. q = q.toLowerCase();
  27. return directors.filter(director => director.name.toLowerCase().match(q))
  28. }
  29. class App extends Component {
  30. constructor(props) {
  31. super(props);
  32. this.handleChange = this.handleChange.bind(this);
  33. }
  34. handleChange(val) {
  35. console.log('selected ' + val);
  36. }
  37. autoCompleteRenderCell(director, style) {
  38. return <div style={style.name}>director.name</div>
  39. }
  40. render() {
  41. const style = {
  42. list: {
  43. marginLeft: '5em',
  44. item: { name: { color: 'blue' } }
  45. }
  46. }
  47. <AutoComplete
  48. prefix="Search Board"
  49. data={directors}
  50. value=""
  51. style={style}
  52. autoCompleteValue={director => director.name}
  53. autoCompleteSearch={autoCompleteSearch}
  54. autoCompleteRenderCell={this.autoCompleteRenderCell}
  55. onChange={this.handleChange}
  56. underlined
  57. />
  58. }
  59. }
  60. export default App;