.edit-group { display: flex; align-items: center; margin: 0em 1em 1.5em 0em; }…
Private research annotation
Sign in to add a private research label or note.
- User
.edit-group { display: flex; align-items: center; margin: 0em 1em 1.5em 0em; }
code.edit-text { margin-left: 0.5em; /* Space between button and text */ color: #a0a0a0; } textarea.code { font-family: "SF Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Courier, monospace; font-size: 1em; background-color: #f1f1f1; padding: 10px; overflow-x: auto; margin-top: 0.5em; margin-bottom: 0.5em; } const PostButtonsPanel = ({ apiPrefix, apis }) => { const [apiRequestUrl, setApiRequestUrl] = useState("aaa"); const [apiJsonBody, setApiJsonBody] = useState("bbb"); const [response, setResponse] = useState("ttt"); const findPosition = async () => { const url = `/api/${apiPrefix}/findPosition`; const r = { snap: true, }; const jsonBody = JSON.stringify(r); const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: jsonBody, }); setApiRequestUrl(`POST ${url}`); setApiJsonBody(JSON.stringify(r, null, 2)); const data = await response.text(); setResponse(JSON.stringify(JSON.parse(data), null, 2)); // setResponse(data); }; return html` <div class="column col-6 col-md-12"> <div class="panel"> <div class="panel-header"> <h4 class="panel-title">Post Requests</h4> </div> <div class="panel-body"> <div> <button class="btn btn-primary" onClick=${findPosition}>Find Position</button> <button class="btn btn-primary">Start Calibrate</button> <button class="btn btn-primary">Calibrate</button> <button class="btn btn-primary">End Calibrate</button> </div> <div> ${apiRequestUrl && html`<div><pre class="code label label-secondary">${apiRequestUrl}</pre></div> <span class="label label-rounded label-success">Request</span>`} ${apiJsonBody && html`<div><textarea class="form-input code" data-lang="JSON">${apiJsonBody}</textarea></div>`} <div class="edit-group"> <button class="btn btn-secondary">Post</button> <span class="edit-text">(You may edit the above request and repost.)</span> </div> </div> <div> ${response && html`<span class="label label-rounded label-success">Response</span> <div class="form-group"> <textarea class="form-input code" data-lang="JSON">${response}</textarea> </div> <div class="edit-group"> <button class="btn btn-secondary">Set Response</button> <span class="edit-text">(You may edit the above and set it as response.)</span> </div> `} </div> </div> </div> </div> `; }; Assistant
To make the textareas auto-expand their heights in Preact and Spectre CSS, you need to override the default behavior that restricts the height of textarea elements. This can be done by setting the CSS
resizeproperty tononeand defining a custompadding-bottomthat adjusts with the content.Here's how you can achieve this:
- First, remove the default
resizeproperty, which restricts vertical resizing. - Then, set the
overflow-ytoautoto allow vertical scrolling when the content overflows.
- First, remove the default