diff --git a/lib/components/InputContent.jsx b/lib/components/InputContent.jsx index 5e920e7..4e3ac14 100644 --- a/lib/components/InputContent.jsx +++ b/lib/components/InputContent.jsx @@ -1,7 +1,7 @@ import * as React from "react"; import { useState } from "react"; -const InputContent = ({ error, setError, data, setData }) => { +const InputContent = ({ error, setError, data, setData, colorScheme }) => { const [dataHeaders, setDataHeaders] = useState([ { isUsed: true, @@ -80,15 +80,18 @@ const InputContent = ({ error, setError, data, setData }) => { value={dataItem.isUsed} defaultChecked={dataItem.isUsed} onChange={(e) => toggleChecked(e.target.value, dataItem)} + className={colorScheme == "dark" && "dark"} /> change(e, dataItem, "header")} + className={colorScheme == "dark" && "dark"} /> : change(e, dataItem, "value")} + className={colorScheme == "dark" && "dark"} /> ); @@ -99,6 +102,7 @@ const InputContent = ({ error, setError, data, setData }) => { validateInput(e.target.value)} + className={colorScheme == "dark" && "dark"} /> {error !== null && error} diff --git a/lib/components/InputForm.jsx b/lib/components/InputForm.jsx index 62a0265..3d37bb8 100644 --- a/lib/components/InputForm.jsx +++ b/lib/components/InputForm.jsx @@ -1,7 +1,7 @@ import * as React from "react"; import axios from "axios"; -const InputForm = ({ data, setData }) => { +const InputForm = ({ data, setData, colorScheme, endpointsList }) => { const APICall = async (endpoint, reqType) => { const req = async () => { let reqOptions = { @@ -26,6 +26,7 @@ const InputForm = ({ data, setData }) => { }; req(); }; + console.log(data); return ( { id="reqType" defaultValue="GET" onChange={(e) => setData({ ...data, reqType: e.target.value })} + className={colorScheme == "dark" && "dark"} > GET POST DELETE + setData({ ...data, endpoint: e.target.value })} placeholder="Enter your endpoint" + className={colorScheme == "dark" && "dark"} /> - APICall(data.endpoint, data.reqType)} - // disabled={error !== null} - > + + {endpointsList.map((o) => ( + {o} + ))} + + + APICall(data.endpoint, data.reqType)}> Submit{" "} diff --git a/lib/components/InputResponse.jsx b/lib/components/InputResponse.jsx index d261d64..aa29cca 100644 --- a/lib/components/InputResponse.jsx +++ b/lib/components/InputResponse.jsx @@ -1,6 +1,6 @@ import * as React from "react"; import ReactJson from "react-json-view"; -const InputResponse = ({ data }) => { +const InputResponse = ({ data, colorScheme }) => { let RJsonProps = { displayObjectSize: false, name: false, @@ -19,13 +19,18 @@ const InputResponse = ({ data }) => { Response: Headers: - + > )} diff --git a/lib/main.css b/lib/main.css index df038e4..830b25c 100644 --- a/lib/main.css +++ b/lib/main.css @@ -2,16 +2,12 @@ padding: 5px 35px 5px 5px; font-size: 16px; border: 1px solid #ccc; - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; - background: url(https://img.icons8.com/material-outlined/24/000000/expand-arrow--v1.png) - 94% / 15% no-repeat #fff; + border-radius: 5px; } .mockman input { font-size: 16px; - padding: 5px 35px 5px 5px; + padding: 5px 5px 5px 5px; border: 1px solid #ccc; border-radius: 5px; } @@ -63,6 +59,7 @@ margin: 10px; border-radius: 5px; overflow-wrap: anywhere; + word-break: break-word; } .title { font-weight: 300; @@ -81,6 +78,10 @@ textarea { line-height: 1.5; font-size: 16px; } +.dark { + background-color: black; + color: white; +} .error { color: rgb(124, 24, 24); padding: 1rem; diff --git a/lib/main.jsx b/lib/main.jsx index 84e5faa..77cba18 100644 --- a/lib/main.jsx +++ b/lib/main.jsx @@ -11,7 +11,7 @@ Add dependencies as per requirement Test the component by importing Mockman in src/main.tsx and run yarn dev to see the component in action */ -function Mockman({ colorScheme = "standard" }) { +function Mockman({ colorScheme = "standard", endpointsList }) { const defaultState = { reqType: "GET", endpoint: "/api/test-todos", @@ -25,16 +25,22 @@ function Mockman({ colorScheme = "standard" }) { return ( - + - + ); diff --git a/src/App.jsx b/src/App.jsx index 11e8946..a98d589 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -35,7 +35,14 @@ function App() { - + To test the above TODO-app, you can find it's mock-API
{error !== null && error}
To test the above TODO-app, you can find it's mock-API