Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(badge)!: remove BaseBadge #2629

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/remove-basebadge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bennypowers marked this conversation as resolved.
Show resolved Hide resolved
"@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
Loading