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

feat: support reflects flag #193

Merged
merged 3 commits into from
Nov 3, 2023
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
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