Add pill variation to badge

This commit is contained in:
Cory LaViska
2020-07-16 15:31:46 -04:00
parent a65b0848e4
commit 79a48a3cc2
5 changed files with 41 additions and 12 deletions

8
src/components.d.ts vendored
View File

@@ -47,6 +47,10 @@ export namespace Components {
"shape": 'circle' | 'square' | 'rounded';
}
interface SlBadge {
/**
* Set to true to draw a pill-style badge with rounded edges.
*/
"pill": boolean;
/**
* The badge's type.
*/
@@ -1105,6 +1109,10 @@ declare namespace LocalJSX {
"shape"?: 'circle' | 'square' | 'rounded';
}
interface SlBadge {
/**
* Set to true to draw a pill-style badge with rounded edges.
*/
"pill"?: boolean;
/**
* The badge's type.
*/

View File

@@ -2,8 +2,6 @@
:host {
display: inline-flex;
border-radius: var(--sl-border-radius-pill);
pointer-events: none;
}
.badge {
@@ -14,9 +12,10 @@
font-weight: var(--sl-font-weight-semibold);
letter-spacing: var(--sl-letter-spacing-normal);
line-height: 1;
border-radius: inherit;
border-radius: var(--sl-border-radius-small);
white-space: nowrap;
padding: 4px 8px;
padding: 3px 6px;
pointer-events: none;
user-select: none;
cursor: inherit;
}
@@ -49,3 +48,11 @@
background-color: var(--sl-color-danger-50);
color: var(--sl-color-white);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pill modifiers
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.badge--pill {
border-radius: var(--sl-border-radius-pill);
}

View File

@@ -21,6 +21,9 @@ export class Badge {
/** The badge's type. */
@Prop() type: 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'text' = 'primary';
/** Set to true to draw a pill-style badge with rounded edges. */
@Prop() pill = false;
render() {
return (
<span
@@ -35,7 +38,8 @@ export class Badge {
'badge--info': this.type === 'info',
'badge--warning': this.type === 'warning',
'badge--danger': this.type === 'danger',
'badge--text': this.type === 'text'
'badge--text': this.type === 'text',
'badge--pill': this.pill
}}
role="status"
>