Each variation will be presented in the following sections.
A simple badge component with different states (e.g. error, success, notice,…) and flexible content.
veams install vc badge
bower install veams-component-badge --save
String
} [default] - Just pass a stringString
} - Modifier classesString
} - Define your badge type (i.e. alert, error, notice, success)String
} - Badge content{
"variations": {
"default": {
"docs": {
"variationName": "Default badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "default",
"badgeContent": "0"
}
},
"error": {
"docs": {
"variationName": "Error badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "error",
"badgeContent": "1"
}
},
"success": {
"docs": {
"variationName": "Success badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "success",
"badgeContent": "2"
}
},
"notice": {
"docs": {
"variationName": "Notice badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "notice",
"badgeContent": "3"
}
},
"alert": {
"docs": {
"variationName": "Alert badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "alert",
"badgeContent": "4"
}
},
"longMessage": {
"docs": {
"variationName": "Long message badge",
"sectionCenter": true
},
"settings": {
"badgeContextClass": false,
"badgeClasses": false
},
"content": {
"badgeType": "success",
"badgeContent": "This is my very long success message ..."
}
}
}
}
{{#unless content.badgeType}}
<h2 style="color: red">Please provide a badge type!</h2>
{{/unless}}
<div class="c-badge{{#if settings.badgeContextClass}}--{{settings.badgeContextClass}}{{else}}--default{{/if}}{{#if settings.badgeClasses}} {{settings.badgeClasses}}{{/if}}"
data-css="c-badge">
<span class="badge__content{{#if content.badgeType}} is-{{content.badgeType}}{{/if}}">
{{content.badgeContent}}
</span>
</div>
/* ===================================================
COMPONENT: BADGE
=================================================== */
/* ---------------------------------------------------
Global Variables
--------------------------------------------------- */
$badge-color-alert: #fff6bf;
$badge-color-error: #fbe3e4;
$badge-color-notice: #e5edf8;
$badge-color-success: #e6efc2;
/* ---------------------------------------------------
Helper mixins
--------------------------------------------------- */
@mixin badge($color: #999, $font-size: 2.5rem) {
background-color: $color;
border-radius: $font-size * 5;
color: darken($color, 60%);
font-size: $font-size;
line-height: 1;
padding: 1.2rem 2.7rem;
}
/* ---------------------------------------------------
Global Styles
--------------------------------------------------- */
[data-css="c-badge"] {
/*
Standard styles
----------------------- */
display: inline-block;
/*
Content classes
----------------------- */
.badge__content {
@include badge();
}
/*
Modifiers
----------------------- */
.is-alert {
@include badge($badge-color-alert);
}
.is-error {
@include badge($badge-color-error);
}
.is-notice {
@include badge($badge-color-notice);
}
.is-success {
@include badge($badge-color-success);
}
}
/* ---------------------------------------------------
Context: Default
--------------------------------------------------- */
.c-badge--default {
}
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-default">
0
</span>
</div>
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-error">
1
</span>
</div>
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-success">
2
</span>
</div>
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-notice">
3
</span>
</div>
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-alert">
4
</span>
</div>
<div class="c-badge--default" data-css="c-badge">
<span class="badge__content is-success">
This is my very long success message ...
</span>
</div>