diff --git a/exports/badge.d.ts b/exports/badge.d.ts new file mode 100644 index 0000000000..ebd7f25deb --- /dev/null +++ b/exports/badge.d.ts @@ -0,0 +1 @@ +export * from './components/badge/Badge'; \ No newline at end of file diff --git a/exports/badge.js b/exports/badge.js new file mode 100644 index 0000000000..5cf477dda8 --- /dev/null +++ b/exports/badge.js @@ -0,0 +1,2 @@ +'use strict'; +module.exports = require('./components/badge/Badge.vue'); \ No newline at end of file diff --git a/src/components/badge/Badge.d.ts b/src/components/badge/Badge.d.ts new file mode 100644 index 0000000000..9ab326c77f --- /dev/null +++ b/src/components/badge/Badge.d.ts @@ -0,0 +1,9 @@ +import Vue from 'vue'; + +declare class Badge extends Vue { + value?: any; + severity?: string; + size?: string; +} + +export default Badge; \ No newline at end of file diff --git a/src/components/badge/Badge.vue b/src/components/badge/Badge.vue new file mode 100644 index 0000000000..d9f49efd13 --- /dev/null +++ b/src/components/badge/Badge.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/main.js b/src/main.js index 49dfd8f6bd..af8128dd9e 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ import Accordion from './components/accordion/Accordion'; import AccordionTab from './components/accordiontab/AccordionTab'; import Avatar from './components/avatar/Avatar'; import AvatarGroup from './components/avatargroup/AvatarGroup'; +import Badge from './components/badge/Badge'; import BlockUI from './components/blockui/BlockUI'; import Breadcrumb from './components/breadcrumb/Breadcrumb'; import Button from './components/button/Button'; @@ -117,6 +118,7 @@ app.component('AccordionTab', AccordionTab); app.component('Avatar', Avatar); app.component('AvatarGroup', AvatarGroup); app.component('AutoComplete', AutoComplete); +app.component('Badge', Badge); app.component('BlockUI', BlockUI); app.component('Breadcrumb', Breadcrumb); app.component('Button', Button); diff --git a/src/views/badge/BadgeDemo.vue b/src/views/badge/BadgeDemo.vue index f2fe5388bf..ced7c0c8da 100644 --- a/src/views/badge/BadgeDemo.vue +++ b/src/views/badge/BadgeDemo.vue @@ -10,53 +10,25 @@
Numbers
-
- 2 - 8 - 4 - 12 - 3 -
- -
Tags
-
- Primary - Success - Info - Warning - Danger -
- -
Pills
-
- Primary - Success - Info - Warning - Danger -
+ + + + +
Positioned Badge
- - - 2 - - - -
diff --git a/src/views/badge/BadgeDoc.vue b/src/views/badge/BadgeDoc.vue index b7c7a4bdab..914e9f39c9 100644 --- a/src/views/badge/BadgeDoc.vue +++ b/src/views/badge/BadgeDoc.vue @@ -2,54 +2,43 @@
-
Getting Started
-

A badge is offered as pure css rather than a component.

+
Import
+
+
+import Badge from 'primevue/badge';
 
-				
Numbers
-

Use .p-badge class to display numbers inside badges.

+
+ +
Getting Started
+

Content of the badge is specified using the value property.

 
-<span class="p-badge">2</span>
+<Badge value="2"></Badge>
 
 
-
Tags
-

Tags are optimized for text rather than number and used with the .p-tag class. For more rounded styling like pills, add the .p-tag-rounded class

+
Positoning
+

A badge can easily be positioned relative to another element by wrapping it.

 
-<span class="p-tag">New</span>
-<span class="p-tag p-tag-rounded">New</span>
+<Badge value="2">
+    <i class="pi pi-bell" style="font-size: 2rem"></i>
+</Badge>
 
 
-
Severities
-

Different options are available as severity levels with.

+

Different color options are available as severity levels.

    -
  • .p-badge-secondary
  • -
  • .p-badge-success
  • -
  • .p-badge-info
  • -
  • .p-badge-warning
  • -
  • .p-badge-danger
  • +
  • secondary
  • +
  • success
  • +
  • info
  • +
  • warning
  • +
  • danger
-
Positoning
-

A badge can easily be positioned relative to another element when both are wrapped inside an element with p-overlay-badge class.

-
-
-<span class="p-overlay-badge">
-    <i class="pi pi-bell" style="font-size: 2em"></i>
-    <span class="p-badge">2</span>
-</span>
-
-<span class="p-overlay-badge">
-    <Button type="button" label="New" />
-    <span class="p-badge p-badge-warning">5</span>
-</span>
-
-
-
Inline Button Badges
+
Button Badges

Buttons provide integrated badge support with the badge and badgeClass properties.

@@ -60,20 +49,20 @@
 
Sizes
-

Badge sizes are adjusted with additional classes.

+

Badge sizes are adjusted with the size property that accepts "large" and "xlarge" as the possible alternatives to the default size.

 
-<span class="p-badge">2</span>
-<span class="p-badge p-badge-l p-badge-success">4</span>
-<span class="p-badge p-badge-xl p-badge-warning">6</span>
+<Badge value="2"></Badge>
+<Badge value="4" size="large" severity="warning"></Badge>
+<Badge value="6" size="xlarge" severity="success"></Badge>
 
 

In addition, when placed inside another element, badge sizes can also derive their size from their parent.

 
-<h1>Heading 1 <span class="p-tag p-tag-success">New</span></h1>
-<h2>Heading 2 <span class="p-tag p-tag-success">New</span></h2>
+<h1>Heading 1 <Badge value="New"></Badge></h1>
+<h2>Heading 2 <Badge value="New"></Badge></h2>
 
 
@@ -92,24 +81,16 @@ p-badge Badge element - - p-tag - Tag element - - - p-tag-rounded - Rounded tag element - p-overlay-badge Wrapper of a badge and its target. - p-badge-l + p-badge-lg Large badge element - p-badge-l + p-badge-xl Extra large badge element @@ -126,54 +107,26 @@