Skip to content

Commit

Permalink
added exported new css parts - fixes #755 #742
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed May 25, 2022
1 parent f7f6e5e commit 843c922
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/components/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ export default class ApiRequest extends LitElement {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
schema-hide-read-only = "${this.schemaHideReadOnly.includes(this.method)}"
schema-hide-write-only = "${this.schemaHideWriteOnly.includes(this.method)}"
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,
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
anchor:anchor, anchor-param-example:anchor-param-example"
> </schema-tree>
</div>`
}
Expand Down Expand Up @@ -649,6 +652,7 @@ export default class ApiRequest extends LitElement {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
schema-hide-read-only = "${this.schemaHideReadOnly}"
schema-hide-write-only = "${this.schemaHideWriteOnly}"
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </schema-table>
`;
} else if (this.schemaStyle === 'tree') {
Expand All @@ -663,6 +667,7 @@ export default class ApiRequest extends LitElement {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
schema-hide-read-only = "${this.schemaHideReadOnly}"
schema-hide-write-only = "${this.schemaHideWriteOnly}"
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </schema-tree>
`;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/schema-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ export default class SchemaTable extends LitElement {
${this.allowSchemaDescriptionExpandToggle === 'true'
? html`
<div style="flex:1"></div>
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
<div part="schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
</div>
`
: ''
}
</div>
${this.data?.['::description']
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
: ''
}
<div style = 'border:1px solid var(--light-border-color)'>
Expand Down
4 changes: 2 additions & 2 deletions src/components/schema-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ export default class SchemaTree extends LitElement {
${this.allowSchemaDescriptionExpandToggle === 'true'
? html`
<div style="flex:1"></div>
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
</div>
`
: ''
}
</div>
${this.data?.['::description']
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
: ''
}
${this.data
Expand Down
5 changes: 3 additions & 2 deletions src/templates/callback-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function callbackTemplate(callbacks) {
fetch-credentials = "${this.fetchCredentials}"
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,
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
anchor:anchor, anchor-param-example:anchor-param-example"
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-request>
<api-response
Expand All @@ -58,7 +58,8 @@ export default function callbackTemplate(callbacks) {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
schema-hide-read-only = "${this.schemaHideReadOnly}"
schema-hide-write-only = "false"
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"
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,
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-response>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/templates/components-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function schemaBodyTemplate(sComponent) {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
schema-hide-read-only = "false"
schema-hide-write-only = "${this.schemaHideWriteOnly}"
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </schema-tree> `
: html`
<schema-tree
Expand All @@ -31,6 +32,7 @@ function schemaBodyTemplate(sComponent) {
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
schema-hide-read-only = "false"
schema-hide-write-only = "${this.schemaHideWriteOnly}"
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </schema-tree>`
}
</div>`;
Expand Down
27 changes: 14 additions & 13 deletions src/templates/endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ function onExpandCollapseAll(e, action = 'expand-all') {
/* eslint-disable indent */
function endpointHeadTemplate(path, pathsExpanded = false) {
return html`
<summary @click="${(e) => { toggleExpand.call(this, path, e); }}" part="endpoint-head" class='endpoint-head ${path.method} ${path.deprecated ? 'deprecated' : ''} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
<div part="endpoint-head-method" class="method ${path.method} ${path.deprecated ? 'deprecated' : ''}"> ${path.method} </div>
<div class="path ${path.deprecated ? 'deprecated' : ''}">
<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'}'>
<div part="section-endpoint-head-method" class="method ${path.method} ${path.deprecated ? 'deprecated' : ''}"> ${path.method} </div>
<div part="section-endpoint-head-path" class="path ${path.deprecated ? 'deprecated' : ''}">
${path.path}
${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>` : ''}
</div>
Expand All @@ -62,7 +62,7 @@ function endpointHeadTemplate(path, pathsExpanded = false) {
${this.showSummaryWhenCollapsed
? html`
<div class="only-large-screen" style="min-width:60px; flex:1"></div>
<div part="endpoint-head-summary" class="descr">${path.summary || path.shortSummary} </div>`
<div part="section-endpoint-head-description" class="descr">${path.summary || path.shortSummary} </div>`
: ''
}
</summary>
Expand All @@ -88,27 +88,27 @@ function endpointBodyTemplate(path) {

const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate(path.xCodeSamples) : '';
return html`
<div class='endpoint-body ${path.method} ${path.deprecated ? 'deprecated' : ''}'>
<div part="section-end-point-body" class='endpoint-body ${path.method} ${path.deprecated ? 'deprecated' : ''}'>
<div class="summary">
${path.summary
? html`<div class="title">${path.summary}<div>`
? html`<div class="title" part="section-end-point-body-title">${path.summary}<div>`
: path.shortSummary !== path.description
? html`<div class="title">${path.shortSummary}</div>`
? html`<div class="title" part="section-end-point-body-title">${path.shortSummary}</div>`
: ''
}
${path.xBadges && path.xBadges?.length > 0
? html`
<div style="display:flex; flex-wrap:wrap;font-size: var(--font-size-small);">
${path.xBadges.map((v) => (
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>`
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>`
))
}
</div>
`
: ''
}
${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
${path.description ? html`<div part="section-end-point-body-description" class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
<slot name="${path.elementId}"></slot>
${pathSecurityTemplate.call(this, path.security)}
${codeSampleTabPanel}
Expand Down Expand Up @@ -141,7 +141,7 @@ function endpointBodyTemplate(path) {
fetch-credentials = "${this.fetchCredentials}"
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,
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
anchor:anchor, anchor-param-example:anchor-param-example"
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-request>
${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
Expand All @@ -160,8 +160,9 @@ function endpointBodyTemplate(path) {
schema-hide-read-only = "${path.isWebhook ? this.schemaHideWriteOnly : this.schemaHideReadOnly}"
schema-hide-write-only = "${path.isWebhook ? this.schemaHideReadOnly : this.schemaHideWriteOnly}"
selected-status = "${Object.keys(path.responses || {})[0] || ''}"
exportparts =
"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"
exportparts = "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,
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-response>
</div>
</div>`;
Expand Down Expand Up @@ -202,7 +203,7 @@ export default function endpointTemplate(showExpandCollapse = true, showTags = t
}
return true;
}).map((path) => html`
<section id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
<section part="section-end-point" id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
${endpointHeadTemplate.call(this, path, pathsExpanded)}
${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
</section>`)
Expand Down
5 changes: 3 additions & 2 deletions src/templates/expanded-endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function expandedEndpointBodyTemplate(path, tagName = '') {
fetch-credentials = "${this.fetchCredentials}"
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,
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
anchor:anchor, anchor-param-example:anchor-param-example"
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-request>
${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
Expand All @@ -111,7 +111,8 @@ export function expandedEndpointBodyTemplate(path, tagName = '') {
schema-hide-read-only = "${path.isWebhook ? this.schemaHideReadOnly : false}"
schema-hide-write-only = "${path.isWebhook ? false : this.schemaHideWriteOnly}"
selected-status = "${Object.keys(path.responses || {})[0] || ''}"
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"
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,
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
> </api-response>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/templates/server-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function serverVarsTemplate() {
// const selectedServerObj = this.resolvedSpec.servers.find((v) => (v.url === this.selectedServer));
return this.selectedServer && this.selectedServer.variables
? html`
<div class="table-title"> SERVER VARIABLES</div>
<div class="table-title">SERVER VARIABLES</div>
<table class='m-table'>
${Object.entries(this.selectedServer.variables).map((kv) => html`
<tr>
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function serverTemplate() {
if (!this.resolvedSpec || this.resolvedSpec.specLoadError) { return ''; }
return html`
<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'}'>
<div class = 'sub-title'>API SERVER</div>
<div part = "section-servers-title" class = "sub-title">API SERVER</div>
<div class = 'mono-font' style='margin: 12px 0; font-size:calc(var(--font-size-small) + 1px);'>
${!this.resolvedSpec.servers || this.resolvedSpec.servers?.length === 0
? ''
Expand Down

0 comments on commit 843c922

Please sign in to comment.