Skip to content

Commit 40f0c2d

Browse files
authored
Merge pull request #15 from cal-smith/master
chore(readme): update readme to make getting started more useful
2 parents a931e13 + dd0b151 commit 40f0c2d

File tree

3 files changed

+59
-15
lines changed

3 files changed

+59
-15
lines changed

.storybook/bootstrap.module.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from "@angular/core";
2+
import { TranslateModule, TranslateService } from "@ngx-translate/core";
3+
const en = require("./../src/i18n/en.json");
4+
5+
@NgModule({
6+
imports: [
7+
TranslateModule.forRoot()
8+
]
9+
})
10+
export class BootstrapModule {
11+
constructor(private translateService: TranslateService) {
12+
this.translateService.setDefaultLang("en");
13+
this.translateService.use("en");
14+
this.translateService.setTranslation("en", en);
15+
}
16+
}

README.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,51 @@ An _Angular_ implementation of the Carbon Design System
33

44
### Getting started
55

6-
```
7-
$ npx @angular/cli new my-project
6+
Assuming we're starting with a new @angular/cli project:
7+
8+
```shell
9+
$ npx @angular/cli new my-project --style=scss
810
$ cd my-project
9-
$ npm i carbon-components-angular carbon-components
10-
$ # include carbon css
11-
$ # import components
12-
$ npm start
11+
$ npm i --save-dev carbon-components-angular carbon-components @ngx-translate/core
12+
```
13+
14+
Then we need to include carbon-components in `src/styles.scss`:
15+
16+
```scss
17+
@import "~carbon-components/scss/globals/scss/styles.scss";
18+
```
19+
20+
And set up our translations in `src/app/app.module.ts`:
21+
22+
```ts
23+
import { BrowserModule } from '@angular/platform-browser';
24+
import { NgModule } from '@angular/core';
25+
import { TranslateModule } from '@ngx-translate/core';
26+
27+
import { AppComponent } from './app.component';
28+
29+
@NgModule({
30+
declarations: [
31+
AppComponent
32+
],
33+
imports: [
34+
BrowserModule,
35+
TranslateModule.forRoot()
36+
],
37+
providers: [],
38+
bootstrap: [AppComponent]
39+
})
40+
export class AppModule { }
1341
```
1442

15-
#### Bundler
43+
_Finally_ we can run `npm start` and start building out our application!
1644

17-
Your project should use a module bundler - we recommend [webpack](https://webpack.js.org/).
45+
> *Note:* This isn't the only way to bootstrap a `carbon-components-angular` application, but the combination of `@angular/cli` and the `carbon-components` scss is our recommended setup.
1846
1947
### Contributing
2048

2149
#### Quickstart
22-
- fork ibm/carbon-components-angular and clone it locally
50+
- fork IBM/carbon-components-angular and clone it locally
2351
- run `npm install` to grab all the dependencies, then `npm run storybook` to start storybook
2452
- **if you are adding a component**:
2553
- add a folder with your component code, styles, tests and story under `src`
@@ -29,7 +57,6 @@ Your project should use a module bundler - we recommend [webpack](https://webpac
2957
- consider adding or modifying a test case to cover the fix
3058
- follow the [Angular style guide](https://angular.io/styleguide)
3159
- be sure to run `npm test` and `npm run lint` to make sure the tests and linter pass
32-
- DO NOT change the version number.
3360
- submit a PR
3461

3562
#### Pull request guidelines
@@ -69,8 +96,8 @@ To keep our build dependancies local we use npm scripts to run our webpack, gulp
6996
- `npm test` to run tests
7097

7198
### Resources
72-
- [Style guide (WIP)](#)
73-
- [General component API guidelines (WIP)](#)
99+
- [Style guide (WIP)](https://github.com/IBM/carbon-components-angular/wiki/Style-guide)
100+
- [General component API guidelines (WIP)](https://github.com/IBM/carbon-components-angular/wiki/Component-API-guidelines)
74101
- [Angular style guide](https://angular.io/styleguide)
75102
- [I18N tooling](https://angular.io/docs/ts/latest/cookbook/i18n.html)
76103
- (Angular 2+ doesn't have anything like ngAria, instead here's [The A11Y Project](http://a11yproject.com/), [WAI-ARIA specs](https://www.w3.org/TR/wai-aria/), and [WAI-ARIA Authoring Practices](https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/))

src/dropdown/dropdown.stories.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import { withNotes } from "@storybook/addon-notes";
33
import { action } from "@storybook/addon-actions";
44
import { withKnobs, boolean, object } from "@storybook/addon-knobs/angular";
55

6-
import { TranslateModule } from "@ngx-translate/core";
7-
86
import { DropdownModule } from "../";
97

8+
// needed to init ngx translate and load the translations
9+
import { BootstrapModule } from "../../.storybook/bootstrap.module";
10+
1011
storiesOf("Dropdown", module)
1112
.addDecorator(
1213
moduleMetadata({
1314
imports: [
1415
DropdownModule,
15-
TranslateModule.forRoot()
16+
BootstrapModule
1617
],
1718
})
1819
)

0 commit comments

Comments
 (0)