From dbb36a255803a2c49bfd9e4fc97f1b216a91266f Mon Sep 17 00:00:00 2001
From: Jimmy Jia First add the Bootstrap CSS to your project; check here if you have not already done that. Note that: Then: The bower repo contains If you do not use JSX and just call components as functions, you must explicitly create a factory before calling it. React-bootstrap provides factories for you in jQuery is currently required only for IE8 support for components which require reading element positions from the DOM:
+
+ );
+ }
+
+ componentDidMount() {
+ if (CodeMirror === undefined) {
+ return;
+ }
+
+ CodeMirror.runMode(
+ this.props.codeText,
+ this.props.mode,
+ React.findDOMNode(this).children[0]
+ );
+ }
+}
diff --git a/docs/src/CodeMirrorWrapper.client.js b/docs/src/CodeMirrorWrapper.client.js
deleted file mode 100644
index 7bca46333a..0000000000
--- a/docs/src/CodeMirrorWrapper.client.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import CodeMirror from 'codemirror';
-import 'codemirror/mode/javascript/javascript';
-
-import 'codemirror/theme/solarized.css';
-import 'codemirror/lib/codemirror.css';
-import './CodeMirrorWrapper.css';
-
-export default {
- IS_NODE: false,
- CodeMirror
-};
diff --git a/docs/src/CodeMirrorWrapper.js b/docs/src/CodeMirrorWrapper.js
deleted file mode 100644
index 1639c02d51..0000000000
--- a/docs/src/CodeMirrorWrapper.js
+++ /dev/null
@@ -1,4 +0,0 @@
-export default {
- IS_NODE: true,
- CodeMirror: {}
-};
diff --git a/docs/src/GettingStartedPage.js b/docs/src/GettingStartedPage.js
index 1d2852450d..f19af4f741 100644
--- a/docs/src/GettingStartedPage.js
+++ b/docs/src/GettingStartedPage.js
@@ -1,10 +1,11 @@
import React from 'react';
+import CodeExample from './CodeExample';
import NavMain from './NavMain';
import PageHeader from './PageHeader';
import PageFooter from './PageFooter';
-const Page = React.createClass({
+export default class Page extends React.Component {
render() {
return (
+ {this.props.codeText}
+
+
-
CommonJS
- {`
- $ npm install react
- $ npm install react-bootstrap
- `}
+ {`
- var Alert = require('react-bootstrap/lib/Alert');
- // or
- var Alert = require('react-bootstrap').Alert;
- `}
+ AMD
- {`
- $ bower install react
- $ bower install react-bootstrap
- `}
+ {`
- define(['react-bootstrap/lib/Alert'], function(Alert) { ... });
- // or
- define(['react-bootstrap'], function(ReactBootstrap) { var Alert = ReactBootstrap.Alert; ... });
- `}
+ Browser globals
react-bootstrap.js
and react-bootstrap.min.js
with all components exported in the window.ReactBootstrap
object.
+ {`
-
-
-
- `}
Without JSX
lib/factories
:
+ {`
- var Alert = require('react-bootstrap/lib/factories').Alert;
- // or
- var Alert = require('react-bootstrap/lib/factories/Alert');
- `}
Popover
and Tooltip
when launched with OverlayTrigger
. We would like to remove this dependency in future versions but for now, including the following snippet in your page should have you covered:
+ {`
-
- `}
{`
-button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)
- `}
+ @@ -43,11 +47,14 @@ button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)
{`
-
- `}
+`
+ }
+ />
@@ -65,11 +72,14 @@ button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)
{`
-
- `}
+`
+ }
+ />
@@ -101,14 +111,17 @@ button(size=SMALL, color=GREEN, text="Something", onClick=someCallback)
{`
-var button = React.DOM.button({
+
+React.render(button, mountNode);`
+ }
+ />
@@ -117,15 +130,18 @@ React.render(button, mountNode);
{`
-var button = ReactBootstrap.Button({
+
+React.render(button, mountNode);`
+ }
+ />
@@ -144,8 +160,10 @@ React.render(button, mountNode);
{`
-var buttonGroupInstance = (
+
@@ -156,8 +174,9 @@ var buttonGroupInstance = (
);
-React.render(buttonGroupInstance, mountNode);
- `}
+React.render(buttonGroupInstance, mountNode);`
+ }
+ />
diff --git a/docs/src/ReactPlayground.js b/docs/src/ReactPlayground.js index 4a4983b048..6beada4323 100644 --- a/docs/src/ReactPlayground.js +++ b/docs/src/ReactPlayground.js @@ -46,6 +46,8 @@ import * as modWell from '../../src/Well'; import babel from 'babel-core/browser'; +import CodeExample from './CodeExample'; + const classNames = modClassNames.default; /* eslint-disable */ const React = modReact.default; @@ -104,7 +106,7 @@ const IS_MOBILE = typeof navigator !== 'undefined' && ( || navigator.userAgent.match(/Windows Phone/i) ); -const CodeMirrorEditor = React.createClass({ +class CodeMirrorEditor extends React.Component { componentDidMount() { if (IS_MOBILE || CodeMirror === undefined) { return; @@ -120,19 +122,19 @@ const CodeMirrorEditor = React.createClass({ readOnly: this.props.readOnly }); this.editor.on('change', this.handleChange); - }, + } componentDidUpdate() { if (this.props.readOnly) { this.editor.setValue(this.props.codeText); } - }, + } handleChange() { if (!this.props.readOnly && this.props.onChange) { this.props.onChange(this.editor.getValue()); } - }, + } render() { // wrap in a div to fully contain CodeMirror @@ -140,7 +142,12 @@ const CodeMirrorEditor = React.createClass({ if (IS_MOBILE) { let preStyles = {overflow: 'scroll'}; - editor =
{this.props.codeText}; + editor = ( +