|
| 1 | +/** @jsx React.DOM */ |
| 2 | +var React = require('react') |
| 3 | +var BS = require('../cjs') |
| 4 | +var Button = BS.Button |
| 5 | +var DropdownButton = BS.DropdownButton |
| 6 | +var MenuItem = BS.MenuItem |
| 7 | +var Accordion = BS.Accordion |
| 8 | +var Panel = BS.Panel |
| 9 | +var ButtonToolbar = BS.ButtonToolbar |
| 10 | +var OverlayTrigger = BS.OverlayTrigger |
| 11 | +var Tooltip = BS.Tooltip |
| 12 | +var Alert = BS.Alert |
| 13 | +var TabbedArea = BS.TabbedArea |
| 14 | +var TabPane = BS.TabPane |
| 15 | +var Modal = BS.Modal |
| 16 | +var OverlayMixin = BS.OverlayMixin |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +var dropdownInstance = ( |
| 23 | + <DropdownButton title="Dropdown"> |
| 24 | + <MenuItem key="1">Item 1</MenuItem> |
| 25 | + <MenuItem key="2">Item 2</MenuItem> |
| 26 | + </DropdownButton> |
| 27 | +) |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +var accordionInstance = ( |
| 33 | + <Accordion> |
| 34 | + <Panel header="Collapsible Group Item #1" key={1}> |
| 35 | + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. |
| 36 | + </Panel> |
| 37 | + <Panel header="Collapsible Group Item #2" key={2}> |
| 38 | + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. |
| 39 | + </Panel> |
| 40 | + <Panel header="Collapsible Group Item #3" key={3}> |
| 41 | + Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS. |
| 42 | + </Panel> |
| 43 | + </Accordion> |
| 44 | +); |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +var positionerInstance = ( |
| 50 | + <ButtonToolbar> |
| 51 | + <OverlayTrigger placement="left" overlay={<Tooltip><strong>Holy guacamole!</strong> Check this info.</Tooltip>}> |
| 52 | + <Button bsStyle="default">Holy guacamole!</Button> |
| 53 | + </OverlayTrigger> |
| 54 | + <OverlayTrigger placement="top" overlay={<Tooltip><strong>Holy guacamole!</strong> Check this info.</Tooltip>}> |
| 55 | + <Button bsStyle="default">Holy guacamole!</Button> |
| 56 | + </OverlayTrigger> |
| 57 | + <OverlayTrigger placement="bottom" overlay={<Tooltip><strong>Holy guacamole!</strong> Check this info.</Tooltip>}> |
| 58 | + <Button bsStyle="default">Holy guacamole!</Button> |
| 59 | + </OverlayTrigger> |
| 60 | + <OverlayTrigger placement="right" overlay={<Tooltip><strong>Holy guacamole!</strong> Check this info.</Tooltip>}> |
| 61 | + <Button bsStyle="default">Holy guacamole!</Button> |
| 62 | + </OverlayTrigger> |
| 63 | + </ButtonToolbar> |
| 64 | +); |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +var tabbedAreaInstance = ( |
| 70 | + <TabbedArea defaultActiveKey={2}> |
| 71 | + <TabPane key={1} tab="Tab 1">TabPane 1 content</TabPane> |
| 72 | + <TabPane key={2} tab="Tab 2">TabPane 2 content</TabPane> |
| 73 | + </TabbedArea> |
| 74 | +); |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +var AlertAutoDismissable = React.createClass({ |
| 80 | + getInitialState: function() { |
| 81 | + return { |
| 82 | + alertVisible: false |
| 83 | + }; |
| 84 | + }, |
| 85 | + |
| 86 | + render: function() { |
| 87 | + if (this.state.alertVisible) { |
| 88 | + return ( |
| 89 | + <Alert bsStyle="danger" onDismiss={this.handleAlertDismiss} dismissAfter={2000}> |
| 90 | + <h4>Oh snap! You got an error!</h4> |
| 91 | + <p>But this will hide after 2 seconds.</p> |
| 92 | + </Alert> |
| 93 | + ); |
| 94 | + } |
| 95 | + |
| 96 | + return ( |
| 97 | + <Button onClick={this.handleAlertShow}>Show Alert</Button> |
| 98 | + ); |
| 99 | + }, |
| 100 | + |
| 101 | + handleAlertDismiss: function() { |
| 102 | + this.setState({alertVisible: false}); |
| 103 | + }, |
| 104 | + |
| 105 | + handleAlertShow: function() { |
| 106 | + this.setState({alertVisible: true}); |
| 107 | + } |
| 108 | +}); |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +var CustomModalTrigger = React.createClass({ |
| 114 | + mixins: [OverlayMixin], |
| 115 | + |
| 116 | + getInitialState: function () { |
| 117 | + return { |
| 118 | + isModalOpen: false |
| 119 | + }; |
| 120 | + }, |
| 121 | + |
| 122 | + handleToggle: function () { |
| 123 | + this.setState({ |
| 124 | + isModalOpen: !this.state.isModalOpen |
| 125 | + }); |
| 126 | + }, |
| 127 | + |
| 128 | + render: function () { |
| 129 | + return ( |
| 130 | + <Button onClick={this.handleToggle} bsStyle="primary">Launch</Button> |
| 131 | + ); |
| 132 | + }, |
| 133 | + |
| 134 | + // This is called by the `OverlayMixin` when this component |
| 135 | + // is mounted or updated and the return value is appended to the body. |
| 136 | + renderOverlay: function () { |
| 137 | + if (!this.state.isModalOpen) { |
| 138 | + return <span/>; |
| 139 | + } |
| 140 | + |
| 141 | + return ( |
| 142 | + <Modal title="Modal heading" onRequestHide={this.handleToggle}> |
| 143 | + <div className="modal-body"> |
| 144 | + This modal is controlled by our custom trigger component. |
| 145 | + </div> |
| 146 | + <div className="modal-footer"> |
| 147 | + <Button onClick={this.handleToggle}>Close</Button> |
| 148 | + </div> |
| 149 | + </Modal> |
| 150 | + ); |
| 151 | + } |
| 152 | +}); |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | +var allTests = ( |
| 158 | + <div> |
| 159 | + <h2>Dropdown</h2> |
| 160 | + {dropdownInstance} |
| 161 | + |
| 162 | + <h2>Tooltips</h2> |
| 163 | + {positionerInstance} |
| 164 | + |
| 165 | + <h2>Tabs</h2> |
| 166 | + {tabbedAreaInstance} |
| 167 | + |
| 168 | + <h2>Alert</h2> |
| 169 | + <AlertAutoDismissable /> |
| 170 | + |
| 171 | + <h2>Modal</h2> |
| 172 | + <CustomModalTrigger /> |
| 173 | + |
| 174 | + </div> |
| 175 | +) |
| 176 | + |
| 177 | +React.renderComponent(allTests, document.body) |
0 commit comments