Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/features/docs/view/Stoplight.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect, useState } from "react"
import { Box } from "@mui/material"
import { API } from "@stoplight/elements"
import "@stoplight/elements/styles.min.css"
import LoadingWrapper from "./LoadingWrapper"

const Swagger = ({ url }: { url: string }) => {
const Stoplight = ({ url }: { url: string }) => {
// The Stoplight component does not provide a callback to let us know
// when loading ends so in order to show our loading indicator, we load
// the specification before showing the Stoplight component.
Expand All @@ -20,10 +21,40 @@ const Swagger = ({ url }: { url: string }) => {
return (
<LoadingWrapper showLoadingIndicator={isLoading}>
{!isLoading && document &&
<API apiDescriptionDocument={document} router="hash" />
<ResponsiveStoplight document={document} />
}
</LoadingWrapper>
)
}

export default Swagger
const ResponsiveStoplight = ({ document }: { document: string }) => {
return (
<>
<Box sx={{
display: { xs: "block", sm: "none" },
width: "100%",
height: "100%",
padding: 2
}}>
<API
apiDescriptionDocument={document}
router="hash"
layout="stacked"
/>
</Box>
<Box sx={{
display: { xs: "none", sm: "block" },
width: "100%",
height: "100%",
}}>
<API
apiDescriptionDocument={document}
router="hash"
layout="sidebar"
/>
</Box>
</>
)
}

export default Stoplight