diff --git a/docs/output.json b/docs/output.json
index b487bd2823..29e438476e 100644
--- a/docs/output.json
+++ b/docs/output.json
@@ -754,6 +754,33 @@
"platform": null,
"examples": [],
"props": [
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgePosition",
+ "shortDescription": "Badge position.\nCan be set to any class or to one of predefined positions:\n'top left', 'top right', 'bottom left', 'bottom right'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeStatus",
+ "shortDescription": "Badge status (adds specific styles):\n'primary', 'info', 'success', 'warning', 'danger'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeText",
+ "shortDescription": "Badge text to display"
+ },
{
"kind": "input",
"platform": null,
@@ -862,6 +889,87 @@
}
]
},
+ {
+ "kind": "component",
+ "platform": null,
+ "examples": [
+ {
+ "shortDescription": "Badge with default position and status(color):",
+ "description": "",
+ "code": "\n\n"
+ },
+ {
+ "shortDescription": "Badge located on the bottom right with warning status:",
+ "description": "",
+ "code": "\n\n\n"
+ }
+ ],
+ "props": [
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "text",
+ "shortDescription": "Text to display"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "position",
+ "shortDescription": "Badge position",
+ "description": "Can be set to any class or to one of predefined positions:\n'top left', 'top right', 'bottom left', 'bottom right'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "status",
+ "shortDescription": "Badge status (adds specific styles):\n'primary', 'info', 'success', 'warning', 'danger'"
+ }
+ ],
+ "methods": [],
+ "name": "NbBadgeComponent",
+ "description": "Element is absolute positioned, so parent should be\n[positioned element](https://developer.mozilla.org/en-US/docs/Web/CSS/position).\nIt means parent `position` should be set to anything except `static`, e.g. `relative`,\n`absolute`, `fixed`, or `sticky`.\n\n",
+ "shortDescription": "Badge is a simple labeling component.\nIt can be used to add additional information to any content or highlight unread items.",
+ "styles": [
+ {
+ "shortDescription": "",
+ "styles": [
+ {
+ "name": "badge-fg-text",
+ "description": ""
+ },
+ {
+ "name": "badge-primary-bg-color",
+ "description": ""
+ },
+ {
+ "name": "badge-success-bg-color",
+ "description": ""
+ },
+ {
+ "name": "badge-info-bg-color",
+ "description": ""
+ },
+ {
+ "name": "badge-warning-bg-color",
+ "description": ""
+ },
+ {
+ "name": "badge-danger-bg-color",
+ "description": ""
+ }
+ ]
+ }
+ ]
+ },
{
"kind": "component",
"platform": null,
@@ -2684,7 +2792,7 @@
"platform": null,
"examples": [
{
- "shortDescription": "",
+ "shortDescription": "Minimal sidebar example",
"description": "",
"code": "\n\n Sidebar content.\n\n"
},
@@ -3110,7 +3218,35 @@
"kind": "component",
"platform": null,
"examples": [],
- "props": [],
+ "props": [
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgePosition",
+ "shortDescription": "Badge position.\nCan be set to any class or to one of predefined positions:\n'top left', 'top right', 'bottom left', 'bottom right'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeStatus",
+ "shortDescription": "Badge status (adds specific styles):\n'primary', 'info', 'success', 'warning', 'danger'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeText",
+ "shortDescription": "Badge text to display"
+ }
+ ],
"methods": [],
"name": "NbTabComponent",
"shortDescription": "Specific tab container.",
@@ -3284,6 +3420,33 @@
"platform": null,
"examples": [],
"props": [
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgePosition",
+ "shortDescription": "Badge position.\nCan be set to any class or to one of predefined positions:\n'top left', 'top right', 'bottom left', 'bottom right'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeStatus",
+ "shortDescription": "Badge status (adds specific styles):\n'primary', 'info', 'success', 'warning', 'danger'"
+ },
+ {
+ "kind": "input",
+ "platform": null,
+ "isStatic": false,
+ "type": "string",
+ "required": null,
+ "name": "badgeText",
+ "shortDescription": "Badge text to display"
+ },
{
"kind": "input",
"platform": null,
@@ -5084,6 +5247,10 @@
"theme": "default",
"prop": "btn-fg"
},
+ {
+ "theme": "default",
+ "prop": "badge-fg-text"
+ },
{
"theme": "cosmic",
"prop": "color-white"
@@ -5125,6 +5292,10 @@
{
"theme": "default",
"prop": "btn-primary-bg"
+ },
+ {
+ "theme": "default",
+ "prop": "badge-primary-bg-color"
}
]
},
@@ -5180,6 +5351,10 @@
{
"theme": "default",
"prop": "radio-fg"
+ },
+ {
+ "theme": "default",
+ "prop": "badge-success-bg-color"
}
]
},
@@ -5203,6 +5378,10 @@
{
"theme": "default",
"prop": "form-control-info-border-color"
+ },
+ {
+ "theme": "default",
+ "prop": "badge-info-bg-color"
}
]
},
@@ -5227,6 +5406,10 @@
"theme": "default",
"prop": "form-control-warning-border-color"
},
+ {
+ "theme": "default",
+ "prop": "badge-warning-bg-color"
+ },
{
"theme": "cosmic",
"prop": "color-warning"
@@ -5253,6 +5436,10 @@
{
"theme": "default",
"prop": "form-control-danger-border-color"
+ },
+ {
+ "theme": "default",
+ "prop": "badge-danger-bg-color"
}
]
},
@@ -8604,6 +8791,72 @@
}
],
"childs": []
+ },
+ "badge-fg-text": {
+ "name": "badge-fg-text",
+ "value": "#ffffff",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-white"
+ }
+ ],
+ "childs": []
+ },
+ "badge-primary-bg-color": {
+ "name": "badge-primary-bg-color",
+ "value": "#8a7fff",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-primary"
+ }
+ ],
+ "childs": []
+ },
+ "badge-success-bg-color": {
+ "name": "badge-success-bg-color",
+ "value": "#40dc7e",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-success"
+ }
+ ],
+ "childs": []
+ },
+ "badge-info-bg-color": {
+ "name": "badge-info-bg-color",
+ "value": "#4ca6ff",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-info"
+ }
+ ],
+ "childs": []
+ },
+ "badge-warning-bg-color": {
+ "name": "badge-warning-bg-color",
+ "value": "#ffa100",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-warning"
+ }
+ ],
+ "childs": []
+ },
+ "badge-danger-bg-color": {
+ "name": "badge-danger-bg-color",
+ "value": "#ff4c6a",
+ "parents": [
+ {
+ "theme": "default",
+ "prop": "color-danger"
+ }
+ ],
+ "childs": []
}
},
"name": "default",
@@ -9472,6 +9725,10 @@
{
"theme": "cosmic",
"prop": "btn-fg"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-fg-text"
}
]
},
@@ -9535,6 +9792,10 @@
{
"theme": "cosmic",
"prop": "form-control-selected-border-color"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-primary-bg-color"
}
]
},
@@ -9570,6 +9831,10 @@
{
"theme": "cosmic",
"prop": "checkbox-selected-border-color"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-success-bg-color"
}
]
},
@@ -9593,6 +9858,10 @@
{
"theme": "cosmic",
"prop": "form-control-info-border-color"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-info-bg-color"
}
]
},
@@ -9621,6 +9890,10 @@
{
"theme": "cosmic",
"prop": "form-control-warning-border-color"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-warning-bg-color"
}
]
},
@@ -9644,6 +9917,10 @@
{
"theme": "cosmic",
"prop": "form-control-danger-border-color"
+ },
+ {
+ "theme": "cosmic",
+ "prop": "badge-danger-bg-color"
}
]
},
@@ -13322,6 +13599,80 @@
}
],
"childs": []
+ },
+ "badge-fg-text": {
+ "name": "badge-fg-text",
+ "value": "#ffffff",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-white"
+ },
+ {
+ "theme": "default",
+ "prop": "color-white"
+ }
+ ],
+ "childs": []
+ },
+ "badge-primary-bg-color": {
+ "name": "badge-primary-bg-color",
+ "value": "#7659ff",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-primary"
+ }
+ ],
+ "childs": []
+ },
+ "badge-success-bg-color": {
+ "name": "badge-success-bg-color",
+ "value": "#00d977",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-success"
+ }
+ ],
+ "childs": []
+ },
+ "badge-info-bg-color": {
+ "name": "badge-info-bg-color",
+ "value": "#0088ff",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-info"
+ }
+ ],
+ "childs": []
+ },
+ "badge-warning-bg-color": {
+ "name": "badge-warning-bg-color",
+ "value": "#ffa100",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-warning"
+ },
+ {
+ "theme": "default",
+ "prop": "color-warning"
+ }
+ ],
+ "childs": []
+ },
+ "badge-danger-bg-color": {
+ "name": "badge-danger-bg-color",
+ "value": "#ff386a",
+ "parents": [
+ {
+ "theme": "cosmic",
+ "prop": "color-danger"
+ }
+ ],
+ "childs": []
}
},
"name": "cosmic",
diff --git a/docs/structure.ts b/docs/structure.ts
index 4d344c4947..8887aa8d6e 100644
--- a/docs/structure.ts
+++ b/docs/structure.ts
@@ -312,6 +312,11 @@ export const STRUCTURE = [
block: 'component',
blockData: 'NbActionsComponent',
},
+ {
+ type: 'block',
+ block: 'component',
+ blockData: 'NbActionComponent',
+ },
],
},
{
@@ -336,6 +341,17 @@ export const STRUCTURE = [
},
],
},
+ {
+ type: 'page',
+ name: 'Badge',
+ children: [
+ {
+ type: 'block',
+ block: 'component',
+ blockData: 'NbBadgeComponent',
+ },
+ ],
+ },
],
},
{
diff --git a/e2e/actions.e2e-spec.ts b/e2e/actions.e2e-spec.ts
new file mode 100644
index 0000000000..6d5b5d6a90
--- /dev/null
+++ b/e2e/actions.e2e-spec.ts
@@ -0,0 +1,34 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+import { browser, element, by } from 'protractor';
+import { NbBadgeComponent } from '../src/framework/theme/components/badge/badge.component';
+import badgeTests from './badge.e2e-spec';
+
+describe('nb-action', () => {
+
+ beforeEach(() => {
+ browser.get('#/actions');
+ });
+
+ describe('badge', () => {
+ const badgeText = '29';
+ const badgesConf = {
+ selector: (i) => `nb-card:nth-child(4) nb-actions nb-action:nth-child(${i + 1}) nb-badge > span`,
+ badges: [
+ { position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText },
+ { position: NbBadgeComponent.TOP_LEFT, status: NbBadgeComponent.STATUS_DANGER, text: badgeText },
+ { position: NbBadgeComponent.BOTTOM_RIGHT, status: NbBadgeComponent.STATUS_WARNING, text: badgeText },
+ { position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText },
+ { position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText },
+ { position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText },
+ { position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_PRIMARY, text: badgeText },
+ ],
+ };
+ badgeTests(badgesConf);
+ });
+
+});
diff --git a/e2e/badge.e2e-spec.ts b/e2e/badge.e2e-spec.ts
new file mode 100644
index 0000000000..ba321753ac
--- /dev/null
+++ b/e2e/badge.e2e-spec.ts
@@ -0,0 +1,32 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+import { element, by } from 'protractor';
+
+export default function badgeTests (badgesConfig) {
+ const { selector, badges } = badgesConfig;
+
+ it('should display badge with correct text', () => {
+ for (let i = 0; i < badges.length; i++) {
+ const badgeEl = element(by.css(selector(i)));
+ expect(badgeEl.getText()).toEqual(badges[i].text);
+ }
+ });
+
+ it('should display badge with correct status', () => {
+ for (let i = 0; i < badges.length; i++) {
+ const badgeEl = element(by.css(selector(i)));
+ expect(badgeEl.getAttribute('class')).toContain(badges[i].status);
+ }
+ });
+
+ it('should display badge in correct position', () => {
+ for (let i = 0; i < badges.length; i++) {
+ const badgeEl = element(by.css(selector(i)));
+ expect(badgeEl.getAttribute('class')).toContain(badges[i].position);
+ }
+ });
+}
diff --git a/e2e/tabset.e2e-spec.ts b/e2e/tabset.e2e-spec.ts
index d7da7f26e2..af6112773b 100644
--- a/e2e/tabset.e2e-spec.ts
+++ b/e2e/tabset.e2e-spec.ts
@@ -6,6 +6,8 @@
import { browser, element, by } from 'protractor';
import { hasClass } from './e2e-helper';
+import { NbBadgeComponent } from '../src/framework/theme/components/badge/badge.component';
+import badgeTests from './badge.e2e-spec';
describe('nb-tabset', () => {
beforeEach((done) => {
@@ -79,4 +81,19 @@ describe('nb-tabset', () => {
expect(browser.getCurrentUrl()).toContain('/#/tabset/tab1');
});
});
+
+ describe('badge', () => {
+ const badgeText = '29';
+ const badgesConf = {
+ selector: (i) => `nb-tabset:nth-child(6) > ul > li:nth-child(${i + 1}) > nb-badge > span`,
+ badges: [
+ { text: badgeText, status: NbBadgeComponent.STATUS_PRIMARY, position: NbBadgeComponent.TOP_RIGHT },
+ { text: badgeText, status: NbBadgeComponent.STATUS_INFO, position: NbBadgeComponent.TOP_LEFT },
+ { text: badgeText, status: NbBadgeComponent.STATUS_SUCCESS, position: NbBadgeComponent.BOTTOM_RIGHT },
+ { text: badgeText, status: NbBadgeComponent.STATUS_DANGER, position: NbBadgeComponent.BOTTOM_LEFT },
+ { text: badgeText, status: NbBadgeComponent.STATUS_WARNING, position: NbBadgeComponent.BOTTOM_RIGHT },
+ ],
+ };
+ badgeTests(badgesConf);
+ })
});
diff --git a/e2e/user.e2e-spec.ts b/e2e/user.e2e-spec.ts
index 1c0b55c2b4..759981b380 100644
--- a/e2e/user.e2e-spec.ts
+++ b/e2e/user.e2e-spec.ts
@@ -5,6 +5,8 @@
*/
import { browser, element, by } from 'protractor';
+import { NbBadgeComponent } from '../src/framework/theme/components/badge/badge.component';
+import badgeTests from './badge.e2e-spec';
describe('nb-user', () => {
@@ -18,4 +20,20 @@ describe('nb-user', () => {
// });
// });
+ describe('badge', () => {
+ const elementsOffset = 10;
+ const badgeText = '29';
+ const badgesConf = {
+ selector: (i) => `.test-row:nth-child(${elementsOffset + i + 1}) nb-badge > span`,
+ badges: [
+ { position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_PRIMARY, text: badgeText },
+ { position: NbBadgeComponent.TOP_LEFT, status: NbBadgeComponent.STATUS_INFO, text: badgeText },
+ { position: NbBadgeComponent.BOTTOM_RIGHT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText },
+ { position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_WARNING, text: badgeText },
+ { position: NbBadgeComponent.TOP_LEFT, status: NbBadgeComponent.STATUS_DANGER, text: badgeText },
+ ],
+ };
+ badgeTests(badgesConf);
+ });
+
});
diff --git a/src/app/actions-test/actions-test.component.ts b/src/app/actions-test/actions-test.component.ts
index eaf52d15f3..03d73ed097 100644
--- a/src/app/actions-test/actions-test.component.ts
+++ b/src/app/actions-test/actions-test.component.ts
@@ -5,6 +5,7 @@
*/
import { Component } from '@angular/core';
+import { NbBadgeComponent } from 'framework/theme/components/badge/badge.component';
@Component({
selector: 'nb-actions-test',
@@ -80,12 +81,59 @@ import { Component } from '@angular/core';
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Badge
+
+
+
`,
})
export class NbActionsTestComponent {
+ badge = NbBadgeComponent;
+
actionOnClick(event: any) {
console.info(event);
}
diff --git a/src/app/tabset-test/tabset-test.component.ts b/src/app/tabset-test/tabset-test.component.ts
index e20ec5f72c..94b019e478 100644
--- a/src/app/tabset-test/tabset-test.component.ts
+++ b/src/app/tabset-test/tabset-test.component.ts
@@ -6,6 +6,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
+import { NbBadgeComponent } from 'framework/theme/components/badge/badge.component';
@Component({
selector: 'nb-tabset-test',
@@ -67,11 +68,73 @@ import { Router } from '@angular/router';
Content #3
+
+
+
+ Content #1
+
+
+ Content #2
+
+
+ Content #3
+
+
+ Content #4
+
+
+ Content #5
+
+
+
+
+ Content #1
+
+
+ Content #2
+
+
+ Content #3
+
+
+ Content #4
+
+
+ Content #5
+
+
`,
})
export class NbTabsetTestComponent {
+
+ badge = NbBadgeComponent;
+
constructor(private router: Router) {
}
diff --git a/src/app/user-test/user-test.component.ts b/src/app/user-test/user-test.component.ts
index c75319c11a..12abb245b9 100644
--- a/src/app/user-test/user-test.component.ts
+++ b/src/app/user-test/user-test.component.ts
@@ -5,6 +5,7 @@
*/
import { Component } from '@angular/core';
+import { NbBadgeComponent } from 'framework/theme/components/badge/badge.component';
@Component({
selector: 'nb-user-test',
@@ -59,12 +60,62 @@ import { Component } from '@angular/core';
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
`,
})
export class NbUserTestComponent {
+ badge = NbBadgeComponent;
+
contextMenu = [
{ title: 'Profile', link: 'some/link', icon: 'nb-person' },
{ title: 'Billing', target: '_blank', url: 'http://akveo.com' },
diff --git a/src/framework/theme/components/actions/actions.component.scss b/src/framework/theme/components/actions/actions.component.scss
index 8704e85a10..df60c1a09a 100644
--- a/src/framework/theme/components/actions/actions.component.scss
+++ b/src/framework/theme/components/actions/actions.component.scss
@@ -13,6 +13,7 @@
display: flex;
flex-wrap: wrap;
align-items: center;
+ position: relative;
&:first-child {
border-left: none!important;
diff --git a/src/framework/theme/components/actions/actions.component.ts b/src/framework/theme/components/actions/actions.component.ts
index 3e4e74eee7..b43e686e94 100644
--- a/src/framework/theme/components/actions/actions.component.ts
+++ b/src/framework/theme/components/actions/actions.component.ts
@@ -24,6 +24,7 @@ import { convertToBoolProperty } from '../helpers';
+
`,
})
export class NbActionComponent {
@@ -44,6 +45,28 @@ export class NbActionComponent {
set disabled(val: boolean) {
this.disabledValue = convertToBoolProperty(val);
}
+
+ /**
+ * Badge text to display
+ * @type string
+ */
+ @Input() badgeText: string;
+
+ /**
+ * Badge status (adds specific styles):
+ * 'primary', 'info', 'success', 'warning', 'danger'
+ * @param {string} val
+ */
+ @Input() badgeStatus: string;
+
+ /**
+ * Badge position.
+ * Can be set to any class or to one of predefined positions:
+ * 'top left', 'top right', 'bottom left', 'bottom right'
+ * @type string
+ */
+ @Input() badgePosition: string;
+
}
/**
diff --git a/src/framework/theme/components/actions/actions.module.ts b/src/framework/theme/components/actions/actions.module.ts
index 9453f5a6a0..d8c08654a0 100644
--- a/src/framework/theme/components/actions/actions.module.ts
+++ b/src/framework/theme/components/actions/actions.module.ts
@@ -10,6 +10,8 @@ import { NbSharedModule } from '../shared/shared.module';
import { NbActionComponent, NbActionsComponent } from './actions.component';
+import { NbBadgeModule } from '../badge/badge.module';
+
const NB_ACTIONS_COMPONENTS = [
NbActionComponent,
NbActionsComponent,
@@ -18,6 +20,7 @@ const NB_ACTIONS_COMPONENTS = [
@NgModule({
imports: [
NbSharedModule,
+ NbBadgeModule,
],
declarations: [
...NB_ACTIONS_COMPONENTS,
diff --git a/src/framework/theme/components/badge/_badge.component.theme.scss b/src/framework/theme/components/badge/_badge.component.theme.scss
new file mode 100644
index 0000000000..049ad6a767
--- /dev/null
+++ b/src/framework/theme/components/badge/_badge.component.theme.scss
@@ -0,0 +1,27 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+@mixin nb-badge-theme() {
+ .nb-badge {
+ color: nb-theme(badge-fg-text);
+
+ &.nb-badge-primary {
+ background-color: nb-theme(badge-primary-bg-color);
+ }
+ &.nb-badge-info {
+ background-color: nb-theme(badge-info-bg-color);
+ }
+ &.nb-badge-success {
+ background-color: nb-theme(badge-success-bg-color);
+ }
+ &.nb-badge-warning {
+ background-color: nb-theme(badge-warning-bg-color);
+ }
+ &.nb-badge-danger {
+ background-color: nb-theme(badge-danger-bg-color);
+ }
+ }
+}
diff --git a/src/framework/theme/components/badge/badge.component.scss b/src/framework/theme/components/badge/badge.component.scss
new file mode 100644
index 0000000000..95d53bd97a
--- /dev/null
+++ b/src/framework/theme/components/badge/badge.component.scss
@@ -0,0 +1,22 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+.nb-badge {
+ position: absolute;
+ padding: 0.25em 0.4em;
+ font-size: 75%;
+ font-weight: 700;
+ line-height: 1;
+ text-align: center;
+ white-space: nowrap;
+ vertical-align: baseline;
+ border-radius: 0.25rem;
+
+ &.top { top: 0; }
+ &.right { right: 0; }
+ &.bottom { bottom: 0; }
+ &.left { left: 0; }
+}
diff --git a/src/framework/theme/components/badge/badge.component.ts b/src/framework/theme/components/badge/badge.component.ts
new file mode 100644
index 0000000000..4049fde5b0
--- /dev/null
+++ b/src/framework/theme/components/badge/badge.component.ts
@@ -0,0 +1,93 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+import { Component, Input, HostBinding } from '@angular/core';
+
+/**
+ * Badge is a simple labeling component.
+ * It can be used to add additional information to any content or highlight unread items.
+ *
+ * Element is absolute positioned, so parent should be
+ * [positioned element](https://developer.mozilla.org/en-US/docs/Web/CSS/position).
+ * It means parent `position` should be set to anything except `static`, e.g. `relative`,
+ * `absolute`, `fixed`, or `sticky`.
+ *
+ *
+ * @example Badge with default position and status(color):
+ *
+ * ```
+ *
+ * ```
+ *
+ * @example Badge located on the bottom right with warning status:
+ *
+ * ```
+ *
+ *
+ * ```
+ *
+ * @styles
+ *
+ * badge-fg-text:
+ * badge-primary-bg-color:
+ * badge-success-bg-color:
+ * badge-info-bg-color:
+ * badge-warning-bg-color:
+ * badge-danger-bg-color:
+ */
+@Component({
+ selector: 'nb-badge',
+ styleUrls: ['./badge.component.scss'],
+ template: `
+ {{text}}
+ `,
+})
+export class NbBadgeComponent {
+ static readonly TOP_LEFT = 'top left';
+ static readonly TOP_RIGHT = 'top right';
+ static readonly BOTTOM_LEFT = 'bottom left';
+ static readonly BOTTOM_RIGHT = 'bottom right';
+
+ static readonly STATUS_PRIMARY = 'primary';
+ static readonly STATUS_INFO = 'info';
+ static readonly STATUS_SUCCESS = 'success';
+ static readonly STATUS_WARNING = 'warning';
+ static readonly STATUS_DANGER = 'danger';
+
+ positionClass: string = NbBadgeComponent.TOP_RIGHT;
+ colorClass: string = NbBadgeComponent.STATUS_PRIMARY;
+
+ /**
+ * Text to display
+ * @type string
+ */
+ @Input() text: string = '';
+
+ /**
+ * Badge position
+ *
+ * Can be set to any class or to one of predefined positions:
+ * 'top left', 'top right', 'bottom left', 'bottom right'
+ * @type string
+ */
+ @Input() set position(value) {
+ if (value) {
+ this.positionClass = value;
+ }
+ }
+
+ /**
+ * Badge status (adds specific styles):
+ * 'primary', 'info', 'success', 'warning', 'danger'
+ * @param {string} val
+ * @type string
+ */
+ @Input() set status(value) {
+ if (value) {
+ this.colorClass = value;
+ }
+ }
+}
diff --git a/src/framework/theme/components/badge/badge.module.ts b/src/framework/theme/components/badge/badge.module.ts
new file mode 100644
index 0000000000..39997a8801
--- /dev/null
+++ b/src/framework/theme/components/badge/badge.module.ts
@@ -0,0 +1,14 @@
+/**
+ * @license
+ * Copyright Akveo. All Rights Reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ */
+
+import { NgModule } from '@angular/core';
+import { NbBadgeComponent } from './badge.component';
+
+@NgModule({
+ exports: [ NbBadgeComponent ],
+ declarations: [ NbBadgeComponent ],
+})
+export class NbBadgeModule { }
diff --git a/src/framework/theme/components/sidebar/sidebar.component.ts b/src/framework/theme/components/sidebar/sidebar.component.ts
index af1a613c7f..79776ed1df 100644
--- a/src/framework/theme/components/sidebar/sidebar.component.ts
+++ b/src/framework/theme/components/sidebar/sidebar.component.ts
@@ -55,6 +55,7 @@ export class NbSidebarFooterComponent {
* Sidebar also supports a `responsive` behavior, listening to window size change and changing its size respectably.
*
* @example Minimal sidebar example
+ *
* ```
*
* Sidebar content.
diff --git a/src/framework/theme/components/tabset/tabset.component.scss b/src/framework/theme/components/tabset/tabset.component.scss
index 61a9344d7a..2a877f967c 100644
--- a/src/framework/theme/components/tabset/tabset.component.scss
+++ b/src/framework/theme/components/tabset/tabset.component.scss
@@ -34,6 +34,7 @@ ul {
cursor: pointer;
margin-bottom: -1px;
text-align: center;
+ position: relative;
&.active a::before {
display: block;
diff --git a/src/framework/theme/components/tabset/tabset.component.ts b/src/framework/theme/components/tabset/tabset.component.ts
index 96ccae525e..3ec87f45c1 100644
--- a/src/framework/theme/components/tabset/tabset.component.ts
+++ b/src/framework/theme/components/tabset/tabset.component.ts
@@ -49,6 +49,27 @@ export class NbTabComponent {
}
}
+ /**
+ * Badge text to display
+ * @type string
+ */
+ @Input() badgeText: string;
+
+ /**
+ * Badge status (adds specific styles):
+ * 'primary', 'info', 'success', 'warning', 'danger'
+ * @param {string} val
+ */
+ @Input() badgeStatus: string;
+
+ /**
+ * Badge position.
+ * Can be set to any class or to one of predefined positions:
+ * 'top left', 'top right', 'bottom left', 'bottom right'
+ * @type string
+ */
+ @Input() badgePosition: string;
+
// TODO: it makes sense to add 'lazyLoad' input to 'nb-tabset' component and make this functionality configurable
init: boolean = false;
}
@@ -103,6 +124,11 @@ export class NbTabComponent {
(click)="selectTab(tab)"
[class.active]="tab.active">
{{ tab.tabTitle }}
+
+
diff --git a/src/framework/theme/components/tabset/tabset.module.ts b/src/framework/theme/components/tabset/tabset.module.ts
index 6e8a29e90f..c1de483510 100644
--- a/src/framework/theme/components/tabset/tabset.module.ts
+++ b/src/framework/theme/components/tabset/tabset.module.ts
@@ -9,6 +9,7 @@ import { NgModule } from '@angular/core';
import { NbSharedModule } from '../shared/shared.module';
import { NbTabsetComponent, NbTabComponent } from './tabset.component';
+import { NbBadgeModule } from '../badge/badge.module';
const NB_TABSET_COMPONENTS = [
NbTabsetComponent,
@@ -18,6 +19,7 @@ const NB_TABSET_COMPONENTS = [
@NgModule({
imports: [
NbSharedModule,
+ NbBadgeModule,
],
declarations: [
...NB_TABSET_COMPONENTS,
diff --git a/src/framework/theme/components/user/user.component.html b/src/framework/theme/components/user/user.component.html
index 9aca1e8d3c..b94bfde878 100644
--- a/src/framework/theme/components/user/user.component.html
+++ b/src/framework/theme/components/user/user.component.html
@@ -1,9 +1,12 @@
-
+
+
+
{{ getInitials() }}
+
diff --git a/src/framework/theme/components/user/user.component.scss b/src/framework/theme/components/user/user.component.scss
index 0c43b28ef6..40709af8b0 100644
--- a/src/framework/theme/components/user/user.component.scss
+++ b/src/framework/theme/components/user/user.component.scss
@@ -21,6 +21,7 @@
}
.user-picture {
+ position: relative;
border-radius: 50%;
flex-shrink: 0;
diff --git a/src/framework/theme/components/user/user.component.ts b/src/framework/theme/components/user/user.component.ts
index 9aa8b605fb..c49ef5b981 100644
--- a/src/framework/theme/components/user/user.component.ts
+++ b/src/framework/theme/components/user/user.component.ts
@@ -190,6 +190,27 @@ export class NbUserComponent {
this.inverseValue = convertToBoolProperty(val);
}
+ /**
+ * Badge text to display
+ * @type string
+ */
+ @Input() badgeText: string;
+
+ /**
+ * Badge status (adds specific styles):
+ * 'primary', 'info', 'success', 'warning', 'danger'
+ * @param {string} val
+ */
+ @Input() badgeStatus: string;
+
+ /**
+ * Badge position.
+ * Can be set to any class or to one of predefined positions:
+ * 'top left', 'top right', 'bottom left', 'bottom right'
+ * @type string
+ */
+ @Input() badgePosition: string;
+
/**
* Outputs when a context menu item is clicked
* @type EventEmitter
diff --git a/src/framework/theme/components/user/user.module.ts b/src/framework/theme/components/user/user.module.ts
index c41801aaeb..a81145d984 100644
--- a/src/framework/theme/components/user/user.module.ts
+++ b/src/framework/theme/components/user/user.module.ts
@@ -11,6 +11,7 @@ import { NbSharedModule } from '../shared/shared.module';
import {
NbUserComponent,
} from './user.component';
+import { NbBadgeModule } from '../badge/badge.module';
const NB_USER_COMPONENTS = [
NbUserComponent,
@@ -19,6 +20,7 @@ const NB_USER_COMPONENTS = [
@NgModule({
imports: [
NbSharedModule,
+ NbBadgeModule,
],
declarations: [
...NB_USER_COMPONENTS,
diff --git a/src/framework/theme/index.ts b/src/framework/theme/index.ts
index 31feab1eb2..4b66a6e559 100644
--- a/src/framework/theme/index.ts
+++ b/src/framework/theme/index.ts
@@ -24,3 +24,6 @@ export * from './components/search/search.module';
export * from './components/search/search.service';
export * from './components/checkbox/checkbox.component';
export * from './components/checkbox/checkbox.module';
+export * from './components/badge/badge.component';
+export * from './components/badge/badge.module';
+
diff --git a/src/framework/theme/styles/global/_components.scss b/src/framework/theme/styles/global/_components.scss
index c62a599d3b..973194ea93 100644
--- a/src/framework/theme/styles/global/_components.scss
+++ b/src/framework/theme/styles/global/_components.scss
@@ -14,7 +14,7 @@
@import '../../components/actions/actions.component.theme';
@import '../../components/search/search.component.theme';
@import '../../components/checkbox/checkbox.component.theme';
-
+@import '../../components/badge/badge.component.theme';
@mixin nb-theme-components() {
@@ -28,4 +28,5 @@
@include nb-actions-theme();
@include nb-search-theme();
@include nb-checkbox-theme();
+ @include nb-badge-theme();
}
diff --git a/src/framework/theme/styles/themes/_cosmic.scss b/src/framework/theme/styles/themes/_cosmic.scss
index e0700908d2..e0293c2838 100644
--- a/src/framework/theme/styles/themes/_cosmic.scss
+++ b/src/framework/theme/styles/themes/_cosmic.scss
@@ -115,6 +115,13 @@ $theme: (
smart-table-paging-fg-active: color-fg-heading,
smart-table-paging-bg-active: color-primary,
smart-table-paging-hover: rgba(0, 0, 0, 0.2),
+
+ badge-fg-text: color-white,
+ badge-primary-bg-color: color-primary,
+ badge-success-bg-color: color-success,
+ badge-info-bg-color: color-info,
+ badge-warning-bg-color: color-warning,
+ badge-danger-bg-color: color-danger,
);
// register the theme
diff --git a/src/framework/theme/styles/themes/_default.scss b/src/framework/theme/styles/themes/_default.scss
index 39e3091852..7ea515b2ca 100644
--- a/src/framework/theme/styles/themes/_default.scss
+++ b/src/framework/theme/styles/themes/_default.scss
@@ -398,6 +398,13 @@ $theme: (
modal-body-font-weight: font-weight-normal,
modal-body-font-size: font-size,
modal-separator: separator,
+
+ badge-fg-text: color-white,
+ badge-primary-bg-color: color-primary,
+ badge-success-bg-color: color-success,
+ badge-info-bg-color: color-info,
+ badge-warning-bg-color: color-warning,
+ badge-danger-bg-color: color-danger,
);
// register the theme