|
10 | 10 | * governing permissions and limitations under the License.
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -import { CSSResultArray, html, TemplateResult } from 'lit'; |
| 13 | +import { CSSResultArray, html, PropertyValues, TemplateResult } from 'lit'; |
14 | 14 | import { property } from 'lit/decorators.js';
|
15 | 15 | import { classMap } from 'lit/directives/class-map.js';
|
16 | 16 | import { when } from 'lit/directives/when.js';
|
@@ -55,18 +55,14 @@ export type { FixedValues } from '@swc/core/components/badge';
|
55 | 55 | * @github https://github.com/adobe/spectrum-web-components/tree/main/...
|
56 | 56 | * @figma https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=36806-6551
|
57 | 57 | *
|
58 |
| - * @property {BadgeVariant} variant - The variant of the badge. |
59 |
| - * @property {boolean} subtle - Whether the badge is subtle. |
60 |
| - * @property {boolean} outline - Whether the badge is outlined. |
61 |
| - * @property {FixedValues} fixed - The fixed position of the badge. |
62 |
| - * @property {string[]} customStyles - The custom styles of the badge. |
| 58 | + * @attribute {BadgeVariant} variant - The variant of the badge. |
| 59 | + * @attribute {boolean} subtle - Whether the badge is subtle. |
| 60 | + * @attribute {boolean} outline - Whether the badge is outlined. |
| 61 | + * @attribute {FixedValues} fixed - The fixed position of the badge. |
63 | 62 | *
|
64 | 63 | * @slot - Text label of the badge
|
65 | 64 | * @slot icon - Optional icon that appears to the left of the label
|
66 | 65 | *
|
67 |
| - * @csspart label - The text content area of the badge |
68 |
| - * @csspart icon - The icon area of the badge (when present) |
69 |
| - * |
70 | 66 | * @example
|
71 | 67 | * <swc-badge variant="positive">New</swc-badge>
|
72 | 68 | *
|
@@ -122,4 +118,23 @@ export class Badge extends BadgeBase {
|
122 | 118 | </div>
|
123 | 119 | `;
|
124 | 120 | }
|
| 121 | + |
| 122 | + protected override update(changedProperties: PropertyValues): void { |
| 123 | + super.update(changedProperties); |
| 124 | + if (window.__swc?.DEBUG) { |
| 125 | + if ( |
| 126 | + this.outline && |
| 127 | + !BADGE_VARIANTS_SEMANTIC.includes(this.variant) |
| 128 | + ) { |
| 129 | + window.__swc.warn( |
| 130 | + this, |
| 131 | + `<${this.localName}> element only supports the outline styling if the variant is a semantic color variant.`, |
| 132 | + 'https://opensource.adobe.com/spectrum-web-components/components/badge/#variants', |
| 133 | + { |
| 134 | + issues: [...BADGE_VARIANTS_SEMANTIC], |
| 135 | + } |
| 136 | + ); |
| 137 | + } |
| 138 | + } |
| 139 | + } |
125 | 140 | }
|
0 commit comments