Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(getting-started): update readme.md and bootstrap.md files #3933

Merged
merged 10 commits into from Apr 5, 2018
77 changes: 51 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,51 @@ Best way to quickly integrate <a href="https://getbootstrap.com/">Bootstrap 3</a
4. [API](#api)
5. [Troubleshooting](#troubleshooting)
6. [Contributing](#contribution)
7. [License](#license)

# Getting Started
## Getting Started

ngx-bootstrap contains all core (and not only) Bootstrap components powered by Angular. So you don't need to include original JS components, but we are using markup and css provided by Bootstrap.

# Installation instructions
## Installation instructions

Install `ngx-bootstrap` from `npm`
Install `ngx-bootstrap` from `npm`:
```bash
npm install ngx-bootstrap --save
```

You will need bootstrap styles (Bootstrap 3)
Add needed package to NgModule imports:
```
import { TooltipModule } from 'ngx-bootstrap/tooltip';

@NgModule({
...
imports: [TooltipModule.forRoot(),...]
...
})
```

Add component to your page:
```
<button type="button" class="btn btn-primary"
tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Simple demo
</button>
```

You will need bootstrap styles:
- `Bootstrap 3`
```
<!-- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
```

Or Bootstrap 4
- `Bootstrap 4`
```
<!--- index.html -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
```
To enable bootstrap 4 theme templates in ngx-bootstrap, please read
[this](https://github.com/valor-software/ngx-bootstrap/blob/development/docs/getting-started/bootstrap4.md) .

# Usage & Demo
## Usage & Demo

Main source of API documentation and usage scenarios available here:
[https://valor-software.com/ngx-bootstrap/](https://valor-software.com/ngx-bootstrap/)
Expand All @@ -73,36 +89,41 @@ Additionally you can find demos and docs deployed from latest code with <a href=

Server side rendered version of this documentation available <a href="https://ngx-universal.herokuapp.com/">here</a>

# API
## API
Check demo page for API [reference](https://valor-software.com/ngx-bootstrap/)

## How to use it with:
- `angular-cli` please refer to [getting-started-with-ng-cli](https://github.com/valor-software/ngx-bootstrap/tree/development/docs/getting-started/ng-cli.md)
### How to use it with:
- `Bootstrap and angular-cli` please refer to [using-with-bootstrap-and-angular-cli](https://github.com/valor-software/ngx-bootstrap/tree/development/docs/getting-started/bootstrap.md)
- `angular-seed` please refer to [getting-started-with-angular-seed](https://github.com/valor-software/ngx-bootstrap/tree/development/docs/getting-started/angular-seed.md)
- `system.js` (and [angular2 quickstart](https://angular.io/docs/ts/latest/quickstart.html)) please checkout [sample repository](https://github.com/valor-software/angular2-quickstart)
- `plnkr` sample available [here](http://bit.ly/ngx-bootstrap-plnkr)
- `plnkr` sample available [here](https://plnkr.co/edit/0NipkZrnckZZROAcnjzB?p=preview)
- `AoT using ngc and rollup` please refer to [ngx-bootstrap-with-aot](https://github.com/valor-software/ngx-bootstrap/tree/development/docs/getting-started/aot.md)
- `Bootstrap 4 and angular-cli` please refer to [using-with-bootstrap-4-and-angular-cli](https://github.com/valor-software/ngx-bootstrap/tree/development/docs/getting-started/bootstrap4.md)
- `ASP.NET Core 2.0` please refer to [using-with-asp.net-core-2](https://github.com/csegyud/ASPNETCore_ngx-bootstrap_Sample/blob/master/README.md)

# How to build lib for development
### How to build lib for development

First time
First time:
- clone repository
- `npm install`
- `npm run test` it will build the lib and create a link in `node_modules`
- `npm run test`

To update your fork and prepare it for local usage:
- `git pull upstream development`
- `rm -rf node_modules`
- `npm install`
- `npm run test` _*// it will build the lib, create a link in node_modules and run package's "test" script*_

To run bootstrap 3 and 4 demo:
- `npm run demo.serve` to serve local demo. This is for testing only, without watchers.
To run the demo:
- `npm run demo.serve` _*// to serve local demo. This is for testing only, without watchers.*_

For local development run
- `npm run build.watch` in first terminal
- `ng serve` in second
For local development run:
- `npm run build.watch` _*// in first terminal*_
- `ng serve` _*// in second*_

If you want to run the demo with Angular Universal:
- `npm run demo.serve-universal`

# Troubleshooting
## Troubleshooting

So if you are in trouble, here's where you can look for help.

Expand All @@ -111,16 +132,20 @@ You can also join [our Slack channel](https://ngx-slack.herokuapp.com/) and link

If, **and only if**, none of the above helped, please open a [new issue](https://github.com/valor-software/ngx-bootstrap/issues/new).

# Contribution
## Contribution

Are very welcome! And remember, contribution is not only PRs and code, but any help with docs or helping other developers to solve issues are very appreciated! Thanks in advance!

Please read our [contribution guidelines](https://github.com/valor-software/ngx-bootstrap/blob/development/CONTRIBUTING.md).

## If you need more modules check [here](https://github.com/valor-software/ng2-plans)
### If you need more modules check [here](https://github.com/valor-software/ng2-plans)

Please read central `ngx` modules [readme](https://github.com/valor-software/ng2-plans) for details, plans and approach

## Credits
### Credits
Crossbrowser testing sponsored by [Browser Stack](https://www.browserstack.com)
[<img src="https://camo.githubusercontent.com/a7b268f2785656ab3ca7b1cbb1633ee5affceb8f/68747470733a2f2f64677a6f7139623561736a67312e636c6f756466726f6e742e6e65742f70726f64756374696f6e2f696d616765732f6c61796f75742f6c6f676f2d6865616465722e706e67" alt="Browser Stack" height="31px" style="background: cornflowerblue;">](https://www.browserstack.com)

### License

MIT
127 changes: 127 additions & 0 deletions docs/getting-started/bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Using with Bootstrap and angular-cli

This is extracted from the [angular-cli include bootstrap story](https://github.com/angular/angular-cli/wiki/stories-include-bootstrap) and demonstates one way to accomplish using Bootstrap 3 or 4 with ngx-bootstrap. The `Bootstrap's` version is defined automatically by the `ngx-bootstrap`.

## Installing angular-cli

*Recommended*: to use latest stable `angular-cli` version.

*Note*: You can skip this part if you already have application generated by `ng-cli` and webpack.

```bash
npm i -g @angular/cli
ng new my-app
cd my-app
ng serve
```

## Adding ngx-bootstrap and Bootstrap

- install `ngx-bootstrap` and `Bootstrap`

```bash
npm install ngx-bootstrap bootstrap --save
```

## Using with css
### Configuring Project

Now that the project is set up it must be configured to include the Bootstrap CSS. You have two options:

- add styles to .angular-cli.json:
- Open the file .angular-cli.json from the root of your project.
- Under the property apps the first item in that array is the default application.
- There is a property styles which allows external global styles to be applied to your application.

- Specify the path to bootstrap.min.css

It should look like the following when you are done:
```
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
```

Note: When you make changes to .angular-cli.json you will need to re-start ng serve to pick up configuration changes.

- add styles to index.html:
- for Bootstrap 3:
```
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
```

- or for Bootstrap 4:
```
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
```

## Using SASS

### Configuring Project

Ensure that the project is set up to use scss by default and that the main styles file is styles.scss

The easiest way to do this is when creating a new project by
```bash
ng new my-app --style=scss
cd my-app
```

If the project has already been created then

- rename `src/styles.css` to `src/styles.scss`
- in `.angular-cli.json` make the following changes
```
"styles": [
"styles.css" <-- rename this from .css to .scss
],
.
.
.
"defaults": {
"styleExt": "css" <-- set this to default to .scss
}
```
Create an empty file `_variables.scss` in `src/`.

In `styles.scss` add the following:

```
@import 'variables';
@import '../node_modules/bootstrap/scss/bootstrap';
```

## Checkout

Open `src/app/app.module.ts` and add

```typescript
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
...

@NgModule({
...
imports: [BsDropdownModule.forRoot(), ... ],
...
})
```

- open `src/app/app.component.html` and add
```
<div class="btn-group" dropdown>
<button dropdownToggle type="button" class="btn btn-primary dropdown-toggle">
Button dropdown <span class="caret"></span>
</button>
<ul *dropdownMenu class="dropdown-menu" role="menu">
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a>
</li>
</ul>
</div>
```

run the app in demo mode and ensure the dropdown button functions correctly.
123 changes: 0 additions & 123 deletions docs/getting-started/bootstrap4.md

This file was deleted.