Skip to content

Commit f9c08fa

Browse files
authored
Merge pull request #1449 from isaacphysics/redesign/improve-ada-printing
Improve Ada printing behaviour
2 parents 008a6a4 + 5704484 commit f9c08fa

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

src/app/components/content/IsaacCodeSnippet.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const IsaacCodeSnippet = ({doc}: IsaacCodeProps) => {
5656
</div>
5757
{doc.url && <Row>
5858
<Col className="text-center mb-2">
59-
<a href={doc.url} onClick={logViewOnGitHub} target="_blank" rel="noopener noreferrer">View on GitHub</a>
59+
<a className="no-print" href={doc.url} onClick={logViewOnGitHub} target="_blank" rel="noopener noreferrer">View on GitHub</a>
60+
<a className="only-print" href={doc.url} target="_blank" rel="noopener noreferrer">{doc.url}</a>
6061
</Col>
6162
</Row>}
6263
</>;

src/app/components/elements/Tabs.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function callOrString(stringOrTabFunction: StringOrTabFunction | undefined, tabT
3232
}
3333

3434
// e.g.: Tab 1 | Tab 2 | Tab 3
35-
const TabNavbar = ({singleLine, children, tabTitleClass, activeTab, changeTab}: TabsProps & {activeTab: number; changeTab: (i: number) => void}) => {
36-
return <Nav tabs className={classNames("flex-wrap", {"guaranteed-single-line": singleLine})}>
35+
const TabNavbar = ({singleLine, children, tabTitleClass, activeTab, changeTab, className}: TabsProps & {activeTab: number; changeTab: (i: number) => void;}) => {
36+
return <Nav tabs className={classNames(className, "flex-wrap", {"guaranteed-single-line": singleLine})}>
3737
{Object.keys(children).map((tabTitle, mapIndex) => {
3838
const tabIndex = mapIndex + 1;
3939
const linkClasses = callOrString(tabTitleClass, tabTitle, tabIndex);
@@ -129,7 +129,7 @@ export const Tabs = (props: TabsProps) => {
129129
{expandButton}
130130
<div className={classNames(className, innerClasses, `tab-style-${style}`, "position-relative")}>
131131
{style === "tabs"
132-
? <TabNavbar activeTab={activeTab} changeTab={changeTab} {...props}>{children}</TabNavbar>
132+
? <TabNavbar {...props} className="no-print" activeTab={activeTab} changeTab={changeTab}>{children}</TabNavbar>
133133
: style === "buttons"
134134
? <ButtonNavbar activeTab={activeTab} changeTab={changeTab} {...props}>{children}</ButtonNavbar>
135135
: <DropdownNavbar activeTab={activeTab} changeTab={changeTab} {...props}>{children}</DropdownNavbar>
@@ -138,9 +138,13 @@ export const Tabs = (props: TabsProps) => {
138138
<TabContent activeTab={activeTab} className={tabContentClass}>
139139
{Object.entries(children).map(([tabTitle, tabBody], mapIndex) => {
140140
const tabIndex = mapIndex + 1;
141-
return <TabPane key={tabTitle} tabId={tabIndex}>
142-
{tabBody as ReactNode}
143-
</TabPane>;
141+
return <>
142+
{/* This navbar exists only when printing so each tab has its own heading */}
143+
{style === "tabs" && <TabNavbar {...props} className={classNames("d-none d-print-flex mb-3 mt-2", {"mt-n4": mapIndex === 0 && tabContentClass.includes("pt-4")})} activeTab={tabIndex} changeTab={changeTab}>{children}</TabNavbar>}
144+
<TabPane key={tabTitle} tabId={tabIndex}>
145+
{tabBody as ReactNode}
146+
</TabPane>
147+
</>;
144148
})}
145149
</TabContent>
146150
</ExpandableParentContext.Provider>

src/scss/cs/button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162

163163
.print-icon {
164164
position: relative;
165-
z-index: 1;
165+
z-index: 2;
166166
&:not(.outline) {
167167
@include ada-icon-button-base(48px, 48px, false);
168168
}

src/scss/cs/questions.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
border-top-left-radius: 50px;
1414
border-bottom-left-radius: 50px;
1515
z-index: 2;
16+
background: $cs-cultured;
1617
.question-actions-link {
1718
margin-top: 2px; // Just to vertically center the links nicely
1819
color: $secondary;

src/test/pages/AssignmentProgress.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ describe("AssignmentProgress", () => {
4343
// Clicking on the group title should suffice to open the accordion
4444
await userEvent.click(groupTitle);
4545
// Get the two tabs, making sure that they show the correct numbers of assignments in each one
46-
const assignmentsTab = await screen.findByRole("button", {name: `Assignments (${mockAssignments.length})`});
47-
const testsTab = await screen.findByRole("button", {name: `Tests (${mockTestAssignments.length})`});
46+
// (and check that the user-visible "no-print" version of the tab is used)
47+
const assignmentsTabs = await screen.findAllByRole("button", {name: `Assignments (${mockAssignments.length})`});
48+
const assignmentsTab = assignmentsTabs.filter(tab => tab.classList.contains("no-print"))[0];
49+
const testsTabs = await screen.findAllByRole("button", {name: `Tests (${mockTestAssignments.length})`});
50+
const testsTab = testsTabs.filter(tab => tab.classList.contains("no-print"))[0];
4851
await userEvent.click(assignmentsTab);
4952
for (const assignmentTitle of mockAssignments.map(a => a.gameboard?.title)) {
5053
await screen.findByText(assignmentTitle, {exact: false});

0 commit comments

Comments
 (0)