Skip to content

Redesign concept pages #1346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/components/elements/PrintButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const PrintButton = ({questionPage}: PrintProps ) => {
const dispatch = useAppDispatch();

return questionPage ?
<>
{questionPrintOpen && <div className="question-actions-link-box not-mobile">
<div className="position-relative">
{questionPrintOpen && <div className="action-buttons-popup-container not-mobile">
<div className="question-actions-link text-nowrap">
<Button
size={"sm"}
Expand Down Expand Up @@ -58,7 +58,7 @@ export const PrintButton = ({questionPage}: PrintProps ) => {
aria-label="Print page"
/>
)}
</>
</div>
:
siteSpecific(
<IconButton
Expand Down
25 changes: 12 additions & 13 deletions src/app/components/elements/ShareLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useEffect, useRef, useState} from "react";
import {isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";
import {isAda, isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import isAda.

Copilot Autofix

AI 3 months ago

To fix the problem, we need to remove the unused import isAda from the import statement on line 2. This will clean up the code and potentially improve performance by reducing the bundle size.

  • In general terms, the problem can be fixed by identifying and removing any unused imports.
  • Specifically, we will remove isAda from the import statement on line 2 in the file src/app/components/elements/ShareLink.tsx.
  • No additional methods, imports, or definitions are needed to implement this change.
Suggested changeset 1
src/app/components/elements/ShareLink.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/app/components/elements/ShareLink.tsx b/src/app/components/elements/ShareLink.tsx
--- a/src/app/components/elements/ShareLink.tsx
+++ b/src/app/components/elements/ShareLink.tsx
@@ -1,3 +1,3 @@
 import React, {useEffect, useRef, useState} from "react";
-import {isAda, isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";
+import {isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";
 import {selectors, useAppSelector} from "../../state";
EOF
@@ -1,3 +1,3 @@
import React, {useEffect, useRef, useState} from "react";
import {isAda, isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";
import {isMobile, isPhy, isTutorOrAbove, PATHS, siteSpecific, useOutsideCallback} from "../../services";
import {selectors, useAppSelector} from "../../state";
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
import {selectors, useAppSelector} from "../../state";
import classNames from "classnames";
import { IconButton } from "./AffixButton";
Expand Down Expand Up @@ -40,9 +40,17 @@
useOutsideCallback(shareLinkDivRef, () => clickAwayClose && setShowShareLink(false), [setShowShareLink]);

const buttonAriaLabel = showShareLink ? "Hide share link" : "Get share link";
const linkWidth = isMobile() || reducedWidthLink ? 192 : (shareUrl.length * siteSpecific(9, 6));
const linkWidth = isMobile() || reducedWidthLink ? siteSpecific(256, 192) : (shareUrl.length * siteSpecific(9, 6));
const showDuplicateAndEdit = gameboardId && isTutorOrAbove(user);
return <div ref={shareLinkDivRef} className={classNames(className, "share-link-icon", {"w-max-content d-inline-flex": isPhy})}>
return <div ref={shareLinkDivRef} className={classNames(className, "position-relative share-link-icon", {"w-max-content d-inline-flex": isPhy})}>
<div className={`action-buttons-popup-container ${showShareLink ? "" : "d-none"} ${showDuplicateAndEdit ? "double-height" : ""}`} style={{width: linkWidth}}>
<input type="text" readOnly ref={shareLink} value={shareUrl} onClick={(e) => e.preventDefault()} aria-label="Share URL" />
</div>
{showShareLink && showDuplicateAndEdit && <div className="duplicate-and-edit" style={{width: linkWidth}}>
<a href={`${PATHS.GAMEBOARD_BUILDER}?base=${gameboardId}`} className={isPhy ? "px-1" : ""}>
{siteSpecific("Duplicate and Edit", "Duplicate and edit")}
</a>
</div>}
{siteSpecific(
<IconButton
icon="icon-share"
Expand All @@ -54,16 +62,7 @@
data-bs-theme="neutral"
onClick={(e) => { e.preventDefault(); toggleShareLink(); }}
/>,
<button className={siteSpecific("btn-action", classNames({"outline": outline}))} onClick={(e) => {e.preventDefault(); toggleShareLink();}} aria-label={buttonAriaLabel} />
<button className={siteSpecific("btn-action", classNames("btn btn-primary", {"outline": outline}))} onClick={(e) => {e.preventDefault(); toggleShareLink();}} aria-label={buttonAriaLabel} />
)}
<div className={`share-link ${showShareLink ? "d-block" : ""} ${showDuplicateAndEdit ? "double-height" : ""}`} style={{width: linkWidth}}>
<input type="text" readOnly ref={shareLink} value={shareUrl} onClick={(e) => e.preventDefault()} aria-label="Share URL" />
{showDuplicateAndEdit && <React.Fragment>
{isPhy && <hr className="text-center mt-4" />}
<a href={`${PATHS.GAMEBOARD_BUILDER}?base=${gameboardId}`} className={isPhy ? "px-1" : ""}>
{siteSpecific("Duplicate and Edit", "Duplicate and edit")}
</a>
</React.Fragment>}
</div>
</div>;
};
7 changes: 4 additions & 3 deletions src/app/components/elements/inputs/UserContextPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
useUserViewingContext
} from "../../../services";
import {selectors, transientUserContextSlice, useAppDispatch, useAppSelector,} from "../../../state";
import classNames from "classnames";

const contextExplanationMap: {[key in CONTEXT_SOURCE]: string} = {
[CONTEXT_SOURCE.TRANSIENT]: "these context picker settings",
Expand Down Expand Up @@ -62,7 +63,7 @@ export const UserContextPicker = ({className, hideLabels = true}: {className?: s
return <Col className={`d-flex flex-column w-100 px-0 mt-2 context-picker-container no-print ${className}`}>
<Row sm={12} md={7} lg={siteSpecific(7, 8)} xl={siteSpecific(7, 9)} className={`d-flex m-0 p-0 justify-content-md-end`}>
{/* Stage Selector */}
<FormGroup className={`form-group w-100 d-flex justify-content-end m-0`}>
<div className={classNames("form-group w-100 d-flex justify-content-end m-0", {"mb-3": isAda})}>
{!hideLabels && <Label className="d-inline-block pe-2" htmlFor="uc-stage-select">Stage</Label>}
{!userContext.hasDefaultPreferences && (userContext.explanation.stage == CONTEXT_SOURCE.TRANSIENT || userContext.explanation.examBoard == CONTEXT_SOURCE.TRANSIENT) &&
<button className={"icon-reset mt-2"} aria-label={"Reset viewing context"} onClick={() => {
Expand All @@ -71,7 +72,7 @@ export const UserContextPicker = ({className, hideLabels = true}: {className?: s
}}/>
}
<Input
className={`flex-grow-1 d-inline-block ps-2 pe-0 mb-2 ${isAda ? "me-1" : ""}`}
className={classNames("flex-grow-1 d-inline-block ps-2 pe-0", { "mb-2 me-1": isAda })}
type="select" id="uc-stage-select"
aria-label={hideLabels ? "Stage" : undefined}
value={userContext.stage}
Expand Down Expand Up @@ -134,7 +135,7 @@ export const UserContextPicker = ({className, hideLabels = true}: {className?: s
}
</UncontrolledTooltip>
</div>
</FormGroup>
</div>
</Row>
</Col>;
}
Expand Down
41 changes: 26 additions & 15 deletions src/app/components/elements/layout/SidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,17 @@ const FilterCheckbox = (props : FilterCheckboxProps) => {
/>;
};

const AllFiltersCheckbox = (props: Omit<FilterCheckboxProps, "tag">) => {
const { conceptFilters, setConceptFilters, tagCounts, baseTag, ...rest } = props;
const AllFiltersCheckbox = (props: Omit<FilterCheckboxProps, "tag"> & {forceEnabled?: boolean}) => {
const { conceptFilters, setConceptFilters, tagCounts, baseTag, forceEnabled, ...rest } = props;
const [previousFilters, setPreviousFilters] = useState<Tag[]>(baseTag ? [baseTag] : []);
return <StyledTabPicker {...rest}
id="all" checked={baseTag ? conceptFilters.length === 1 && conceptFilters[0] === baseTag : !conceptFilters.length} checkboxTitle="All" count={tagCounts && Object.values(tagCounts).reduce((a, b) => a + b, 0)}
id="all" checked={forceEnabled || baseTag ? conceptFilters.length === 1 && conceptFilters[0] === baseTag : !conceptFilters.length}
checkboxTitle="All" count={tagCounts && (baseTag ? tagCounts[baseTag.id] : Object.values(tagCounts).reduce((a, b) => a + b, 0))}
onInputChange={(e) => {
if (forceEnabled) {
setConceptFilters(baseTag ? [baseTag] : []);
return;
}
if (e.target.checked) {
setPreviousFilters(conceptFilters);
setConceptFilters(baseTag ? [baseTag] : []);
Expand Down Expand Up @@ -272,19 +277,25 @@ export const SubjectSpecificConceptListSidebar = (props: ConceptListSidebarProps

<div className="d-flex flex-column">
<h5>Filter by topic</h5>
<AllFiltersCheckbox conceptFilters={conceptFilters} setConceptFilters={setConceptFilters} tagCounts={tagCounts} baseTag={subjectTag}/>
<AllFiltersCheckbox
conceptFilters={conceptFilters} setConceptFilters={setConceptFilters} tagCounts={tagCounts} baseTag={subjectTag}
forceEnabled={applicableTags.filter(tag => !isDefined(tagCounts) || tagCounts[tag.id] > 0).length === 0}
/>
<div className="section-divider-small"/>
{applicableTags.map(tag =>
<FilterCheckbox
key={tag.id}
tag={tag}
conceptFilters={conceptFilters}
setConceptFilters={setConceptFilters}
tagCounts={tagCounts}
incompatibleTags={[subjectTag]}
baseTag={subjectTag}
/>
)}
{applicableTags
.filter(tag => !isDefined(tagCounts) || tagCounts[tag.id] > 0)
.map(tag =>
<FilterCheckbox
key={tag.id}
tag={tag}
conceptFilters={conceptFilters}
setConceptFilters={setConceptFilters}
tagCounts={tagCounts}
incompatibleTags={[subjectTag]}
baseTag={subjectTag}
/>
)
}
</div>

<div className="section-divider"/>
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/elements/markup/markdownRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ MARKDOWN_RENDERER.renderer.rules.link_open = function(tokens: Remarkable.LinkOpe
const href = utils.escapeHtml(tokens[idx].href || "");
const localLink = href.startsWith(window.location.origin) || href.startsWith("/") || href.startsWith("mailto:") || href.startsWith("#");
const title = tokens[idx].title ? (' title="' + utils.escapeHtml(utils.replaceEntities(tokens[idx].title || "")) + '"') : '';
const conceptIcon = "<i class=\"icon icon-lightbulb\"></i>";
if (localLink) {
return `<a class="a-link" href="${href}" ${title}>`;
return `<a class="a-link" href="${href}" ${title}>${isPhy && href.includes("/concepts/") ? conceptIcon : ""}`;
} else {
return `<a class="a-link" href="${href}" ${title} target="_blank" rel="noopener nofollow">`;
}
Expand Down
41 changes: 30 additions & 11 deletions src/app/components/pages/Concept.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Col, Container, Row} from "reactstrap";
import {ShowLoading} from "../handlers/ShowLoading";
import {IsaacContent} from "../content/IsaacContent";
import {IsaacConceptPageDTO} from "../../../IsaacApiTypes";
import {DOCUMENT_TYPE, Subject, above, below, usePreviousPageContext, isAda, isPhy, useDeviceSize, useNavigation} from "../../services";
import {DOCUMENT_TYPE, Subject, above, below, usePreviousPageContext, isAda, isPhy, useDeviceSize, useNavigation, siteSpecific} from "../../services";
import {DocumentSubject, GameboardContext} from "../../../IsaacAppTypes";
import {RelatedContent} from "../elements/RelatedContent";
import {WithFigureNumbering} from "../elements/WithFigureNumbering";
Expand Down Expand Up @@ -60,9 +60,9 @@ export const Concept = withRouter(({match: {params}, location: {search}, concept
<Container data-bs-theme={doc.subjectId ?? pageContext?.subject}>
<TitleAndBreadcrumb
intermediateCrumbs={navigation.breadcrumbHistory}
currentPageTitle={doc.title as string}
currentPageTitle={siteSpecific("Concept", doc.title as string)}
collectionType={navigation.collectionType}
subTitle={doc.subtitle as string}
subTitle={siteSpecific(undefined, doc.subtitle as string)}
preview={preview}
icon={{type: "hex", subject: doc.subjectId as Subject, icon: "page-icon-concept"}}
/>
Expand All @@ -73,14 +73,35 @@ export const Concept = withRouter(({match: {params}, location: {search}, concept
<SidebarLayout>
<ConceptSidebar relatedContent={doc.relatedContent} />
<MainContent>
<EditContentButton doc={doc} />
{isPhy && <>
<div className="no-print d-flex align-items-center mt-3">
<div>
<h2 className="text-theme-dark mb-4"><Markup encoding="latex">{doc.title as string}</Markup></h2>
{doc.subtitle && <h5 className="text-theme-dark">{doc.subtitle}</h5>}
</div>
<div className="d-flex gap-2 ms-auto">
<ShareLink linkUrl={`/concepts/${conceptId}${search || ""}`} />
<PrintButton questionPage />
<ReportButton pageId={conceptId}/>
</div>
</div>

{below["sm"](deviceSize) && <ManageButtons />}
<div className="section-divider"/>

<div className="d-flex justify-content-end align-items-center me-sm-1 flex-grow-1">
<UserContextPicker />
{above["md"](deviceSize) && <ManageButtons />}
</div>
<div className="d-flex justify-content-end align-items-center me-sm-1 flex-grow-1">
<EditContentButton doc={doc} />
<UserContextPicker />
</div>
</>}

{isAda && <>
{below["sm"](deviceSize) && <ManageButtons />}

<div className="d-flex justify-content-end align-items-center me-sm-1 flex-grow-1">
<UserContextPicker />
{above["md"](deviceSize) && <ManageButtons />}
</div>
</>}

<Row className="concept-content-container">
<Col className={classNames("py-4 concept-panel", {"mw-760": isAda})}>
Expand All @@ -102,8 +123,6 @@ export const Concept = withRouter(({match: {params}, location: {search}, concept
{isAda && doc.relatedContent && <RelatedContent conceptId={conceptId} content={doc.relatedContent} parentPage={doc} />}

<NavigationLinks navigation={navigation} />

{isPhy && doc.relatedContent && <RelatedContent conceptId={conceptId} content={doc.relatedContent} parentPage={doc} />}
</Col>
</Row>
</MainContent>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/pages/Concepts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Concepts = withRouter((props: RouteComponentProps) => {
};

const applicableTags = pageContext?.subject ? tags.getDirectDescendents(subjectToTagMap[pageContext.subject]) : tags.allFieldTags;
const tagCounts : Record<string, number> = applicableTags.reduce((acc, t) => ({...acc, [t.id]: concepts?.filter(c => c.tags?.includes(t.id)).length || 0}), {});
const tagCounts : Record<string, number> = [...applicableTags, ...(pageContext?.subject ? [tags.getById(pageContext?.subject as TAG_ID)] : [])].reduce((acc, t) => ({...acc, [t.id]: concepts?.filter(c => c.tags?.includes(t.id)).length || 0}), {});

useEffect(() => {
if (pageContext) {
Expand Down Expand Up @@ -105,7 +105,7 @@ export const Concepts = withRouter((props: RouteComponentProps) => {
: <GenericConceptsSidebar {...sidebarProps}/>
}
<MainContent>
{isPhy && <div className="list-results-container p-2 mt-4">
{isPhy && <div className="list-results-container p-2 my-4">
{shortcutAndFilteredSearchResults && <div className="p-2 py-3">
Showing <b>{shortcutAndFilteredSearchResults.length}</b> results
</div>}
Expand Down
5 changes: 2 additions & 3 deletions src/scss/common/scroll-button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
button.btn.scroll-btn {
button.scroll-btn.scroll-btn {
position: fixed;
display: flex;
opacity: 0;
height: 45px;
width: 45px;
Expand All @@ -15,8 +16,6 @@ button.btn.scroll-btn {

&.is-sticky {
opacity: 1;
display: flex;
// TODO: animate opacity on destruction
}

> img {
Expand Down
36 changes: 0 additions & 36 deletions src/scss/cs/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -178,42 +178,6 @@
position: relative;
z-index: 2;
}
.share-link {
z-index: 1;
top: 3px;
font-family: $secondary-font !important;
display: none;
position: absolute;
border: 1px solid gray;
transform: translate(calc(30px - 100%));
height: 42px;
width: 70%;

input {
z-index: 1;
padding-right: 40px;
padding-left: 10px;
white-space: nowrap;
text-overflow: ellipsis;
user-select: all;
-webkit-user-select: all;
-moz-user-select: all;
-ms-user-select: all;
width: 100%;
height: 100%;
}

&.double-height {
height: auto;
padding-bottom: 10px;
background: #fff;
text-align: center;
input {
height: 42px;
margin-bottom: 8px;
}
}
}
}

.print-icon {
Expand Down
Loading
Loading