Skip to content

Commit

Permalink
refactor: in react ui, have Page manage Viewer
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Jan 23, 2025
1 parent 04b5b91 commit 4172134
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions pdl-live-react/src/Demo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Page from "./Page"
import Viewer from "./Viewer"

type Props = {
name: string
Expand All @@ -9,7 +8,7 @@ type Props = {
export default function Demo({ name, value }: Props) {
return (
<Page breadcrumb1="Demo" breadcrumb2={name}>
<Viewer value={value} />
{value}
</Page>
)
}
9 changes: 7 additions & 2 deletions pdl-live-react/src/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PageSection,
} from "@patternfly/react-core"

import Viewer from "./Viewer"
import Sidebar from "./Sidebar"
import Masthead from "./Masthead"
import ViewerTabs from "./ViewerTabs"
Expand Down Expand Up @@ -58,7 +59,7 @@ export default function PDLPage({ breadcrumb1, breadcrumb2, children }: Props) {
<Masthead setDarkMode={setDarkMode} />
</DarkModeContext.Provider>
}
horizontalSubnav={<ViewerTabs />}
horizontalSubnav={typeof children === "string" && <ViewerTabs />}
groupProps={notFilled /* so breadcrumbs aren't filled */}
isBreadcrumbGrouped
breadcrumb={
Expand All @@ -78,7 +79,11 @@ export default function PDLPage({ breadcrumb1, breadcrumb2, children }: Props) {
>
<DrawerContext.Provider value={setDrawerContent}>
<DarkModeContext.Provider value={darkMode}>
{children}
{typeof children === "string" && children.length > 0 ? (
<Viewer value={children} />
) : (
children
)}
</DarkModeContext.Provider>
</DrawerContext.Provider>
</PageSection>
Expand Down
3 changes: 1 addition & 2 deletions pdl-live-react/src/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@patternfly/react-core"

import Page from "./Page"
import Viewer from "./Viewer"

export default function Uploader() {
const [value, setValue] = useState("")
Expand Down Expand Up @@ -142,7 +141,7 @@ export default function Uploader() {
</FormGroup>
</Form>

{value && <Viewer value={value} />}
{value}
</Page>
)
}

0 comments on commit 4172134

Please sign in to comment.