Skip to content

Commit e00d4cc

Browse files
committed
chore: adding docs notes and todos to 2nd gen
1 parent 48e874d commit e00d4cc

File tree

8 files changed

+278
-104
lines changed

8 files changed

+278
-104
lines changed

first-gen/packages/badge/src/badge-overrides.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

second-gen/packages/core/components/badge/Badge.base.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export type FixedValues = (typeof FIXED_VALUES)[number];
5757

5858
/**
5959
* @element sp-badge-base
60-
* @property {BadgeVariant} variant - The variant of the badge.
61-
* @property {FixedValues} fixed - The fixed position of the badge.
62-
* @property {string[]} customStyles - The custom styles of the badge.
60+
* @attribute {ElementSize} size - The size of the badge.
61+
* @attribute {BadgeVariant} variant - The variant of the badge.
62+
* @attribute {FixedValues} fixed - The fixed position of the badge.
6363
*/
6464
export abstract class BadgeBase extends SizedMixin(
6565
ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot="icon"]'), ''),
@@ -73,6 +73,9 @@ export abstract class BadgeBase extends SizedMixin(
7373
@property({ type: String, reflect: true })
7474
public fixed?: FixedValues;
7575

76+
/**
77+
* @internal Used for rendering gap when the badge has an icon.
78+
*/
7679
protected get hasIcon(): boolean {
7780
return this.slotContentIsPresent;
7881
}

second-gen/packages/swc/.storybook/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const config = {
77
core: {
88
disableTelemetry: true,
99
},
10+
addons: [
11+
'@storybook/addon-docs',
12+
'@storybook/addon-a11y',
13+
'@storybook/addon-designs',
14+
],
1015
viteFinal: async (config) => {
1116
config.resolve = config.resolve || {};
1217
config.resolve.alias = {

second-gen/packages/swc/.storybook/preview.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import '../tokens/light-vars.css';
55
import '../tokens/medium-vars.css';
66
import '../tokens/global-vars.css';
77

8-
import { html } from 'lit';
98
import { setCustomElementsManifest } from '@storybook/web-components';
109
import customElements from './custom-elements.json';
1110

@@ -14,6 +13,7 @@ setCustomElementsManifest(customElements);
1413

1514
const preview = {
1615
parameters: {
16+
layout: 'centered',
1717
controls: {
1818
expanded: true,
1919
matchers: {
@@ -29,6 +29,7 @@ const preview = {
2929
},
3030
},
3131
},
32+
tags: ['autodocs'],
3233
};
3334

3435
export default preview;

second-gen/packages/swc/components/badge/Badge.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import { CSSResultArray, html, TemplateResult } from 'lit';
13+
import { CSSResultArray, html, PropertyValues, TemplateResult } from 'lit';
1414
import { property } from 'lit/decorators.js';
1515
import { classMap } from 'lit/directives/class-map.js';
1616
import { when } from 'lit/directives/when.js';
@@ -55,18 +55,14 @@ export type { FixedValues } from '@swc/core/components/badge';
5555
* @github https://github.com/adobe/spectrum-web-components/tree/main/...
5656
* @figma https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=36806-6551
5757
*
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.
6362
*
6463
* @slot - Text label of the badge
6564
* @slot icon - Optional icon that appears to the left of the label
6665
*
67-
* @csspart label - The text content area of the badge
68-
* @csspart icon - The icon area of the badge (when present)
69-
*
7066
* @example
7167
* <swc-badge variant="positive">New</swc-badge>
7268
*
@@ -122,4 +118,23 @@ export class Badge extends BadgeBase {
122118
</div>
123119
`;
124120
}
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+
}
125140
}

0 commit comments

Comments
 (0)