Skip to content

Commit 1c3240f

Browse files
committed
chore: in react ui, clean up welcome to factor out common Tile
Signed-off-by: Nick Mitchell <[email protected]>
1 parent d3a7594 commit 1c3240f

File tree

4 files changed

+66
-76
lines changed

4 files changed

+66
-76
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { PropsWithChildren, ReactNode } from "react"
2+
3+
import {
4+
Card,
5+
CardBody,
6+
CardFooter,
7+
CardHeader,
8+
CardTitle,
9+
Flex,
10+
} from "@patternfly/react-core"
11+
12+
type Props = PropsWithChildren<{
13+
title: ReactNode
14+
body: ReactNode
15+
}>
16+
17+
export default function Tile({ title, body, children }: Props) {
18+
return (
19+
<Card isLarge>
20+
<CardHeader>
21+
<CardTitle>{title}</CardTitle>
22+
</CardHeader>
23+
<CardBody>{body}</CardBody>
24+
<CardFooter>
25+
<Flex>{children}</Flex>
26+
</CardFooter>
27+
</Card>
28+
)
29+
}
Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,22 @@
11
import { Link } from "react-router"
2-
import {
3-
Button,
4-
Card,
5-
CardBody,
6-
CardFooter,
7-
CardHeader,
8-
CardTitle,
9-
Flex,
10-
} from "@patternfly/react-core"
2+
import { Button } from "@patternfly/react-core"
113

4+
import Tile from "../Tile"
125
import demos from "../../../demos/demos"
136

147
export default function Demos() {
158
return (
16-
<Card isLarge>
17-
<CardHeader>
18-
<CardTitle>View a Demo</CardTitle>
19-
</CardHeader>
20-
<CardBody>You may view one of the built-in PDL demos.</CardBody>
21-
<CardFooter>
22-
<Flex>
23-
{demos.map((demo) => (
24-
<Button key={demo.name} isInline variant="link">
25-
<Link to={"/demos/" + encodeURIComponent(demo.name)}>
26-
{demo.name}
27-
</Link>
28-
</Button>
29-
))}
30-
</Flex>
31-
</CardFooter>
32-
</Card>
9+
<Tile
10+
title="View a Demo"
11+
body="You may view one of the built-in PDL demos."
12+
>
13+
{demos.map((demo) => (
14+
<Button key={demo.name} isInline variant="link">
15+
<Link to={"/demos/" + encodeURIComponent(demo.name)}>
16+
{demo.name}
17+
</Link>
18+
</Button>
19+
))}
20+
</Tile>
3321
)
3422
}
Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,22 @@
11
import { Link } from "react-router"
2-
import {
3-
Button,
4-
Card,
5-
CardBody,
6-
CardFooter,
7-
CardHeader,
8-
CardTitle,
9-
Flex,
10-
} from "@patternfly/react-core"
2+
import { Button } from "@patternfly/react-core"
113

4+
import Tile from "../Tile"
125
import { getMyTraces } from "../../MyTraces"
136

147
export default function MyTraces() {
158
const myTraces = getMyTraces()
169

1710
return (
18-
myTraces.length > 0 && (
19-
<Card isLarge>
20-
<CardHeader>
21-
<CardTitle>My Traces</CardTitle>
22-
</CardHeader>
23-
<CardBody>
24-
You may view one of your previously uploaded traces.
25-
</CardBody>
26-
<CardFooter>
27-
<Flex>
28-
{myTraces.map(({ title, filename }) => (
29-
<Button key={filename} isInline variant="link">
30-
<Link to={"/my/" + encodeURIComponent(title)}>{title}</Link>
31-
</Button>
32-
))}
33-
</Flex>
34-
</CardFooter>
35-
</Card>
36-
)
11+
<Tile
12+
title="My Traces"
13+
body="You may view one of your previously uploaded traces."
14+
>
15+
{myTraces.map(({ title, filename }) => (
16+
<Button key={filename} isInline variant="link">
17+
<Link to={"/my/" + encodeURIComponent(title)}>{title}</Link>
18+
</Button>
19+
))}
20+
</Tile>
3721
)
3822
}
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
import { Link } from "react-router"
2-
import {
3-
Button,
4-
Card,
5-
CardBody,
6-
CardFooter,
7-
CardHeader,
8-
CardTitle,
9-
} from "@patternfly/react-core"
2+
import { Button } from "@patternfly/react-core"
3+
4+
import Tile from "../Tile"
105

116
export default function Upload() {
127
return (
13-
<Card isLarge>
14-
<CardHeader>
15-
<CardTitle>Upload Trace</CardTitle>
16-
</CardHeader>
17-
<CardBody>
18-
You may upload a trace from your computer to visualize the program
19-
execution.
20-
</CardBody>
21-
<CardFooter>
22-
<Button isInline variant="link">
23-
<Link to="/upload">Choose Trace File</Link>
24-
</Button>
25-
</CardFooter>
26-
</Card>
8+
<Tile
9+
title="Upload Trace"
10+
body="You may upload a trace from your computer to visualize the program execution."
11+
>
12+
<Button isInline variant="link">
13+
<Link to="/upload">Choose Trace File</Link>
14+
</Button>
15+
</Tile>
2716
)
2817
}

0 commit comments

Comments
 (0)