Skip to content

Commit

Permalink
[changed] Replace everything with LinkContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Sep 15, 2015
1 parent 888fc56 commit ac500c8
Show file tree
Hide file tree
Showing 47 changed files with 639 additions and 1,805 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

38 changes: 2 additions & 36 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
{
"extends": ["eslint-config-airbnb"],
"env": {
"browser": true,
"node": true
},
"ecmaFeatures": {
"jsx": true
},
"parser": "babel-eslint",
"plugins": [
"react",
"babel"
],
"extends": "airbnb",
"rules": {
"comma-dangle": 0,
"comma-spacing": 1,
"key-spacing": 0,
"no-eq-null": 0,
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"no-undef": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-var": 2,
"babel/object-shorthand": 2,
"quotes": [1, "single", "avoid-escape"],
"react/display-name": 0,
"react/jsx-no-undef": 2,
"react/jsx-quotes": 0,
"react/jsx-uses-react": 2,
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/no-multi-comp": 2,
"react/prop-types": [1, { "ignore": ["children", "className"] }],
"react/react-in-jsx-scope": 2,
"react/self-closing-comp": 1,
"react/wrap-multilines": 2,
"react/jsx-uses-vars": 1,
"strict": 0
"no-eq-null": 0
}
}
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

As part of the react-bootstrap organization all contributing guidelines can be
found at:
https://github.com/react-bootstrap/react-bootstrap/blob/master/CONTRIBUTING.md
As part of the react-bootstrap organization all contributing guidelines can be found at: https://github.com/react-bootstrap/react-bootstrap/blob/master/CONTRIBUTING.md.

Note that automated changelog generation has not been setup on this repo yet.
Use `npm run visual-test` to check the appearance of components in your browser. The page will load at [http://localhost:8080/](http://localhost:8080/).

Note that automated changelog generation has not been set up on this repo yet.
120 changes: 13 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,127 +1,33 @@
# react-router-bootstrap
Integration between [React Router](https://github.com/rackt/react-router) and [React-Bootstrap](https://github.com/react-bootstrap/react-bootstrap).

[![Build Status](https://travis-ci.org/react-bootstrap/react-router-bootstrap.svg?branch=master)](https://travis-ci.org/react-bootstrap/react-router-bootstrap)
[![npm version](https://badge.fury.io/js/react-router-bootstrap.svg)](http://badge.fury.io/js/react-router-bootstrap)

Intregation between [react-router](https://github.com/rackt/react-router) and [react-bootstrap](https://github.com/react-bootstrap/react-bootstrap)

This package gives you react-router compatible substitutes for:

- `NavItem` -> `NavItemLink`
- `Button` -> `ButtonLink`
- `MenuItem` -> `MenuItemLink`
- `ListGroupItem` -> `ListGroupItemLink`
- `PageItem` -> `PageItemLink`
- `Thumbnail` -> `ThumbnailLink`

Turning this:
## Usage

```jsx
React.createClass({
mixins: [State, Navigation],
Wrap your React-Bootstrap element in a `LinkContainer` to make it behave like a React Router `Link`:

render: function() {
var href = this.makeHref('destination', {some: 'params'}, {some: 'query param'});
var isActive = this.isActive('destination', {some: 'params'}, {some: 'query param'});
return <Button href={href} active={isActive}>;
}
});
```js
<LinkContainer to="/foo" query={{bar: "baz"}}>
<Button>Foo</Button>
</LinkContainer>
```

Into this

```jsx
React.createClass({
render: function() {
return <ButtonLink to="destination" params={{ some: 'params' }} query={{some: 'query param'}}>;
}
});
```
To disable the element and the link, set the `disabled` prop on the `LinkContainer`. For the equivalent of `IndexLink`, use `IndexLinkContainer`.

## Installation

```
npm install --save react-router-bootstrap
npm install react-router-bootstrap
```

You will also (if you haven't already) want to install `react-router` and `react-bootstrap`
You will also want to have React Router and React-Bootstrap.

```
npm install --save react-router react-bootstrap
```

## Usage

A simple example

```jsx
var Router = require('react-router')
, RouteHandler = Router.RouteHandler
, Route = Router.Route;

var ReactBootstrap = require('react-bootstrap')
, Nav = ReactBootstrap.Nav
, ListGroup = ReactBootstrap.ListGroup;

var ReactRouterBootstrap = require('react-router-bootstrap')
, NavItemLink = ReactRouterBootstrap.NavItemLink
, ButtonLink = ReactRouterBootstrap.ButtonLink
, ListGroupItemLink = ReactRouterBootstrap.ListGroupItemLink;

var App = React.createClass({
render: function() {
return (
<div>
NavItemLink<br />
<Nav>
<NavItemLink
to="destination"
params={{ someparam: 'hello' }}>
Linky!
</NavItemLink>
</Nav>
<br />
ButtonLink<br />
<ButtonLink
to="destination"
params={{ someparam: 'hello' }}>
Linky!
</ButtonLink>
<br />
<ListGroup>
<ListGroupItemLink
to="destination"
params={{ someparam: 'hello' }}>
Linky!
</ListGroupItemLink>
</ListGroup>
<RouteHandler />
</div>
);
}
});

var Destination = React.createClass({
render: function() {
return <div>You made it!</div>;
}
});

var routes = (
<Route handler={App} path="/">
<Route name="destination" path="destination/:someparam" handler={Destination} />
</Route>
);

Router.run(routes, function (Handler) {
React.render(<Handler/>, document.body);
});

npm install react-router react-bootstrap
```

## Contributing

See [CONTRIBUTING](CONTRIBUTING.md)

Use `npm run visual-test` command to check components appearance in browser. It will open browser with a blank page. Then after `webpack-server` finishes its bundling, the browser automatically will refresh the page.

URL for it: http://localhost:8080/public/visual#/
See [CONTRIBUTING](CONTRIBUTING.md).
Binary file removed assets/thumbnail.png
Binary file not shown.
20 changes: 11 additions & 9 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ delete webpackConfig.entry;

module.exports = function (config) {
config.set({

basePath: '',

frameworks: [ 'mocha' ],
frameworks: [
'mocha',
'sinon-chai'
],

files: [
'./tests/index.js'
],

exclude: [],

preprocessors: {
'./tests/index.js': [ 'webpack' ]
'./tests/index.js': ['webpack', 'sourcemap']
},

webpack: [ webpackConfig ],
webpack: webpackConfig,

webpackMiddleware: { },
webpackMiddleware: {
noInfo: true
},

reporters: [ 'mocha' ],
reporters: ['mocha'],

port: 9876,

Expand All @@ -33,7 +35,7 @@ module.exports = function (config) {

autoWatch: true,

browsers: [ 'PhantomJS' ],
browsers: ['PhantomJS'],

captureTimeout: 60000,
browserDisconnectTimeout: 7000,
Expand Down
80 changes: 41 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
{
"name": "react-router-bootstrap",
"version": "0.18.1",
"description": "react-router and react-bootstrap compatible components",
"description": "Integration between React Router and React-Bootstrap",
"main": "./lib/index.js",
"scripts": {
"prepublish": "npm run build",
"build": "babel src --out-dir=lib && webpack && COMPRESS=1 webpack && npm run bower-prepare",
"build": "babel src --out-dir=lib && webpack && webpack -p",
"test": "npm run lint && karma start --single-run",
"tdd": "karma start",
"visual-test": "open http://localhost:8080/public/visual#/ && webpack-dev-server --config webpack.test.config.babel.js",
"lint": "eslint ./",
"bower-prepare": "babel-node scripts/bower-prepare.js",
"patch": "release patch",
"minor": "release minor",
"major": "release major"
"visual-test": "open http://localhost:8080/ && webpack-dev-server --config webpack.visual.config.babel.js",
"lint": "eslint *.babel.js src tests",
"release": "release"
},
"repository": {
"type": "git",
Expand All @@ -34,48 +31,53 @@
},
"homepage": "https://github.com/react-bootstrap/react-router-bootstrap",
"peerDependencies": {
"react-bootstrap": ">=0.22.4",
"react-router": ">=0.13.1"
"react": ">=0.13.0 || >=0.14.0-rc1",
"react-router": ">=1.0.0-rc1"
},
"devDependencies": {
"babel": "^5.5.6",
"babel-core": "^5.5.6",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.1.4",
"bootstrap": "^3.3.1",
"chai": "^3.0.0",
"colors": "^1.1.2",
"css-loader": "^0.15.3",
"eslint": "^1.0.0",
"eslint-config-airbnb": "0.0.7",
"eslint-plugin-babel": "^1.0.0",
"eslint-plugin-mocha": "^0.4.0",
"eslint-plugin-react": "^3.1.0",
"karma": "^0.13.3",
"babel": "^5.8.23",
"babel-core": "^5.8.24",
"babel-eslint": "^4.1.2",
"babel-loader": "^5.3.2",
"bootstrap": "^3.3.5",
"css-loader": "^0.18.0",
"es5-shim": "^4.1.13",
"eslint": "1.3.x",
"eslint-config-airbnb": "0.0.8",
"eslint-plugin-babel": "^2.1.1",
"eslint-plugin-mocha": "^0.5.1",
"eslint-plugin-react": "^3.3.2",
"file-loader": "^0.8.4",
"history": "^1.9.1",
"html-webpack-plugin": "^1.6.1",
"karma": "^0.13.9",
"karma-cli": "^0.1.0",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.0.2",
"karma-phantomjs-launcher": "^0.2.0",
"karma-webpack": "^1.5.0",
"karma-mocha-reporter": "^1.1.1",
"karma-phantomjs-launcher": "^0.2.1",
"karma-sinon-chai": "^1.1.0",
"karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0",
"less": "^2.5.1",
"less-loader": "^2.2.0",
"lodash": "^3.10.0",
"mocha": "^2.1.0",
"mt-changelog": "^0.6.1",
"mocha": "^2.3.2",
"mt-changelog": "^0.6.2",
"node-libs-browser": "^0.5.2",
"phantomjs": "^1.9.13",
"react": ">0.10.0",
"react-bootstrap": ">=0.22.4",
"react-router": ">=0.13.1",
"release-script": "^0.2.1",
"shelljs": "^0.5.1",
"phantomjs": "^1.9.18",
"react": "^0.14.0-rc1",
"react-bootstrap": "^0.25.100-react-pre.1",
"react-dom": "^0.14.0-rc1",
"react-router": "^1.0.0-rc1",
"release-script": "^0.2.7",
"style-loader": "^0.12.3",
"url-loader": "^0.5.6",
"webpack": "^1.4.15",
"webpack-dev-server": "^1.7.0",
"yargs": "^3.15.0"
"webpack": "^1.12.1",
"webpack-dev-server": "^1.10.1",
"yargs": "^3.25.0"
},
"files": [
"README",
"CHANGELOG.md",
"lib"
],
"release-script": {
Expand Down
Loading

0 comments on commit ac500c8

Please sign in to comment.