Skip to content

Commit

Permalink
feat: show whether the property is reflected (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendera authored Nov 3, 2023
1 parent 5f7183f commit 1d3a419
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .changeset/old-days-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@api-viewer/common': patch
'@api-viewer/docs': patch
'@api-viewer/demo': patch
'@api-viewer/tabs': patch
'api-viewer-element': patch
---

Show whether a property reflects to attribute
4 changes: 2 additions & 2 deletions packages/api-common/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
Attribute,
ClassField as ManifestClassField,
ClassLike,
ClassMember,
ClassMethod,
Expand All @@ -9,6 +8,7 @@ import type {
CustomElement,
CustomElementDeclaration,
CustomElementExport,
CustomElementField,
Event,
Export,
Package,
Expand All @@ -17,7 +17,7 @@ import type {

// FIXME: remove once new custom-elements-manifest version is released
// https://github.com/webcomponents/custom-elements-manifest/pull/118
type ClassField = ManifestClassField & {
type ClassField = CustomElementField & {
/**
* Whether the property is read-only.
*/
Expand Down
21 changes: 16 additions & 5 deletions packages/api-docs/src/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ const renderItem = (
valueType?: string,
value?: unknown,
attribute?: string,
isStatic?: boolean
isStatic?: boolean,
reflects?: boolean
): TemplateResult => html`
<div part="docs-item">
${isStatic
? html`<div part="docs-row"><div part="docs-tag">static</div></div>`
${isStatic || reflects
? html`<div part="docs-row">
${isStatic ? html`<div part="docs-tag">static</div>` : nothing}
${reflects ? html`<div part="docs-tag">reflected</div>` : nothing}
</div>`
: nothing}
<div part="docs-row">
<div part="docs-column" class="column-name-${prefix}">
Expand Down Expand Up @@ -164,7 +168,13 @@ class ApiDocsLayout extends LitElement {
props,
html`
${props.map((prop) => {
const { name, description, type, static: isStatic } = prop;
const {
name,
description,
type,
static: isStatic,
reflects
} = prop;
const attribute = attrs.find((x) => x.fieldName === name);
return renderItem(
'prop',
Expand All @@ -173,7 +183,8 @@ class ApiDocsLayout extends LitElement {
type?.text,
prop.default,
attribute?.name,
isStatic
isStatic,
reflects
);
})}
`
Expand Down

0 comments on commit 1d3a419

Please sign in to comment.