-
}
@@ -70,17 +74,36 @@ templ APIExplorer(explorer APIExplorerData) {
document.getElementById('real-btn')?.addEventListener('click', () => showMode('real'));
function showMode(mode) {
+ const mockBtn = document.getElementById('mock-btn');
+ const realBtn = document.getElementById('real-btn');
+ const responseBody = document.getElementById('response-body');
+ const responseStatus = document.getElementById('response-status');
+ const responseTime = document.getElementById('response-time');
+ const apiResponse = document.querySelector('.api-response');
+ const requestBody = document.getElementById('request-body');
+ const tryItOut = document.getElementById('try-it-out');
+
if (mode === 'mock') {
- document.querySelector('.api-response').style.display = 'block';
- document.getElementById('request-body').readOnly = true;
- document.getElementById('try-it-out').style.display = 'none';
- document.getElementById('response-body').textContent = JSON.stringify(exampleResponse, null, 2);
- document.getElementById('response-status').textContent = '200 OK';
- document.getElementById('response-time').textContent = 'Mock';
+ mockBtn.classList.add('bg-accent', 'text-white');
+ mockBtn.classList.remove('bg-background-primary', 'text-text-primary');
+ realBtn.classList.remove('bg-accent', 'text-white');
+ realBtn.classList.add('bg-background-primary', 'text-text-primary');
+
+ apiResponse.classList.remove('hidden');
+ requestBody.readOnly = true;
+ tryItOut.classList.add('hidden');
+ responseBody.textContent = JSON.stringify(exampleResponse, null, 2);
+ responseStatus.textContent = '200 OK';
+ responseTime.textContent = 'Mock';
} else {
- document.querySelector('.api-response').style.display = 'none';
- document.getElementById('request-body').readOnly = false;
- document.getElementById('try-it-out').style.display = 'block';
+ realBtn.classList.add('bg-accent', 'text-white');
+ realBtn.classList.remove('bg-background-primary', 'text-text-primary');
+ mockBtn.classList.remove('bg-accent', 'text-white');
+ mockBtn.classList.add('bg-background-primary', 'text-text-primary');
+
+ apiResponse.classList.add('hidden');
+ requestBody.readOnly = false;
+ tryItOut.classList.remove('hidden');
}
}
@@ -106,11 +129,11 @@ templ APIExplorer(explorer APIExplorerData) {
document.getElementById('response-status').textContent = `${response.status} (${response.statusText})`;
document.getElementById('response-time').textContent = `${duration}ms`;
document.getElementById('response-body').textContent = JSON.stringify(data, null, 2);
- document.querySelector('.api-response').style.display = 'block';
+ document.querySelector('.api-response').classList.remove('hidden');
} catch (error) {
document.getElementById('response-status').textContent = 'Error';
document.getElementById('response-body').textContent = error.message;
- document.querySelector('.api-response').style.display = 'block';
+ document.querySelector('.api-response').classList.remove('hidden');
}
});
@@ -144,126 +167,6 @@ templ APIExplorer(explorer APIExplorerData) {
navigator.clipboard.writeText(curl);
}
-
-
}
// APIExplorerData holds data for the API explorer component
diff --git a/templates/api_explorer_templ.go b/templates/api_explorer_templ.go
index bb0a306..4bd3e47 100644
--- a/templates/api_explorer_templ.go
+++ b/templates/api_explorer_templ.go
@@ -30,7 +30,7 @@ func APIExplorer(explorer APIExplorerData) templ.Component {
}
ctx = templ.ClearChildren(ctx)
if !explorer.IsLoggedIn {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
Response (Mock)
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
Response (Mock)
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(explorer.Endpoint.Response)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/api_explorer.templ`, Line: 25, Col: 43}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/api_explorer.templ`, Line: 25, Col: 138}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "