Skip to content

Commit 843c922

Browse files
committed
added exported new css parts - fixes #755 #742
1 parent f7f6e5e commit 843c922

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

src/components/api-request.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ export default class ApiRequest extends LitElement {
403403
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
404404
schema-hide-read-only = "${this.schemaHideReadOnly.includes(this.method)}"
405405
schema-hide-write-only = "${this.schemaHideWriteOnly.includes(this.method)}"
406+
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
407+
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
408+
anchor:anchor, anchor-param-example:anchor-param-example"
406409
> </schema-tree>
407410
</div>`
408411
}
@@ -649,6 +652,7 @@ export default class ApiRequest extends LitElement {
649652
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
650653
schema-hide-read-only = "${this.schemaHideReadOnly}"
651654
schema-hide-write-only = "${this.schemaHideWriteOnly}"
655+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
652656
> </schema-table>
653657
`;
654658
} else if (this.schemaStyle === 'tree') {
@@ -663,6 +667,7 @@ export default class ApiRequest extends LitElement {
663667
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
664668
schema-hide-read-only = "${this.schemaHideReadOnly}"
665669
schema-hide-write-only = "${this.schemaHideWriteOnly}"
670+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
666671
> </schema-tree>
667672
`;
668673
}

src/components/schema-table.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ export default class SchemaTable extends LitElement {
9292
${this.allowSchemaDescriptionExpandToggle === 'true'
9393
? html`
9494
<div style="flex:1"></div>
95-
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
95+
<div part="schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
9696
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
9797
</div>
9898
`
9999
: ''
100100
}
101101
</div>
102102
${this.data?.['::description']
103-
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
103+
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
104104
: ''
105105
}
106106
<div style = 'border:1px solid var(--light-border-color)'>

src/components/schema-tree.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ export default class SchemaTree extends LitElement {
107107
${this.allowSchemaDescriptionExpandToggle === 'true'
108108
? html`
109109
<div style="flex:1"></div>
110-
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
110+
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
111111
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
112112
</div>
113113
`
114114
: ''
115115
}
116116
</div>
117117
${this.data?.['::description']
118-
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
118+
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
119119
: ''
120120
}
121121
${this.data

src/templates/callback-template.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function callbackTemplate(callbacks) {
4242
fetch-credentials = "${this.fetchCredentials}"
4343
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
4444
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
45-
anchor:anchor, anchor-param-example:anchor-param-example"
45+
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
4646
> </api-request>
4747
4848
<api-response
@@ -58,7 +58,8 @@ export default function callbackTemplate(callbacks) {
5858
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
5959
schema-hide-read-only = "${this.schemaHideReadOnly}"
6060
schema-hide-write-only = "false"
61-
exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy"
61+
exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
62+
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
6263
> </api-response>
6364
</div>
6465
</div>

src/templates/components-template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function schemaBodyTemplate(sComponent) {
2121
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
2222
schema-hide-read-only = "false"
2323
schema-hide-write-only = "${this.schemaHideWriteOnly}"
24+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
2425
> </schema-tree> `
2526
: html`
2627
<schema-tree
@@ -31,6 +32,7 @@ function schemaBodyTemplate(sComponent) {
3132
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
3233
schema-hide-read-only = "false"
3334
schema-hide-write-only = "${this.schemaHideWriteOnly}"
35+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
3436
> </schema-tree>`
3537
}
3638
</div>`;

src/templates/endpoint-template.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ function onExpandCollapseAll(e, action = 'expand-all') {
4646
/* eslint-disable indent */
4747
function endpointHeadTemplate(path, pathsExpanded = false) {
4848
return html`
49-
<summary @click="${(e) => { toggleExpand.call(this, path, e); }}" part="endpoint-head" class='endpoint-head ${path.method} ${path.deprecated ? 'deprecated' : ''} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
50-
<div part="endpoint-head-method" class="method ${path.method} ${path.deprecated ? 'deprecated' : ''}"> ${path.method} </div>
51-
<div class="path ${path.deprecated ? 'deprecated' : ''}">
49+
<summary @click="${(e) => { toggleExpand.call(this, path, e); }}" part="section-endpoint-head" class='endpoint-head ${path.method} ${path.deprecated ? 'deprecated' : ''} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
50+
<div part="section-endpoint-head-method" class="method ${path.method} ${path.deprecated ? 'deprecated' : ''}"> ${path.method} </div>
51+
<div part="section-endpoint-head-path" class="path ${path.deprecated ? 'deprecated' : ''}">
5252
${path.path}
5353
${path.isWebhook ? html`<span style="font-family: var(--font-regular); font-size: var(--); font-size: var(--font-size-small); color:var(--primary-color); margin-left: 16px"> Webhook</span>` : ''}
5454
</div>
@@ -62,7 +62,7 @@ function endpointHeadTemplate(path, pathsExpanded = false) {
6262
${this.showSummaryWhenCollapsed
6363
? html`
6464
<div class="only-large-screen" style="min-width:60px; flex:1"></div>
65-
<div part="endpoint-head-summary" class="descr">${path.summary || path.shortSummary} </div>`
65+
<div part="section-endpoint-head-description" class="descr">${path.summary || path.shortSummary} </div>`
6666
: ''
6767
}
6868
</summary>
@@ -88,27 +88,27 @@ function endpointBodyTemplate(path) {
8888

8989
const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate(path.xCodeSamples) : '';
9090
return html`
91-
<div class='endpoint-body ${path.method} ${path.deprecated ? 'deprecated' : ''}'>
91+
<div part="section-end-point-body" class='endpoint-body ${path.method} ${path.deprecated ? 'deprecated' : ''}'>
9292
<div class="summary">
9393
${path.summary
94-
? html`<div class="title">${path.summary}<div>`
94+
? html`<div class="title" part="section-end-point-body-title">${path.summary}<div>`
9595
: path.shortSummary !== path.description
96-
? html`<div class="title">${path.shortSummary}</div>`
96+
? html`<div class="title" part="section-end-point-body-title">${path.shortSummary}</div>`
9797
: ''
9898
}
9999
${path.xBadges && path.xBadges?.length > 0
100100
? html`
101101
<div style="display:flex; flex-wrap:wrap;font-size: var(--font-size-small);">
102102
${path.xBadges.map((v) => (
103-
html`<span style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
103+
html`<span part="endpoint-badge" style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
104104
))
105105
}
106106
</div>
107107
`
108108
: ''
109109
}
110110
111-
${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
111+
${path.description ? html`<div part="section-end-point-body-description" class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
112112
<slot name="${path.elementId}"></slot>
113113
${pathSecurityTemplate.call(this, path.security)}
114114
${codeSampleTabPanel}
@@ -141,7 +141,7 @@ function endpointBodyTemplate(path) {
141141
fetch-credentials = "${this.fetchCredentials}"
142142
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
143143
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
144-
anchor:anchor, anchor-param-example:anchor-param-example"
144+
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
145145
> </api-request>
146146
147147
${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
@@ -160,8 +160,9 @@ function endpointBodyTemplate(path) {
160160
schema-hide-read-only = "${path.isWebhook ? this.schemaHideWriteOnly : this.schemaHideReadOnly}"
161161
schema-hide-write-only = "${path.isWebhook ? this.schemaHideReadOnly : this.schemaHideWriteOnly}"
162162
selected-status = "${Object.keys(path.responses || {})[0] || ''}"
163-
exportparts =
164-
"btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param, anchor:anchor, anchor-param-example:anchor-param-example, btn-clear-resp:btn-clear-resp"
163+
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, file-input:file-input,
164+
textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param, anchor:anchor, anchor-param-example:anchor-param-example, btn-clear-resp:btn-clear-resp,
165+
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
165166
> </api-response>
166167
</div>
167168
</div>`;
@@ -202,7 +203,7 @@ export default function endpointTemplate(showExpandCollapse = true, showTags = t
202203
}
203204
return true;
204205
}).map((path) => html`
205-
<section id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
206+
<section part="section-end-point" id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
206207
${endpointHeadTemplate.call(this, path, pathsExpanded)}
207208
${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
208209
</section>`)

src/templates/expanded-endpoint-template.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function expandedEndpointBodyTemplate(path, tagName = '') {
9393
fetch-credentials = "${this.fetchCredentials}"
9494
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
9595
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
96-
anchor:anchor, anchor-param-example:anchor-param-example"
96+
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
9797
> </api-request>
9898
9999
${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
@@ -111,7 +111,8 @@ export function expandedEndpointBodyTemplate(path, tagName = '') {
111111
schema-hide-read-only = "${path.isWebhook ? this.schemaHideReadOnly : false}"
112112
schema-hide-write-only = "${path.isWebhook ? false : this.schemaHideWriteOnly}"
113113
selected-status = "${Object.keys(path.responses || {})[0] || ''}"
114-
exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy"
114+
exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
115+
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
115116
> </api-response>
116117
</div>
117118
</div>

src/templates/server-template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function serverVarsTemplate() {
3535
// const selectedServerObj = this.resolvedSpec.servers.find((v) => (v.url === this.selectedServer));
3636
return this.selectedServer && this.selectedServer.variables
3737
? html`
38-
<div class="table-title"> SERVER VARIABLES</div>
38+
<div class="table-title">SERVER VARIABLES</div>
3939
<table class='m-table'>
4040
${Object.entries(this.selectedServer.variables).map((kv) => html`
4141
<tr>
@@ -86,7 +86,7 @@ export default function serverTemplate() {
8686
if (!this.resolvedSpec || this.resolvedSpec.specLoadError) { return ''; }
8787
return html`
8888
<section id = 'servers' part="section-servers" style="text-align:left; direction:ltr; margin-top:24px; margin-bottom:24px;" class='regular-font observe-me ${'read focused'.includes(this.renderStyle) ? 'section-gap--read-mode' : 'section-gap'}'>
89-
<div class = 'sub-title'>API SERVER</div>
89+
<div part = "section-servers-title" class = "sub-title">API SERVER</div>
9090
<div class = 'mono-font' style='margin: 12px 0; font-size:calc(var(--font-size-small) + 1px);'>
9191
${!this.resolvedSpec.servers || this.resolvedSpec.servers?.length === 0
9292
? ''

0 commit comments

Comments
 (0)