mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:28:29 +02:00
Iframe response viewer
This commit is contained in:
12
src/App.tsx
12
src/App.tsx
@@ -13,10 +13,13 @@ interface Response {
|
|||||||
function App() {
|
function App() {
|
||||||
const [responseBody, setResponseBody] = useState<Response | null>(null);
|
const [responseBody, setResponseBody] = useState<Response | null>(null);
|
||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState("");
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function sendRequest() {
|
async function sendRequest() {
|
||||||
|
setLoading(true);
|
||||||
const body = await invoke("send_request", {url: url}) as Response;
|
const body = await invoke("send_request", {url: url}) as Response;
|
||||||
setResponseBody(body);
|
setResponseBody(body);
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -33,7 +36,7 @@ function App() {
|
|||||||
onChange={(e) => setUrl(e.currentTarget.value)}
|
onChange={(e) => setUrl(e.currentTarget.value)}
|
||||||
placeholder="Enter a URL..."
|
placeholder="Enter a URL..."
|
||||||
/>
|
/>
|
||||||
<button type="submit">Send</button>
|
<button type="submit" disabled={loading}>{loading ? 'Sending...' : 'Send'}</button>
|
||||||
</form>
|
</form>
|
||||||
{responseBody !== null && (
|
{responseBody !== null && (
|
||||||
<>
|
<>
|
||||||
@@ -44,7 +47,12 @@ function App() {
|
|||||||
•
|
•
|
||||||
{responseBody?.elapsed2}ms
|
{responseBody?.elapsed2}ms
|
||||||
</div>
|
</div>
|
||||||
<Editor value={responseBody?.body}/>
|
<div className="row">
|
||||||
|
<Editor value={responseBody?.body}/>
|
||||||
|
<div className="iframe-wrapper">
|
||||||
|
<iframe srcDoc={responseBody.body}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
.cm-editor {
|
.cm-editor {
|
||||||
height: 20rem;
|
|
||||||
background-color: #000;
|
background-color: #000;
|
||||||
border-radius: 0.5rem;
|
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
width: 100%;
|
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-editor, .iframe-wrapper {
|
||||||
padding: 0.3rem 0.5rem;
|
padding: 0.3rem 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
height: 30rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-editor.cm-focused {
|
.cm-editor.cm-focused {
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ interface Props {
|
|||||||
export default function Editor(props: Props) {
|
export default function Editor(props: Props) {
|
||||||
const {ref} = useCodeMirror({value: props.value});
|
const {ref} = useCodeMirror({value: props.value});
|
||||||
return (
|
return (
|
||||||
<div ref={ref} id="editor-yo" style={{height: '10rem'}}/>
|
<div ref={ref} id="editor-yo" />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ div, form, p {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@@ -84,6 +85,13 @@ button {
|
|||||||
|
|
||||||
button {
|
button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
width: 7rem;
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user