Skip to content

Commit 1d3a419

Browse files
authored
feat: show whether the property is reflected (#193)
1 parent 5f7183f commit 1d3a419

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.changeset/old-days-kick.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@api-viewer/common': patch
3+
'@api-viewer/docs': patch
4+
'@api-viewer/demo': patch
5+
'@api-viewer/tabs': patch
6+
'api-viewer-element': patch
7+
---
8+
9+
Show whether a property reflects to attribute

packages/api-common/src/manifest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type {
22
Attribute,
3-
ClassField as ManifestClassField,
43
ClassLike,
54
ClassMember,
65
ClassMethod,
@@ -9,6 +8,7 @@ import type {
98
CustomElement,
109
CustomElementDeclaration,
1110
CustomElementExport,
11+
CustomElementField,
1212
Event,
1313
Export,
1414
Package,
@@ -17,7 +17,7 @@ import type {
1717

1818
// FIXME: remove once new custom-elements-manifest version is released
1919
// https://github.com/webcomponents/custom-elements-manifest/pull/118
20-
type ClassField = ManifestClassField & {
20+
type ClassField = CustomElementField & {
2121
/**
2222
* Whether the property is read-only.
2323
*/

packages/api-docs/src/layout.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ const renderItem = (
2626
valueType?: string,
2727
value?: unknown,
2828
attribute?: string,
29-
isStatic?: boolean
29+
isStatic?: boolean,
30+
reflects?: boolean
3031
): TemplateResult => html`
3132
<div part="docs-item">
32-
${isStatic
33-
? html`<div part="docs-row"><div part="docs-tag">static</div></div>`
33+
${isStatic || reflects
34+
? html`<div part="docs-row">
35+
${isStatic ? html`<div part="docs-tag">static</div>` : nothing}
36+
${reflects ? html`<div part="docs-tag">reflected</div>` : nothing}
37+
</div>`
3438
: nothing}
3539
<div part="docs-row">
3640
<div part="docs-column" class="column-name-${prefix}">
@@ -164,7 +168,13 @@ class ApiDocsLayout extends LitElement {
164168
props,
165169
html`
166170
${props.map((prop) => {
167-
const { name, description, type, static: isStatic } = prop;
171+
const {
172+
name,
173+
description,
174+
type,
175+
static: isStatic,
176+
reflects
177+
} = prop;
168178
const attribute = attrs.find((x) => x.fieldName === name);
169179
return renderItem(
170180
'prop',
@@ -173,7 +183,8 @@ class ApiDocsLayout extends LitElement {
173183
type?.text,
174184
prop.default,
175185
attribute?.name,
176-
isStatic
186+
isStatic,
187+
reflects
177188
);
178189
})}
179190
`

0 commit comments

Comments
 (0)