Skip to content

Commit 397083a

Browse files
committed
data service
1 parent 7d2ea3e commit 397083a

File tree

3 files changed

+69
-33
lines changed

3 files changed

+69
-33
lines changed

src/app/components/grid/grid.component.ts

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { GridItem } from '../../interfaces/grid-item.interface';
33
import { MatCardModule } from '@angular/material/card';
4+
import { DataService } from '../../services/data.service';
45

56
@Component({
67
selector: 'app-grid',
@@ -9,38 +10,14 @@ import { MatCardModule } from '@angular/material/card';
910
templateUrl: './grid.component.html',
1011
styleUrl: './grid.component.scss'
1112
})
12-
export class GridComponent {
13-
gridItems: GridItem[] = [{
14-
title: 'VSCode Extension',
15-
description: 'The sQeeZ extension for Visual Studio Code.',
16-
image: './grid/vsc-extension.svg',
17-
url: 'https://github.com/sQeeZ-scripting-language/language-server'
18-
}, {
19-
title: 'Playground',
20-
description: 'The sQeeZ playground for testing scripts.',
21-
image: './grid/playground.svg',
22-
url: 'https://sqeez-scripting-language.github.io/playground/'
23-
}, {
24-
title: 'Documentation',
25-
description: 'The sQeeZ documentation for learning the language.',
26-
image: './grid/documentation.svg',
27-
url: 'https://sqeez-scripting-language.github.io/documentation/'
28-
}, {
29-
title: 'GitHub',
30-
description: 'The sQeeZ GitHub organization.',
31-
image: './grid/github.svg',
32-
url: 'https://github.com/sqeez-scripting-language/'
33-
}, {
34-
title: 'All Releases',
35-
description: 'All sQeeZ releases on GitHub.',
36-
image: './grid/releases.svg',
37-
url: 'https://github.com/sQeeZ-scripting-language/interpreter/releases'
38-
}, {
39-
title: 'Contribute',
40-
description: 'Contribute to the sQeeZ project on GitHub.',
41-
image: './grid/contribute.svg',
42-
url: 'https://github.com/sQeeZ-scripting-language#-become-part-of-the-sqeez-journey'
43-
}];
13+
export class GridComponent implements OnInit {
14+
gridItems: GridItem[] = [];
15+
16+
constructor(private data: DataService) {}
17+
18+
ngOnInit(): void {
19+
this.gridItems = this.data.gridItems;
20+
}
4421

4522
redirectTo(url: string): void {
4623
// new tab
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { DataService } from './data.service';
4+
5+
describe('DataService', () => {
6+
let service: DataService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(DataService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});

src/app/services/data.service.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Injectable } from '@angular/core';
2+
import { GridItem } from '../interfaces/grid-item.interface';
3+
4+
@Injectable({
5+
providedIn: 'root'
6+
})
7+
export class DataService {
8+
private _gridItems: GridItem[] = [{
9+
title: 'VSCode Extension',
10+
description: 'The sQeeZ extension for Visual Studio Code.',
11+
image: './grid/vsc-extension.svg',
12+
url: 'https://github.com/sQeeZ-scripting-language/language-server'
13+
}, {
14+
title: 'Playground',
15+
description: 'The sQeeZ playground for testing scripts.',
16+
image: './grid/playground.svg',
17+
url: 'https://sqeez-scripting-language.github.io/playground/'
18+
}, {
19+
title: 'Documentation',
20+
description: 'The sQeeZ documentation for learning the language.',
21+
image: './grid/documentation.svg',
22+
url: 'https://sqeez-scripting-language.github.io/documentation/'
23+
}, {
24+
title: 'GitHub',
25+
description: 'The sQeeZ GitHub organization.',
26+
image: './grid/github.svg',
27+
url: 'https://github.com/sqeez-scripting-language/'
28+
}, {
29+
title: 'All Releases',
30+
description: 'All sQeeZ releases on GitHub.',
31+
image: './grid/releases.svg',
32+
url: 'https://github.com/sQeeZ-scripting-language/interpreter/releases'
33+
}, {
34+
title: 'Contribute',
35+
description: 'Contribute to the sQeeZ project on GitHub.',
36+
image: './grid/contribute.svg',
37+
url: 'https://github.com/sQeeZ-scripting-language#-become-part-of-the-sqeez-journey'
38+
}];
39+
40+
get gridItems(): GridItem[] {
41+
return this._gridItems;
42+
}
43+
}

0 commit comments

Comments
 (0)