Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit e98aa8d

Browse files
mmalerbajelbourn
authored andcommitted
Add component category view (#43)
1 parent 97600aa commit e98aa8d

File tree

13 files changed

+290
-28
lines changed

13 files changed

+290
-28
lines changed

src/app/app-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import {ComponentList} from './pages/component-list/component-list';
1111
import {ComponentViewer} from './pages/component-viewer/component-viewer';
1212
import {ExampleModule} from './examples/example-module';
1313
import {SharedModule} from './shared/shared-module';
14+
import {ComponentCategoryList} from './pages/component-category-list/component-category-list';
1415

1516

1617
@NgModule({
1718
declarations: [
1819
MaterialDocsApp,
20+
ComponentCategoryList,
1921
ComponentList,
2022
ComponentViewer,
2123
Homepage,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<md-card
2+
*ngFor="let category of docItems.getItemsInCategories()"
3+
class="docs-component-category-list-category"
4+
routerLink="/components/{{category.id}}">
5+
<md-card-title>{{category.name}}</md-card-title>
6+
<p>{{category.summary}}</p>
7+
<img md-card-image src="../../../assets/img/component-categories/{{category.id}}.svg">
8+
</md-card>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.docs-component-category-list-category {
2+
display: inline-block;
3+
width: 300px;
4+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Component} from '@angular/core';
2+
import {
3+
DocumentationItems,
4+
DocCategory
5+
} from '../../shared/documentation-items/documentation-items';
6+
7+
8+
@Component({
9+
selector: 'app-component-category-list',
10+
templateUrl: './component-category-list.html',
11+
styleUrls: ['./component-category-list.scss']
12+
})
13+
export class ComponentCategoryList {
14+
constructor(public docItems: DocumentationItems) {}
15+
}

src/app/pages/component-list/component-list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div *ngFor="let category of docItems.getItemsInCategories()" class="docs-component-list-category">
1+
<div class="docs-component-list-category">
22
<h2>{{category.name}}</h2>
33
<a *ngFor="let component of category.items"
44
class="docs-component-list-item"
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import {Component} from '@angular/core';
2-
import {DocumentationItems} from '../../shared/documentation-items/documentation-items';
2+
import {
3+
DocumentationItems,
4+
DocCategory
5+
} from '../../shared/documentation-items/documentation-items';
6+
import {ActivatedRoute} from '@angular/router';
37

48
@Component({
59
selector: 'app-components',
610
templateUrl: './component-list.html',
711
styleUrls: ['./component-list.scss']
812
})
913
export class ComponentList {
10-
constructor(public docItems: DocumentationItems) { }
14+
category: DocCategory;
15+
16+
constructor(public docItems: DocumentationItems, private _route: ActivatedRoute) {
17+
_route.params.subscribe(p => {
18+
this.category = docItems.getCategoryById(p['id']);
19+
});
20+
}
1121
}

src/app/routes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {Homepage} from './pages/homepage';
33
import {ComponentList} from './pages/component-list';
44
import {Routes, RouterModule} from '@angular/router';
55
import {ComponentViewer} from './pages/component-viewer/component-viewer';
6+
import {ComponentCategoryList} from './pages/component-category-list/component-category-list';
67

78
const MATERIAL_DOCS_ROUTES: Routes = [
89
{path: '', component: Homepage, pathMatch: 'full'},
9-
{path: 'components', component: ComponentList},
10+
{path: 'components', component: ComponentCategoryList},
11+
{path: 'components/:id', component: ComponentList},
1012
{path: 'component/:id', component: ComponentViewer},
1113
];
1214

src/app/shared/documentation-items/documentation-items.ts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,60 @@ export interface DocCategory {
1515
const DOCS = [
1616
{
1717
id: 'forms',
18-
name: 'Form controls',
18+
name: 'Form Controls',
19+
summary: 'Radio buttons, checkboxes, input fields, sliders, slide toggles, selects',
1920
items: [
20-
{id: 'button', name: 'Button', examples: ['button-types']},
21-
{id: 'checkbox', name: 'Checkbox'},
2221
{id: 'radio', name: 'Radio button'},
23-
{id: 'button-toggle', name: 'Button toggle'},
22+
{id: 'checkbox', name: 'Checkbox'},
2423
{id: 'input', name: 'Input'},
2524
{id: 'textarea', name: 'Textarea'},
26-
{id: 'select', name: 'Select'},
27-
{id: 'slide-toggle', name: 'Slide toggle'},
2825
{id: 'slider', name: 'Slider'},
26+
{id: 'slide-toggle', name: 'Slide toggle'},
27+
{id: 'select', name: 'Select'},
2928
]
3029
},
3130
{
32-
id: 'structure',
33-
name: 'Application structure',
31+
id: 'nav',
32+
name: 'Navigation',
33+
summary: 'Sidenavs, toolbars, menus, lists',
3434
items: [
35-
{id: 'card', name: 'Card'},
36-
{id: 'list', name: 'List'},
37-
{id: 'grid-list', name: 'Grid list'},
3835
{id: 'sidenav', name: 'Sidenav'},
3936
{id: 'toolbar', name: 'Toolbar'},
37+
{id: 'menu', name: 'Menu'},
38+
{id: 'list', name: 'List'},
4039
]
4140
},
4241
{
43-
id: 'popups',
44-
name: 'Pop-ups and notifications',
42+
id: 'layout',
43+
name: 'Layout',
44+
summary: 'Grid lists, cards',
4545
items: [
46-
47-
{id: 'menu', name: 'Menu'},
48-
{id: 'dialog', name: 'Dialog'},
49-
{id: 'snackbar', name: 'Snackbar'},
50-
{id: 'tooltip', name: 'Tooltip'},
46+
{id: 'grid-list', name: 'Grid list'},
47+
{id: 'card', name: 'Card'},
5148
]
5249
},
5350
{
54-
id: 'progress',
55-
name: 'Progress indicators',
51+
id: 'buttons',
52+
name: 'Buttons, Actions & Icons',
53+
summary: 'buttons, button toggles, icons, progress spinners, progress bars',
5654
items: [
55+
{id: 'button', name: 'Button', examples: ['button-types']},
56+
{id: 'button-toggle', name: 'Button toggle'},
57+
{id: 'icon', name: 'Icon'},
5758
{id: 'progress-spinner', name: 'Progress spinner'},
5859
{id: 'progress-bar', name: 'Progress bar'},
5960
]
6061
},
6162
{
62-
id: 'icons',
63-
name: 'Icons',
63+
id: 'modals',
64+
name: 'Popups & Modals',
65+
summary: 'Dialogs, tooltips, snackbars',
6466
items: [
65-
{id: 'icon', name: 'Icon'},
67+
{id: 'dialog', name: 'Dialog'},
68+
{id: 'tooltip', name: 'Tooltip'},
69+
{id: 'snackbar', name: 'Snackbar'},
6670
]
67-
}
71+
},
6872
];
6973

7074
const ALL_ITEMS = DOCS.reduce((result, category) => result.concat(category.items), []);
@@ -82,4 +86,8 @@ export class DocumentationItems {
8286
getItemById(id: string): DocItem {
8387
return ALL_ITEMS.find(i => i.id === id);
8488
}
89+
90+
getCategoryById(id: string): DocCategory {
91+
return DOCS.find(c => c.id == id);
92+
}
8593
}
Lines changed: 43 additions & 0 deletions
Loading
Lines changed: 80 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)