Skip to content

Commit 674ce63

Browse files
committed
Create fittable-angular demo app and present main source code in user docs.
1 parent f2349d0 commit 674ce63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+13607
-976
lines changed

README.md

+70-27
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
npm install fittable-angular
2929
```
3030

31+
## Angular component example
32+
3133
### tsconfig.json (for non-ECMAScript module dependants)
3234

3335
```json
@@ -52,57 +54,63 @@ npm install fittable-angular
5254
}
5355
```
5456

55-
## API Overview
57+
### app.module.ts
5658

57-
### HTML
59+
```typescript
60+
import { NgModule } from '@angular/core';
61+
import { BrowserModule } from '@angular/platform-browser';
5862

59-
```html
60-
<div style="width:100%;height:300px;">
61-
<!-- Angular component -->
62-
<fittable [designer]="fit"></fittable>
63-
</div>
63+
import { registerModelConfig } from 'fittable-core/model';
64+
import { registerOperationConfig } from 'fittable-core/operations';
65+
import { registerViewModelConfig } from 'fittable-core/view-model';
66+
import { FIT_MODEL_CONFIG } from 'fittable-model';
67+
import { FIT_OPERATION_CONFIG } from 'fittable-model-operations';
68+
import { FIT_VIEW_MODEL_CONFIG } from 'fittable-view-model';
69+
import { NgxFittableModule } from 'fittable-angular';
70+
71+
import { AppComponent } from './app.component';
72+
73+
// Register functionalities
74+
registerModelConfig(FIT_MODEL_CONFIG);
75+
registerOperationConfig(FIT_OPERATION_CONFIG);
76+
registerViewModelConfig(FIT_VIEW_MODEL_CONFIG);
77+
78+
@NgModule({
79+
declarations: [AppComponent],
80+
imports: [BrowserModule, NgxFittableModule],
81+
providers: [],
82+
bootstrap: [AppComponent],
83+
})
84+
export class AppModule {}
6485
```
6586

66-
### TypeScript
87+
### app.component.ts
6788

6889
```typescript
6990
import { Component, OnInit } from '@angular/core';
7091

71-
// TypeScript modules
7292
import {
7393
CellRange,
7494
createStyle,
7595
createTable,
76-
registerModelConfig,
7796
Table,
7897
} from 'fittable-core/model';
79-
import { registerOperationConfig } from 'fittable-core/operations';
8098
import {
8199
createFittableDesigner,
82100
FittableDesigner,
83-
registerViewModelConfig,
84101
} from 'fittable-core/view-model';
85-
import { FitStyle, FitTable, FIT_MODEL_CONFIG } from 'fittable-model';
86-
import {
87-
FitOperationArgs,
88-
FIT_OPERATION_CONFIG,
89-
} from 'fittable-model-operations';
90-
import { FIT_VIEW_MODEL_CONFIG } from 'fittable-view-model';
102+
import { FitStyle, FitTable } from 'fittable-model';
103+
import { FitOperationArgs } from 'fittable-model-operations';
91104

92105
@Component({
93-
selector: 'sample',
94-
templateUrl: './sample.component.html',
95-
styleUrls: ['.sample/common.css'],
106+
selector: 'app-root',
107+
templateUrl: './app.component.html',
108+
styleUrls: ['./app.component.css'],
96109
})
97-
export class SampleComponent implements OnInit {
110+
export class AppComponent implements OnInit {
98111
public fit!: FittableDesigner;
99112

100113
public ngOnInit(): void {
101-
// Register functionalities
102-
registerModelConfig(FIT_MODEL_CONFIG);
103-
registerOperationConfig(FIT_OPERATION_CONFIG);
104-
registerViewModelConfig(FIT_VIEW_MODEL_CONFIG);
105-
106114
// Build table model
107115
const table: Table = createTable<FitTable>()
108116
.setNumberOfRows(100)
@@ -134,3 +142,38 @@ export class SampleComponent implements OnInit {
134142
}
135143
}
136144
```
145+
146+
### app.component.html
147+
148+
```html
149+
<div class="fittable">
150+
<!-- Angular component -->
151+
<fittable [designer]="fit"></fittable>
152+
</div>
153+
```
154+
155+
### app.component.css
156+
157+
```css
158+
.fittable {
159+
position: relative;
160+
width: 100%;
161+
height: 100%;
162+
}
163+
```
164+
165+
### styles.css
166+
167+
```css
168+
html,
169+
body {
170+
position: relative;
171+
width: 100%;
172+
height: 100%;
173+
margin: 0px;
174+
padding: 0px;
175+
overflow: hidden;
176+
}
177+
```
178+
179+
<p>The demo component can be found <a href="https://github.com/ionutkosteea/fittable/tree/main/angular-app/ngx-fittable-test">here</a>.<p>

0 commit comments

Comments
 (0)