Skip to content

Commit

Permalink
feat(front-end): make result panel scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Jul 19, 2024
1 parent d67ef3f commit fbd73f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
33 changes: 30 additions & 3 deletions server-jetty/src/main/js/src/lg4j-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,38 @@ export class LG4JResultElement extends LitElement {
this.removeEventListener( 'result', this.#onResult )
}


#renderResult2(result, index) {
return html`
<div class="card bg-neutral text-neutral-content">
<div class="card-body">
<h2 class="card-title">${result.node}</h2>
<div class="collapse collapse-arrow bg-base-200">
<input type="radio" name="item-1" checked="checked" />
<div class="collapse-content">
${Object.entries(result.state).map(([key, value]) => html`
<div>
<h4 class="italic">${key}</h4>
<p class="my-3">
<json-viewer id="json${index}">
${JSON.stringify(value)}
</json-viewer>
</p>
</div>
`)}
</div>
</div>
</div>
</div> `
}

/**
* Renders a result.
* @param {ResultData} result - The result data to render.
* @returns {import('lit').TemplateResult} The template for the result.
*/
#renderResult(result, index) {
return html`
<div>
<div class="collapse collapse-arrow bg-base-200">
<input type="radio" name="item-1" checked="checked" />
<div class="collapse-title text-xl font-bold">${result.node}</div>
Expand All @@ -61,6 +85,7 @@ export class LG4JResultElement extends LitElement {
`)}
</div>
</div>
</div>
`
}

Expand Down Expand Up @@ -102,8 +127,10 @@ export class LG4JResultElement extends LitElement {
render() {

return html`
<div class="flex flex-col gap-y-1.5 mx-2 mt-2">
${this.results.map( (result, index) => this.#renderResult(result, index))}
<div class="h-screen flex flex-col">
<div class="flex flex-col gap-y-1.5 mx-2 mt-2 h-full overflow-auto">
${this.results.map( (result, index) => this.#renderResult(result, index))}
</div>
</div>
`;
}
Expand Down
4 changes: 2 additions & 2 deletions server-jetty/src/main/js/src/twlit.js

Large diffs are not rendered by default.

0 comments on commit fbd73f1

Please sign in to comment.