|
| 1 | +/* eslint react/no-multi-comp: 0, react/prop-types: 0 */ |
| 2 | +import React from 'react'; |
| 3 | +import { PrismCode } from 'react-prism'; |
| 4 | +import Helmet from 'react-helmet'; |
| 5 | +import OverviewExample from '../examples/InputGroupOverview'; |
| 6 | +const OverviewExampleSource = require('!!raw!../examples/InputGroupOverview.jsx'); |
| 7 | +import AddonExample from '../examples/InputGroupAddon'; |
| 8 | +const AddonExampleSource = require('!!raw!../examples/InputGroupAddon.jsx'); |
| 9 | +import AddonSizingExample from '../examples/InputGroupSizing'; |
| 10 | +const AddonSizingExampleSource = require('!!raw!../examples/InputGroupSizing.jsx'); |
| 11 | +import ButtonExample from '../examples/InputGroupButton'; |
| 12 | +const ButtonExampleSource = require('!!raw!../examples/InputGroupButton.jsx'); |
| 13 | +import ButtonShorthandExample from '../examples/InputGroupButtonShorthand'; |
| 14 | +const ButtonShorthandExampleSource = require('!!raw!../examples/InputGroupButtonShorthand.jsx'); |
| 15 | + |
| 16 | +export default class InputGroupPage extends React.Component { |
| 17 | + constructor(props) { |
| 18 | + super(props); |
| 19 | + |
| 20 | + this.toggle = this.toggle.bind(this); |
| 21 | + this.state = { |
| 22 | + dropdownOpen: false |
| 23 | + }; |
| 24 | + } |
| 25 | + |
| 26 | + toggle() { |
| 27 | + this.setState({ |
| 28 | + dropdownOpen: !this.state.dropdownOpen |
| 29 | + }); |
| 30 | + } |
| 31 | + |
| 32 | + render() { |
| 33 | + return ( |
| 34 | + <div> |
| 35 | + <Helmet title="Input Group" /> |
| 36 | + <h3>Input Group</h3> |
| 37 | + <div className="docs-example"> |
| 38 | + <OverviewExample /> |
| 39 | + </div> |
| 40 | + <pre> |
| 41 | + <PrismCode className="language-jsx"> |
| 42 | + {OverviewExampleSource} |
| 43 | + </PrismCode> |
| 44 | + </pre> |
| 45 | + <h4>Properties</h4> |
| 46 | + <pre> |
| 47 | + <PrismCode className="language-jsx"> |
| 48 | +{`InputGroup.propTypes = { |
| 49 | + tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), |
| 50 | + size: PropTypes.string, |
| 51 | + className: PropTypes.any |
| 52 | +}; |
| 53 | +
|
| 54 | +InputGroupAddOn.propTypes = { |
| 55 | + tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), |
| 56 | + className: PropTypes.any |
| 57 | +}; |
| 58 | +
|
| 59 | +InputGroupButton.propTypes = { |
| 60 | + tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), |
| 61 | + children: PropTypes.node, |
| 62 | + groupClassName: PropTypes.any, // only used in shorthand |
| 63 | + groupAttributes: PropTypes.object, // only used in shorthand |
| 64 | + className: PropTypes.any |
| 65 | +};`} |
| 66 | + </PrismCode> |
| 67 | + </pre> |
| 68 | + <h3>Addons</h3> |
| 69 | + <div className="docs-example"> |
| 70 | + <div> |
| 71 | + <AddonExample /> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + <pre> |
| 75 | + <PrismCode className="language-jsx"> |
| 76 | + {AddonExampleSource} |
| 77 | + </PrismCode> |
| 78 | + </pre> |
| 79 | + |
| 80 | + <h3>Addon Sizing</h3> |
| 81 | + <div className="docs-example"> |
| 82 | + <div> |
| 83 | + <AddonSizingExample /> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + <pre> |
| 87 | + <PrismCode className="language-jsx"> |
| 88 | + {AddonSizingExampleSource} |
| 89 | + </PrismCode> |
| 90 | + </pre> |
| 91 | + |
| 92 | + <h3>Buttons / Dropdowns</h3> |
| 93 | + <div className="docs-example"> |
| 94 | + <div> |
| 95 | + <ButtonExample /> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + <pre> |
| 99 | + <PrismCode className="language-jsx"> |
| 100 | + {ButtonExampleSource} |
| 101 | + </PrismCode> |
| 102 | + </pre> |
| 103 | + |
| 104 | + <h3>Button Shorthand</h3> |
| 105 | + <p> |
| 106 | + Button shorthand is a convenience method for adding just a button. It is triggered when only a single string |
| 107 | + is the child. A Button will be created and all of the props will be passed to it with the exception of |
| 108 | + <code>groupClassName</code> and <code>groupAttributes</code>, which are used to added classes and attributes |
| 109 | + to the wrapping container. This means you can add your <code>onClick</code> and other handlers directly to |
| 110 | + <code>InputGroupButton</code>. If you want your string to not be wrapped in a button, then you really want to |
| 111 | + use <code>InputGroupAddon</code> (see Addons above for that). |
| 112 | + </p> |
| 113 | + <div className="docs-example"> |
| 114 | + <div> |
| 115 | + <ButtonShorthandExample /> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | + <pre> |
| 119 | + <PrismCode className="language-jsx"> |
| 120 | + {ButtonShorthandExampleSource} |
| 121 | + </PrismCode> |
| 122 | + </pre> |
| 123 | + </div> |
| 124 | + ); |
| 125 | + } |
| 126 | +} |
0 commit comments