Skip to content

Commit 5f7183f

Browse files
authored
feat: show whether the property is static (#190)
1 parent be9c5a5 commit 5f7183f

File tree

10 files changed

+95
-3
lines changed

10 files changed

+95
-3
lines changed

.changeset/lazy-crabs-yell.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@api-viewer/common': patch
3+
'@api-viewer/demo': patch
4+
'@api-viewer/docs': patch
5+
'@api-viewer/tabs': patch
6+
'api-viewer-element': patch
7+
---
8+
9+
Added the ability to show whether a property is static

docs/assets/custom-elements.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@
105105
"name": "_boundBodyKeyup",
106106
"privacy": "private"
107107
},
108+
{
109+
"kind": "field",
110+
"name": "version",
111+
"type": {
112+
"text": "string"
113+
},
114+
"static": true,
115+
"default": "'1.0.0'",
116+
"description": "Version of the component"
117+
},
108118
{
109119
"kind": "method",
110120
"name": "focus",
@@ -334,6 +344,16 @@
334344
"privacy": "private",
335345
"default": "this._onOpened.bind(this)"
336346
},
347+
{
348+
"kind": "field",
349+
"name": "version",
350+
"type": {
351+
"text": "string"
352+
},
353+
"static": true,
354+
"default": "'1.0.0'",
355+
"description": "Version of the component"
356+
},
337357
{
338358
"kind": "field",
339359
"name": "focused",
@@ -500,6 +520,16 @@
500520
"default": "'en-GB'",
501521
"description": "Locale code used for formatting.",
502522
"attribute": "locale"
523+
},
524+
{
525+
"kind": "field",
526+
"name": "version",
527+
"type": {
528+
"text": "string"
529+
},
530+
"static": true,
531+
"default": "'1.0.0'",
532+
"description": "Version of the component"
503533
}
504534
],
505535
"attributes": [
@@ -691,6 +721,16 @@
691721
"attribute": "indeterminate",
692722
"reflects": true
693723
},
724+
{
725+
"kind": "field",
726+
"name": "version",
727+
"type": {
728+
"text": "string"
729+
},
730+
"static": true,
731+
"default": "'1.0.0'",
732+
"description": "Version of the component"
733+
},
694734
{
695735
"kind": "method",
696736
"name": "setBounds",

docs/docs/api/styling.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ The following custom CSS properties are available:
2424
| `--ave-tab-color` | Inactive tabs color |
2525
| `--ave-tab-selected-color` | Selected tab color |
2626
| `--ave-tab-indicator-size` | Size of the selected tab indicator |
27+
| `--ave-tag-background-color` | Background color of tags (e.g., `static`) |
28+
| `--ave-tag-border-color` | Color of tag borders |
29+
| `--ave-tag-color` | Color of tags |
2730

2831
## CSS shadow parts
2932

fixtures/lit/src/expansion-panel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export class ExpansionPanel extends OpenedMixin(LitElement) {
5151

5252
private _boundBodyKeyup = this._onBodyKeyup.bind(this);
5353

54+
/**
55+
* Version of the component
56+
*/
57+
static version = '1.0.0';
58+
5459
static get styles(): CSSResult {
5560
return css`
5661
:host {

fixtures/lit/src/fancy-accordion.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class FancyAccordion extends LitElement {
4141

4242
private _boundOnOpened = this._onOpened.bind(this) as EventListener;
4343

44+
/**
45+
* Version of the component
46+
*/
47+
static version = '1.0.0';
48+
4449
static get styles(): CSSResult {
4550
return css`
4651
:host {

fixtures/lit/src/intl-currency.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export class IntlCurrency extends LitElement {
4444
*/
4545
@property() locale: string | null | undefined = 'en-GB';
4646

47+
/**
48+
* Version of the component
49+
*/
50+
static version = '1.0.0';
51+
4752
static get styles(): CSSResult {
4853
return css`
4954
:host {

fixtures/lit/src/progress-bar.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export class ProgressBar extends LitElement {
5959
*/
6060
@property({ type: Boolean, reflect: true }) indeterminate = false;
6161

62+
/**
63+
* Version of the component
64+
*/
65+
static version = '1.0.0';
66+
6267
static get styles(): CSSResult {
6368
return css`
6469
:host {

packages/api-common/src/shared-styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export default css`
2525
--ave-link-hover-color: #d63200;
2626
--ave-tab-indicator-size: 2px;
2727
--ave-tab-color: rgba(0, 0, 0, 0.54);
28+
--ave-tag-background-color: #e2e3e5;
29+
--ave-tag-border-color: #d6d8db;
30+
--ave-tag-color: #383d41;
2831
--ave-monospace-font: Menlo, 'DejaVu Sans Mono', 'Liberation Mono', Consolas,
2932
'Courier New', monospace;
3033
}

packages/api-docs/src/layout.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ const renderItem = (
2525
description?: string,
2626
valueType?: string,
2727
value?: unknown,
28-
attribute?: string
28+
attribute?: string,
29+
isStatic?: boolean
2930
): TemplateResult => html`
3031
<div part="docs-item">
32+
${isStatic
33+
? html`<div part="docs-row"><div part="docs-tag">static</div></div>`
34+
: nothing}
3135
<div part="docs-row">
3236
<div part="docs-column" class="column-name-${prefix}">
3337
<div part="docs-label">Name</div>
@@ -140,6 +144,8 @@ class ApiDocsLayout extends LitElement {
140144
cssParts
141145
].every((arr) => arr.length === 0);
142146

147+
props.sort((p) => (p.static ? -1 : 1));
148+
143149
const attributes = attrs.filter(
144150
(x) => !props.some((y) => y.name === x.fieldName)
145151
);
@@ -158,15 +164,16 @@ class ApiDocsLayout extends LitElement {
158164
props,
159165
html`
160166
${props.map((prop) => {
161-
const { name, description, type } = prop;
167+
const { name, description, type, static: isStatic } = prop;
162168
const attribute = attrs.find((x) => x.fieldName === name);
163169
return renderItem(
164170
'prop',
165171
name,
166172
description,
167173
type?.text,
168174
prop.default,
169-
attribute?.name
175+
attribute?.name,
176+
isStatic
170177
);
171178
})}
172179
`

packages/api-docs/src/styles.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ export default css`
4040
border-top: solid 1px var(--ave-border-color);
4141
}
4242
43+
[part='docs-tag'] {
44+
background-color: var(--ave-tag-background-color);
45+
border: 1px solid var(--ave-tag-border-color);
46+
border-radius: 3px;
47+
color: var(--ave-tag-color);
48+
display: inline-block;
49+
font-size: 0.75rem;
50+
padding: 1px 5px;
51+
}
52+
4353
[part='docs-description'] {
4454
display: block;
4555
padding: 0 1rem;

0 commit comments

Comments
 (0)