Skip to content

Commit

Permalink
fix: further improvements to spacing and borders in react ui
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Jan 22, 2025
1 parent e7310db commit eb1018f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 36 deletions.
4 changes: 4 additions & 0 deletions pdl-live-react/src/Page.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.pdl-content-section {
/* This places the content e.g. editors flush with the tabs */
padding-top: 0;
}
3 changes: 3 additions & 0 deletions pdl-live-react/src/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import DrawerContent from "./DrawerContent"
import DrawerContext from "./DrawerContentContext"
import DarkModeContext, { getDarkModeUserSetting } from "./DarkModeContext"

import "./Page.css"

const notFilled = { isFilled: false }

type Props = PropsWithChildren<{
Expand Down Expand Up @@ -67,6 +69,7 @@ export default function PDLPage({ breadcrumb1, breadcrumb2, children }: Props) {
<PageSection
isFilled
hasOverflowScroll
className="pdl-content-section"
aria-label="PDL Viewer main section"
>
<DrawerContext.Provider value={setDrawerContent}>
Expand Down
3 changes: 3 additions & 0 deletions pdl-live-react/src/view/transcript/FinalResult.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pdl-final-result {
margin-top: 2em;
}
53 changes: 32 additions & 21 deletions pdl-live-react/src/view/transcript/Output.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
import { match, P } from "ts-pattern"
import { Card, CardBody } from "@patternfly/react-core"

import Markdown from "../Markdown"
import { isMarkdownish, type PdlBlock } from "../../helpers"

export default function Output({ data }: { data: PdlBlock }) {
return match(data)
.with(
P.string,
(output) =>
output.trim().length > 0 &&
(!isMarkdownish(output) ? (
<span className="pdl-wrap">{output.trim()}</span>
) : (
<Markdown>{output}</Markdown>
)),
)
.with(P.union(P.number, P.boolean, P.nullish), (output) => String(output))
.with({ contribute: P.union([], ["context"]) }, () => {
//div.classList.add('pdl_show_result_false'); // @nickm TODO
return "☐"
})
.with({ result: P.string }, (data) => <Markdown>{data.result}</Markdown>)
.with({ result: P._ }, (data) => (
<pre>{JSON.stringify(data.result, undefined, 2)}</pre>
))
.otherwise(() => "☐")
return (
<Card className="pdl-transcript-item pdl-output" variant="secondary">
<CardBody>
{match(data)
.with(
P.string,
(output) =>
output.trim().length > 0 &&
(!isMarkdownish(output) ? (
<span className="pdl-wrap">{output.trim()}</span>
) : (
<Markdown>{output}</Markdown>
)),
)
.with(P.union(P.number, P.boolean, P.nullish), (output) =>
String(output),
)
.with({ contribute: P.union([], ["context"]) }, () => {
//div.classList.add('pdl_show_result_false'); // @nickm TODO
return "☐"
})
.with({ result: P.string }, (data) => (
<Markdown>{data.result}</Markdown>
))
.with({ result: P._ }, (data) => (
<pre>{JSON.stringify(data.result, undefined, 2)}</pre>
))
.otherwise(() => "☐")}
</CardBody>
</Card>
)
}
35 changes: 23 additions & 12 deletions pdl-live-react/src/view/transcript/Transcript.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
.pdl-transcript-item {
--pdl-transcript-item-border: var(--pf-v6-c-card--BorderColor)
var(--pf-v6-c-card--BorderStyle) var(--pf-v6-c-card--BorderWidth);

border-radius: 0;

&:before {
border: none;
border-top: var(--pdl-transcript-item-border);
border-bottom: var(--pdl-transcript-item-border);
}
&:hover {
cursor: pointer;
background-color: var(--pf-t--global--background--color--primary--hover);
}
&:not(:first-child) {
border-top: var(--pf-v6-c-card--BorderColor)
var(--pf-v6-c-card--BorderStyle) var(--pf-v6-c-card--BorderWidth);
}

.pdl-transcript-item:not(.pf-m-secondary) + .pdl-transcript-item {
&:before {
border-top: none;
}
}

.pdl-output + .pdl-output {
.pf-v6-c-card__body {
padding-top: 0;
}
}

.pdl-output + .pdl-transcript-item {
}

.pdl-block-icon {
font-size: 1.375em;
}

.pdl-transcript {
.pdl-transcript,
.pdl-final-result {
max-width: 800px;

.pf-v6-c-accordion__expandable-content {
background-color: transparent;
}

.pdl-result-panel {
--pf-v6-c-panel--BackgroundColor: transparent;
}
height: auto;
}
8 changes: 5 additions & 3 deletions pdl-live-react/src/view/transcript/Transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export default function Transcript({ data }: Props) {
}, [darkMode, setDrawerContent])

return (
<Stack className="pdl-transcript">
<BlocksConjoin block={data} ctx={ctx} />
<>
<Stack className="pdl-transcript">
<BlocksConjoin block={data} ctx={ctx} />
</Stack>
{hasResult(data) && <FinalResult block={data} />}
</Stack>
</>
)
}

0 comments on commit eb1018f

Please sign in to comment.