|
| 1 | +<p align="center"> |
| 2 | + <img height="256px" width="256px" style="text-align: center;" src="https://cdn.rawgit.com/anthonynahas/ngx-material-faq/master/demo/src/assets/logo.svg"> |
| 3 | +</p> |
| 4 | + |
| 5 | +# ngx-material-faq - Angular Library built with material design in order to provide a reusable faq (frequently asked questions) component for every project. Ask, Answer and List |
| 6 | + |
| 7 | +[](https://badge.fury.io/js/ngx-material-faq), |
| 8 | +[](https://anthonynahas.github.io/ngx-material-faq) |
| 9 | +[](https://coveralls.io/github/anthonynahas/ngx-material-faq?branch=master) |
| 10 | +[](https://coveralls.io/github/anthonynahas/ngx-material-faq?branch=master) |
| 11 | +[](https://david-dm.org/anthonynahas/ngx-material-faq) |
| 12 | +[](https://david-dm.org/anthonynahas/ngx-material-faq#info=devDependencies) |
| 13 | +[](https://greenkeeper.io/) |
| 14 | +[](https://github.com/AnthonyNahas/ngx-material-faq/blob/master/LICENSE) |
| 15 | + |
| 16 | + |
| 17 | +<p align="center"> |
| 18 | + <img alt="ngx-material-faq" style="text-align: center;" |
| 19 | + src="assets/demo.gif"> |
| 20 | +</p> |
| 21 | + |
| 22 | + |
| 23 | +## Demo |
| 24 | + |
| 25 | +View all the directives in action at https://anthonynahas.github.io/ngx-material-faq |
| 26 | + |
| 27 | +## Dependencies |
| 28 | +* [Angular](https://angular.io) (*requires* Angular 2 or higher, tested with 2.0.0) |
| 29 | + |
| 30 | +### Requirements (peer dependencies): |
| 31 | +- [angular flex-layout ](https://www.npmjs.com/package/@angular/flex-layout) |
| 32 | +- [angular material ](https://www.npmjs.com/package/@angular/material) |
| 33 | +- [angular material theme](https://material.angular.io/guide/getting-started#step-4-include-a-theme) |
| 34 | +- [angular cdk ](https://www.npmjs.com/package/@angular/cdk) |
| 35 | +- [angular animations ](https://www.npmjs.com/package/@angular/animations) |
| 36 | +- [angular forms ](https://www.npmjs.com/package/@angular/forms) |
| 37 | +- if you need a built in theme --> please let me know |
| 38 | + |
| 39 | + |
| 40 | +```bash |
| 41 | +npm i @angular/cdk @angular/material @angular/flex-layout @angular/animations @angular/forms |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +## Installation |
| 46 | +Install above dependencies via *npm*. |
| 47 | + |
| 48 | +Now install `ngx-material-faq` via: |
| 49 | +```shell |
| 50 | +npm install --save ngx-material-faq |
| 51 | +``` |
| 52 | + |
| 53 | +--- |
| 54 | +##### SystemJS |
| 55 | +>**Note**:If you are using `SystemJS`, you should adjust your configuration to point to the UMD bundle. |
| 56 | +In your systemjs config file, `map` needs to tell the System loader where to look for `ngx-material-faq`: |
| 57 | +```js |
| 58 | +map: { |
| 59 | + 'ngx-material-faq': 'node_modules/ngx-material-faq/bundles/ngx-material-faq.umd.js', |
| 60 | +} |
| 61 | +``` |
| 62 | +--- |
| 63 | + |
| 64 | +Once installed you need to import the main module: |
| 65 | +```js |
| 66 | +import { LibModule } from 'ngx-material-faq'; |
| 67 | +``` |
| 68 | +The only remaining part is to list the imported module in your application module. The exact method will be slightly |
| 69 | +different for the root (top-level) module for which you should end up with the code similar to (notice ` LibModule .forRoot()`): |
| 70 | +```js |
| 71 | +import { LibModule } from 'ngx-material-faq'; |
| 72 | + |
| 73 | +@NgModule({ |
| 74 | + declarations: [AppComponent, ...], |
| 75 | + imports: [LibModule.forRoot(), ...], |
| 76 | + bootstrap: [AppComponent] |
| 77 | +}) |
| 78 | +export class AppModule { |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +Other modules in your application can simply import ` LibModule `: |
| 83 | + |
| 84 | +```js |
| 85 | +import { LibModule } from 'ngx-material-faq'; |
| 86 | + |
| 87 | +@NgModule({ |
| 88 | + declarations: [OtherComponent, ...], |
| 89 | + imports: [LibModule, ...], |
| 90 | +}) |
| 91 | +export class OtherModule { |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Usage |
| 96 | + |
| 97 | +add the `ngx-material-faq` or the `ngx-material-faq-admin` element to your template: |
| 98 | + |
| 99 | + |
| 100 | +### ngx-material-faq |
| 101 | + |
| 102 | +<p align="center"> |
| 103 | + <img alt="ngx-material-faq" style="text-align: center;" |
| 104 | + src="assets/demo-ngx-material-faq.png"> |
| 105 | +</p> |
| 106 | + |
| 107 | +```html |
| 108 | +<ngx-material-faq [faqList]="list"></ngx-material-faq> |
| 109 | +``` |
| 110 | + |
| 111 | +```typescript |
| 112 | +export class HomeComponent implements OnInit { |
| 113 | + |
| 114 | + list: FaqItem[] = [ |
| 115 | + { |
| 116 | + question: 'Why does it think the jQuery plugin is missing?', |
| 117 | + answer: 'Remember: load jQuery before AngularJS if you are using jQuery plugins!' |
| 118 | + }, |
| 119 | + { |
| 120 | + question: 'How do I access the DOM from a controller?', |
| 121 | + answer: 'DO NOT perform DOM selection/traversal from the controller. The HTML hasn\'t rendered yet. Look up \'directives\'.' |
| 122 | + } |
| 123 | + ]; |
| 124 | + |
| 125 | + } |
| 126 | + |
| 127 | +### ngx-material-faq-admin |
| 128 | + |
| 129 | +<p align="center"> |
| 130 | + <img alt="ngx-material-faq-admin" style="text-align: center;" |
| 131 | + src="assets/demo-ngx-material-faq-admin.png"> |
| 132 | +</p> |
| 133 | + |
| 134 | +```html |
| 135 | +<ngx-material-faq-admin [title]="'Admin'" (onFAQItemAdded)="onNewFaqItem($event)"></ngx-material-faq-admin> |
| 136 | +``` |
| 137 | + |
| 138 | +in your component |
| 139 | + |
| 140 | +```typescript |
| 141 | +export class HomeComponent implements OnInit { |
| 142 | +
|
| 143 | + faq: FaqItem[] = []; |
| 144 | + |
| 145 | + onNewFaqItem(faqItem: FaqItem) { |
| 146 | + console.log('on new faqItem -> ', faqItem); |
| 147 | + this.faq.splice(0, 0, faqItem); |
| 148 | + } |
| 149 | + |
| 150 | + } |
| 151 | +``` |
| 152 | + |
| 153 | +### Please checkout the full documentation [here](https://anthonynahas.github.io/ngx-material-faq/doc/index.html) or follow the official [tutorial](https://anthonynahas.github.io/ngx-material-faq/getting-started) |
| 154 | + |
| 155 | +## Development |
| 156 | + |
| 157 | +1. clone this [repo]() |
| 158 | +2. Install the dependencies by running `npm i` |
| 159 | +3. build the library `npm run build` or `gulp build` |
| 160 | +To generate all `*.js`, `*.d.ts` and `*.metadata.json` files: |
| 161 | + |
| 162 | +```bash |
| 163 | +$ npm run build |
| 164 | +``` |
| 165 | + |
| 166 | +4. Link the library |
| 167 | + - on windows `gulp link` or `locally npx gulp link` |
| 168 | + - on mac/linux `sudo gulp link` or locally `sudo npx gulp link` |
| 169 | + |
| 170 | + 5. Navigate to the demo app |
| 171 | + - `cd demo` |
| 172 | + _ `npm i` |
| 173 | + _ `npm start` |
| 174 | + |
| 175 | +extras |
| 176 | +To lint all `*.ts` files: |
| 177 | + |
| 178 | +```bash |
| 179 | +$ npm run lint |
| 180 | +``` |
| 181 | + |
| 182 | + |
| 183 | +## Other Angular Libraries |
| 184 | +- [ngx-auth-firebaseui](https://github.com/AnthonyNahas/ngx-auth-firebaseui) |
| 185 | +- [ngx-material-pages](https://github.com/AnthonyNahas/ngx-material-pages) |
| 186 | +- [ngx-material-password-strength](https://github.com/AnthonyNahas/ngx-material-password-strength) |
| 187 | +- [ngx-material-contacts](https://github.com/AnthonyNahas/ngx-material-contacts) |
| 188 | +- [ngx-combination-generator](https://github.com/AnthonyNahas/combination-generator) |
| 189 | + |
| 190 | + |
| 191 | +## License |
| 192 | + |
| 193 | +Copyright (c) 2018 anthonynahas. Licensed under the MIT License (MIT) |
| 194 | + |
0 commit comments