Skip to content

Commit

Permalink
fix(badge)!: remove BaseBadge
Browse files Browse the repository at this point in the history
Closes #2619
  • Loading branch information
bennypowers committed Apr 11, 2024
1 parent 75b5958 commit d912ffa
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .changeset/remove-basebadge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@patternfly/elements": major
---
`<pf-badge>`: Removed `BaseBadge` class. Reimplement (recommended) or extend `PfBadge`.
1 change: 0 additions & 1 deletion elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"./pf-avatar/pf-avatar.js": "./pf-avatar/pf-avatar.js",
"./pf-back-to-top/pf-back-to-top.js": "./pf-back-to-top/pf-back-to-top.js",
"./pf-background-image/pf-background-image.js": "./pf-background-image/pf-background-image.js",
"./pf-badge/BaseBadge.js": "./pf-badge/BaseBadge.js",
"./pf-badge/pf-badge.js": "./pf-badge/pf-badge.js",
"./pf-banner/pf-banner.js": "./pf-banner/pf-banner.js",
"./pf-button/BaseButton.js": "./pf-button/BaseButton.js",
Expand Down
6 changes: 0 additions & 6 deletions elements/pf-badge/BaseBadge.css

This file was deleted.

34 changes: 0 additions & 34 deletions elements/pf-badge/BaseBadge.ts

This file was deleted.

4 changes: 4 additions & 0 deletions elements/pf-badge/pf-badge.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
:host {
position: relative;
white-space: nowrap;
text-align: center;
display: inline-block;
border-radius: var(--pf-c-badge--BorderRadius,
var(--pf-global--BorderRadius--lg, 180em));
min-width: var(--pf-c-badge--MinWidth,
Expand Down
28 changes: 24 additions & 4 deletions elements/pf-badge/pf-badge.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { LitElement, html } from 'lit';
import { customElement } from 'lit/decorators/custom-element.js';
import { property } from 'lit/decorators/property.js';

import { BaseBadge } from './BaseBadge.js';

import styles from './pf-badge.css';

/**
Expand Down Expand Up @@ -31,18 +30,39 @@ import styles from './pf-badge.css';


@customElement('pf-badge')
export class PfBadge extends BaseBadge {
static readonly styles = [...BaseBadge.styles, styles];
export class PfBadge extends LitElement {
static readonly styles = [styles];

/**
* Denotes the state-of-affairs this badge represents
* Options include read and unread
*/
@property({ reflect: true }) state?: 'unread' | 'read';

/**
* Sets a numeric value for a badge.
*
* You can pair it with `threshold` attribute to add a `+` sign
* if the number exceeds the threshold value.
*/
@property({ reflect: true, type: Number }) number?: number;

/**
* Sets a threshold for the numeric value and adds `+` sign if
* the numeric value exceeds the threshold value.
*/
@property({ reflect: true, type: Number }) threshold?: number;

override render() {
const { threshold, number, textContent } = this;
const displayText =
(threshold && number && (threshold < number)) ? `${threshold.toString()}+`
: (number != null) ? number.toString()
: textContent ?? '';
return html`
<span>${displayText}</span>
`;
}
}

declare global {
Expand Down
1 change: 0 additions & 1 deletion elements/pf-tooltip/pf-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { bound } from '@patternfly/pfe-core/decorators/bound.js';

import { StringListConverter } from '@patternfly/pfe-core';


import styles from './pf-tooltip.css';

const EnterEvents = ['focusin', 'tap', 'click', 'mouseenter'];
Expand Down

0 comments on commit d912ffa

Please sign in to comment.