diff --git a/demo-shell/src/app/components/icons/icons.component.ts b/demo-shell/src/app/components/icons/icons.component.ts
new file mode 100644
index 0000000000..ea55f94eb9
--- /dev/null
+++ b/demo-shell/src/app/components/icons/icons.component.ts
@@ -0,0 +1,41 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, OnInit } from '@angular/core';
+import { MatIconRegistry } from '@angular/material';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Component({
+ selector: 'app-icons-demo',
+ templateUrl: './icons.component.html'
+})
+export class IconsComponent implements OnInit {
+ constructor(
+ private matIconRegistry: MatIconRegistry,
+ private sanitizer: DomSanitizer
+ ) {}
+
+ ngOnInit() {
+ this.matIconRegistry.addSvgIconInNamespace(
+ 'adf',
+ 'move_file',
+ this.sanitizer.bypassSecurityTrustResourceUrl(
+ './assets/images/adf-move-file-24px.svg'
+ )
+ );
+ }
+}
diff --git a/demo-shell/src/app/components/icons/icons.module.ts b/demo-shell/src/app/components/icons/icons.module.ts
new file mode 100644
index 0000000000..c6f32d2f66
--- /dev/null
+++ b/demo-shell/src/app/components/icons/icons.module.ts
@@ -0,0 +1,39 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+import { CommonModule } from '@angular/common';
+import { CoreModule } from '@alfresco/adf-core';
+import { IconsComponent } from './icons.component';
+
+const routes: Routes = [
+ {
+ path: '',
+ component: IconsComponent
+ }
+];
+
+@NgModule({
+ imports: [
+ CommonModule,
+ CoreModule.forChild(),
+ RouterModule.forChild(routes)
+ ],
+ declarations: [IconsComponent]
+})
+export class AppIconsModule {}
diff --git a/demo-shell/src/assets/images/adf-move-file-24px.svg b/demo-shell/src/assets/images/adf-move-file-24px.svg
new file mode 100644
index 0000000000..bf39e51ccf
--- /dev/null
+++ b/demo-shell/src/assets/images/adf-move-file-24px.svg
@@ -0,0 +1 @@
+
diff --git a/docs/core/icon.component.md b/docs/core/icon.component.md
new file mode 100644
index 0000000000..8da7cb1111
--- /dev/null
+++ b/docs/core/icon.component.md
@@ -0,0 +1,77 @@
+# [Icon Component](../../lib/core/icon/icon.component.ts "Defined in icon.component.ts")
+
+Provides universal way of rendering registered and named icons.
+
+## Contents
+
+- [Basic usage](#basic-usage)
+- [Class members](#class-members)
+ - [Properties](#properties)
+- [Named icons](#named-icons)
+
+## Basic usage
+
+```html
+
+
+
+
+
+
+
+
+```
+
+## Class members
+
+### Properties
+
+| Name | Type | Default value | Description |
+| ---- | ---- | ------------- | ----------- |
+| value | `string` | | Icon value, can be either ligature name or custom icon in the format `[namespace]:[name]` |
+
+## Named icons
+
+You can register custom SVG files as named icons in the format `[namespace]:[name]`.
+
+Example below shows how to register a new icon named `adf:move_file`
+that points to an external file within the `assets` folder.
+
+```ts
+import { Component, OnInit } from '@angular/core';
+import { MatIconRegistry } from '@angular/material';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Component({...})
+export class AppComponent implements OnInit {
+
+ constructor(
+ private matIconRegistry: MatIconRegistry,
+ private sanitizer: DomSanitizer
+ ) {}
+
+ ngOnInit() {
+ this.matIconRegistry.addSvgIconInNamespace(
+ 'adf',
+ 'move_file',
+ this.sanitizer.bypassSecurityTrustResourceUrl(
+ './assets/images/adf-move-file-24px.svg'
+ )
+ );
+ }
+}
+```
+
+In the HTML you can now use it like in the following snippet:
+
+```html
+
+```
+
+## Thumbnail Service
+
+You can also use icons registered with the ADF [ThumbnailService](thumbnail.service.md)
+
+```html
+
+```
diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts
index e2faca214a..219a9f5faf 100644
--- a/lib/core/core.module.ts
+++ b/lib/core/core.module.ts
@@ -54,6 +54,7 @@ import { TranslateLoaderService } from './services/translate-loader.service';
import { TranslationService } from './services/translation.service';
import { startupServiceFactory } from './services/startup-service-factory';
import { SortingPickerModule } from './sorting-picker/sorting-picker.module';
+import { IconModule } from './icon/icon.module';
export function createTranslateLoader(http: HttpClient) {
return new TranslateLoaderService(http);
@@ -89,6 +90,7 @@ export function createTranslateLoader(http: HttpClient) {
DataTableModule,
ButtonsMenuModule,
TemplateModule,
+ IconModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
@@ -128,7 +130,8 @@ export function createTranslateLoader(http: HttpClient) {
TranslateModule,
ButtonsMenuModule,
TemplateModule,
- SortingPickerModule
+ SortingPickerModule,
+ IconModule
]
})
export class CoreModuleLazy {
@@ -163,6 +166,7 @@ export class CoreModuleLazy {
DataTableModule,
ButtonsMenuModule,
TemplateModule,
+ IconModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
@@ -202,7 +206,8 @@ export class CoreModuleLazy {
TranslateModule,
ButtonsMenuModule,
TemplateModule,
- SortingPickerModule
+ SortingPickerModule,
+ IconModule
],
providers: [
{
diff --git a/lib/core/icon/icon.component.html b/lib/core/icon/icon.component.html
new file mode 100644
index 0000000000..ba5b060d27
--- /dev/null
+++ b/lib/core/icon/icon.component.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+ {{ value }}
+
diff --git a/lib/core/icon/icon.component.scss b/lib/core/icon/icon.component.scss
new file mode 100644
index 0000000000..ab73482199
--- /dev/null
+++ b/lib/core/icon/icon.component.scss
@@ -0,0 +1,4 @@
+.adf-icon {
+ display: inline-flex;
+ vertical-align: middle;
+}
diff --git a/lib/core/icon/icon.component.ts b/lib/core/icon/icon.component.ts
new file mode 100644
index 0000000000..d3e553473a
--- /dev/null
+++ b/lib/core/icon/icon.component.ts
@@ -0,0 +1,55 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import {
+ Component,
+ Input,
+ ViewEncapsulation,
+ ChangeDetectionStrategy
+} from '@angular/core';
+import { ThumbnailService } from '../services/thumbnail.service';
+
+@Component({
+ selector: 'adf-icon',
+ templateUrl: './icon.component.html',
+ styleUrls: ['./icon.component.scss'],
+ encapsulation: ViewEncapsulation.None,
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ host: { class: 'adf-icon' }
+})
+export class IconComponent {
+ private _value = '';
+ private _isCustom = false;
+
+ get value(): string {
+ return this._value;
+ }
+
+ @Input()
+ set value(value: string) {
+ this._value = value || 'settings';
+ this._isCustom =
+ this._value.includes(':') ||
+ this.thumbnailService.mimeTypeIcons[value];
+ }
+
+ get isCustom(): boolean {
+ return this._isCustom;
+ }
+
+ constructor(private thumbnailService: ThumbnailService) {}
+}
diff --git a/lib/core/icon/icon.module.ts b/lib/core/icon/icon.module.ts
new file mode 100644
index 0000000000..85792791e9
--- /dev/null
+++ b/lib/core/icon/icon.module.ts
@@ -0,0 +1,35 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { NgModule } from '@angular/core';
+import { IconComponent } from './icon.component';
+import { MatIconModule } from '@angular/material';
+import { CommonModule } from '@angular/common';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ MatIconModule
+ ],
+ declarations: [
+ IconComponent
+ ],
+ exports: [
+ IconComponent
+ ]
+})
+export class IconModule {}
diff --git a/lib/core/icon/index.ts b/lib/core/icon/index.ts
new file mode 100644
index 0000000000..4c6ac1d58f
--- /dev/null
+++ b/lib/core/icon/index.ts
@@ -0,0 +1,18 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './public-api';
diff --git a/lib/core/icon/public-api.ts b/lib/core/icon/public-api.ts
new file mode 100644
index 0000000000..57df8ebeb4
--- /dev/null
+++ b/lib/core/icon/public-api.ts
@@ -0,0 +1,19 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './icon.component';
+export * from './icon.module';
diff --git a/lib/core/index.ts b/lib/core/index.ts
index 8719abdd89..3b7ec04f81 100644
--- a/lib/core/index.ts
+++ b/lib/core/index.ts
@@ -40,6 +40,7 @@ export * from './services/index';
export * from './directives/index';
export * from './clipboard/index';
export * from './dialogs/index';
+export * from './icon/index';
export * from './utils/index';
export * from './interface/index';