Skip to content

Commit 61cd1c8

Browse files
authored
Merge pull request #130 from dockersamples/minor-ui-tweaks
Minor UI tweaks
2 parents 67e71ed + 9aa3c71 commit 61cd1c8

File tree

6 files changed

+139
-154
lines changed

6 files changed

+139
-154
lines changed

components/interface/client/src/components/ExternalContentPanel/ExternalTabs.jsx

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,61 @@ export function ExternalTabs({
99
onRefreshClick,
1010
}) {
1111
return (
12-
<>
13-
{tabs.length > 1 && (
14-
<Nav
15-
variant="tabs"
16-
activeKey={activeTab}
17-
onSelect={(selectedKey) => setActiveTab(selectedKey)}
18-
id="external-content-tabs"
19-
className="align-items-end"
20-
>
21-
{tabs.map((tab) => (
22-
<Nav.Item key={tab.url} className="me-2 ms-2">
23-
<Nav.Link
24-
eventKey={tab.url}
25-
href={tab.url}
26-
className="p-1 ps-3 pe-1"
27-
onClick={(e) => {
28-
e.preventDefault();
29-
}}
30-
>
31-
<span className="me-3">{tab.title}</span>
32-
33-
{activeTab === tab.url && (
34-
<Button
35-
size="sm"
36-
variant="default"
37-
className="rounded-circle p-1 pt-0 pb-0"
12+
<>
13+
{tabs.length > 1 && (
14+
<Nav
15+
variant="tabs"
16+
activeKey={activeTab}
17+
onSelect={(selectedKey) => setActiveTab(selectedKey)}
18+
id="external-content-tabs"
19+
className="align-items-end"
20+
>
21+
{tabs.map((tab) => (
22+
<Nav.Item key={tab.url} className="me-2 ms-2">
23+
<Nav.Link
24+
eventKey={tab.url}
25+
href={tab.url}
26+
className="p-1 ps-3 pe-1"
3827
onClick={(e) => {
39-
e.stopPropagation();
4028
e.preventDefault();
41-
onRefreshClick();
4229
}}
4330
>
44-
<span className="material-symbols-outlined">refresh</span>
45-
</Button>
46-
)}
31+
<span className="me-3">{tab.title}</span>
4732

48-
{tab.title !== "Workspace" && (
49-
<Button
50-
size="sm"
51-
variant="default"
52-
className="rounded-circle p-1 pt-0 pb-0"
53-
onClick={(e) => {
54-
e.stopPropagation();
55-
e.preventDefault();
56-
onTabRemoval(tab.url);
57-
}}
58-
>
59-
<span className="material-symbols-outlined">close</span>
60-
</Button>
61-
)}
62-
</Nav.Link>
63-
</Nav.Item>
64-
))}
65-
</Nav>
33+
{activeTab === tab.url && (
34+
<Button
35+
size="sm"
36+
variant="default"
37+
className="rounded-circle p-1 pt-0 pb-0"
38+
onClick={(e) => {
39+
e.stopPropagation();
40+
e.preventDefault();
41+
onRefreshClick();
42+
}}
43+
>
44+
<span className="material-symbols-outlined">refresh</span>
45+
</Button>
46+
)}
6647

67-
)}
48+
{tab.title !== "Workspace" && (
49+
<Button
50+
size="sm"
51+
variant="default"
52+
className="rounded-circle p-1 pt-0 pb-0"
53+
onClick={(e) => {
54+
e.stopPropagation();
55+
e.preventDefault();
56+
onTabRemoval(tab.url);
57+
}}
58+
>
59+
<span className="material-symbols-outlined">close</span>
60+
</Button>
61+
)}
62+
</Nav.Link>
63+
</Nav.Item>
64+
))}
65+
</Nav>
66+
)}
6867
</>
6968
);
7069
}

components/interface/client/src/components/WorkshopPanel/WorkshopBody.jsx

Lines changed: 0 additions & 72 deletions
This file was deleted.

components/interface/client/src/components/WorkshopPanel/WorkshopHeader.jsx

Lines changed: 0 additions & 25 deletions
This file was deleted.

components/interface/client/src/components/WorkshopPanel/WorkshopNav.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import Dropdown from "react-bootstrap/Dropdown";
22
import { useActiveSection, useWorkshop } from "../../WorkshopContext";
3+
import "./WorkshopNav.scss";
34

45
export function WorkshopNav() {
56
const { sections } = useWorkshop();
67
const { activeSection, changeActiveSection } = useActiveSection();
78

89
return (
910
<div className="workshop-nav">
10-
<Dropdown align="end">
11-
<Dropdown.Toggle variant="outline-secondary">
11+
<Dropdown className="dropdown-center" drop="down-centered">
12+
<Dropdown.Toggle
13+
variant="outline-secondary"
14+
className="text-truncate w-100"
15+
size="sm"
16+
id="labspace-nav-dropdown"
17+
>
1218
{(activeSection && (
1319
<>
1420
{sections.findIndex((s) => s.id === activeSection.id) + 1}.{" "}
15-
{activeSection.title}
21+
{activeSection.title} and a little more
1622
</>
1723
)) ||
1824
"Sections"}
1925
</Dropdown.Toggle>
2026

21-
<Dropdown.Menu>
27+
<Dropdown.Menu align="center">
2228
{sections.map((section, index) => (
2329
<Dropdown.Item
2430
key={section.id}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#workshop-footer {
2+
.material-symbols-outlined {
3+
font-size: 0.7rem;
4+
}
5+
}
6+
7+
#labspace-nav-dropdown {
8+
position: relative;
9+
padding-right: 17px;
10+
11+
&::after {
12+
position: absolute;
13+
right: 6px;
14+
top: 42%;
15+
}
16+
}
Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,72 @@
1-
import { WorkshopBody } from "./WorkshopBody";
2-
import { WorkshopHeader } from "./WorkshopHeader";
1+
import { useActiveSection, useWorkshop } from "../../WorkshopContext";
2+
import { useEffect, useRef } from "react";
3+
import Button from "react-bootstrap/Button";
4+
import { MarkdownRenderer } from "./markdown/MarkdownRenderer";
5+
import { WorkshopNav } from "./WorkshopNav";
36
import "./WorkshopPanel.scss";
47

58
export function WorkshopPanel() {
9+
const bodyRef = useRef();
10+
const { activeSection, changeActiveSection } = useActiveSection();
11+
const { sections } = useWorkshop();
12+
13+
const index = sections.findIndex(
14+
(section) => section.id === activeSection.id,
15+
);
16+
17+
useEffect(() => {
18+
// alert("Scrolling?");
19+
window.bodyRef = bodyRef.current;
20+
setTimeout(
21+
() => bodyRef.current.scrollTo({ top: 0, left: 0, behavior: "smooth" }),
22+
100,
23+
);
24+
}, [activeSection, bodyRef]);
25+
26+
const hasNext = index < sections.length - 1;
27+
const hasPrev = index > 0;
28+
629
return (
730
<div className="d-flex flex-column h-100">
8-
<WorkshopBody />
31+
<div className="overflow-auto" ref={bodyRef}>
32+
<div className="workshop-body p-5 pt-3 pb-3">
33+
<MarkdownRenderer>{activeSection.content}</MarkdownRenderer>
34+
</div>
35+
</div>
36+
37+
<div
38+
id="workshop-footer"
39+
style={{ borderColor: "#E5E5E5 !Important" }}
40+
className="workshop-footer d-flex justify-content-between p-3 border-top bg-light-subtle align-items-center"
41+
>
42+
<div>
43+
<Button
44+
size="sm"
45+
variant="outline-secondary"
46+
onClick={() => changeActiveSection(sections[index - 1].id)}
47+
className="d-flex align-items-center"
48+
style={{ visibility: hasPrev ? "visible" : "hidden" }}
49+
>
50+
<span className="material-symbols-outlined">arrow_back</span>
51+
<span>Previous</span>
52+
</Button>
53+
</div>
54+
<div style={{ maxWidth: "calc(100% - 175px)" }}>
55+
<WorkshopNav />
56+
</div>
57+
<div>
58+
<Button
59+
variant="primary"
60+
size="sm"
61+
onClick={() => changeActiveSection(sections[index + 1].id)}
62+
className="d-flex align-items-center"
63+
style={{ visibility: hasNext ? "visible" : "hidden" }}
64+
>
65+
<span className="me-1">Next</span>
66+
<span className="material-symbols-outlined">arrow_forward</span>
67+
</Button>
68+
</div>
69+
</div>
970
</div>
1071
);
1172
}

0 commit comments

Comments
 (0)