-
Notifications
You must be signed in to change notification settings - Fork 5
Question finder redesign #1026
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
Question finder redesign #1026
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
be5fd1c
Prefer namespace-independent RS imports
jacbn 62b6c32
StyledCheckbox: colours, minor code cleanup
jacbn b219880
Genericise dropdown chevron styles
jacbn 539eac0
Initial QF redesign; layout and filters
jacbn b526d49
Merge branch 'master' into question-finder-redesign
skyepurchase f934829
Implement Ada filter structure
skyepurchase 3b1dcf4
Implement filter counts
skyepurchase b74b486
Implement filter bar functionality
skyepurchase b245f44
Search bar styling
skyepurchase 5f652a8
Implement apply filters button
skyepurchase 9d02b77
Implement temporary question status filters
skyepurchase b07bef7
Make filter button sticky within filter card
skyepurchase 23a8348
Add difficulty modal link
skyepurchase cf6e563
Fix style changes on Physics
skyepurchase 9058438
Add book filter options
skyepurchase 1b04942
Revert book exclusion option
skyepurchase 8929e04
Increase width of question finder on Physics
skyepurchase 065bd2a
Implement visual filters
skyepurchase 029cb07
Fix difficulty icon alignment
skyepurchase cbffd3e
Implement book question exclusion
skyepurchase 148ca7c
Add topic count and clearing to Physics
skyepurchase 5e3e9a0
Disable apply filters when no filters change
skyepurchase 42f64b8
Refactor out QuestionFinderFilterPanel
mlt47 5046858
Refactor QF list state to use reducer
mlt47 1fea9dd
Use CSS only for CollapsibleList transitions
mlt47 072ef33
Remove exclude books check
mlt47 1a2691f
Remove unused code & comments from new QF
mlt47 77c28f9
Remove revision mode option
skyepurchase 7aace79
Remove invalid exam boards based on stage
skyepurchase 5df55c3
Improve filter panel on small screens
skyepurchase e829976
Fix closed filters on large screens
skyepurchase 43748af
Implement new summary item difficulty styling
skyepurchase 5f1790b
Add modal for difficulty explanation
jacbn 6563965
Improve collapsible list animation
jacbn c4cfe92
Remove unnecessary div around collapsible lists
jacbn efc3806
Restyle question list group items
skyepurchase 5a9108b
Restyle 'Load more' button
skyepurchase f7073b1
CSS improvements on lg screens
jacbn 2e03f47
Correct sizing and y-alignment of progress icon
jacbn f35af71
Make search input button clickable
jacbn 49ec3f7
Make the entire filter dropdown clickable on mobile
jacbn ece4a90
Tidy "no results" box, allow customising Collapsibles
jacbn 66fe6ec
Trial displaying question difficulty on xs devices
jacbn 57edbd5
Change Ada page title
skyepurchase 142844c
Fix 'apply filters' padding
skyepurchase a5d24dd
Add Ada background image
skyepurchase b3cd8c5
Improve question block logic
skyepurchase 2e320f5
Move difficulty icons below title on small screens
skyepurchase 88a6e0a
Improve styling on Physics
skyepurchase 71f604f
Revert commit 66fe6ec
skyepurchase a15eb43
Fill results from user context if no URL params provided
jacbn 338d662
Tidy up hook calls, move related code together
jacbn 65aba47
Continue refactoring for code clarity
jacbn 4fc63c0
Update difficulty modal texts
jacbn 266009b
Change hide complete filter wording on Physics
skyepurchase cf2df2d
Improve apply filters disable condition
skyepurchase 115ab84
Use hexagons for Physics filter count
skyepurchase 5e3b691
Fix ESLint warning
skyepurchase 8c291c2
Fix buggy nested collapsible list behaviour
jacbn f61d385
Remove `data-targetHeight` on collapsibles' rows
jacbn 2e595b2
Add white background to "Apply filters" button
jacbn 5db0c53
Remove console log
jacbn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useLayoutEffect, useRef, useState } from "react"; | ||
import { Col, Row } from "reactstrap"; | ||
import { Spacer } from "./Spacer"; | ||
import { FilterCount } from "./svg/FilterCount"; | ||
import classNames from "classnames"; | ||
|
||
export interface CollapsibleListProps { | ||
title?: string; | ||
asSubList?: boolean; | ||
expanded: boolean; | ||
toggle: () => void; | ||
numberSelected?: number; | ||
children?: React.ReactNode; | ||
className?: string; | ||
} | ||
|
||
export const CollapsibleList = (props: CollapsibleListProps) => { | ||
const {expanded, toggle} = props; | ||
const [expandedHeight, setExpandedHeight] = useState(0); | ||
const listRef = useRef<HTMLDivElement>(null); | ||
const headRef = useRef<HTMLDivElement>(null); | ||
|
||
useLayoutEffect(() => { | ||
if (!listRef.current) return; | ||
setExpandedHeight(listRef.current.clientHeight); | ||
}, [listRef.current]); | ||
|
||
useLayoutEffect(() => { | ||
if (expanded) { | ||
setExpandedHeight(listRef?.current ? [...listRef.current.children].map(c => | ||
c.getAttribute("data-targetHeight") ? parseInt(c.getAttribute("data-targetHeight") as string) : c.clientHeight | ||
).reduce((a, b) => a + b, 0) : 0); | ||
} | ||
}, [expanded, props.children]); | ||
|
||
const title = props.title && props.asSubList ? props.title : <b>{props.title}</b>; | ||
|
||
return <Col className={props.className} data-targetHeight={(headRef.current?.offsetHeight ?? 0) + (expanded ? expandedHeight : 0)}> | ||
<div className="row collapsible-head" ref={headRef}> | ||
<button className={classNames("w-100 d-flex align-items-center p-3 bg-white text-start", {"ps-4": props.asSubList})} onClick={toggle}> | ||
{title && <span>{title}</span>} | ||
<Spacer/> | ||
{(props.numberSelected ?? 0) > 0 | ||
&& <FilterCount count={props.numberSelected ?? 0} />} | ||
<img className={classNames("icon-dropdown-90", {"active": expanded})} src={"/assets/common/icons/chevron_right.svg"} alt="" /> | ||
</button> | ||
</div> | ||
<Row | ||
className={`collapsible-body overflow-hidden ${expanded ? "open" : "closed"}`} | ||
style={{height: expanded ? expandedHeight : 0, maxHeight: expanded ? expandedHeight : 0}} | ||
> | ||
<Col> | ||
<div ref={listRef} className={classNames({"ms-2": props.asSubList})}> | ||
{props.children} | ||
</div> | ||
</Col> | ||
</Row> | ||
</Col>; | ||
}; |
61 changes: 46 additions & 15 deletions
61
src/app/components/elements/StageAndDifficultySummaryIcons.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,52 @@ | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
import {isAda, isPhy, STAGE, stageLabelMap} from "../../services"; | ||
import {simpleDifficultyLabelMap, siteSpecific, STAGE, stageLabelMap} from "../../services"; | ||
import {DifficultyIcons} from "./svg/DifficultyIcons"; | ||
import {ViewingContext} from "../../../IsaacAppTypes"; | ||
import { Difficulty } from "../../../IsaacApiTypes"; | ||
|
||
export function StageAndDifficultySummaryIcons({audienceViews, className}: {audienceViews: ViewingContext[], className?: string}) { | ||
// FIXME find a better way than hiding the whole thing on mobile | ||
return <div className={classNames(className, "mt-1", {"d-none d-sm-flex flex-wrap justify-content-end align-items-baseline": isAda, "d-sm-flex mt-md-0": isPhy})}> | ||
{audienceViews.map((view, i) => | ||
<div key={`${view.stage} ${view.difficulty} ${view.examBoard}`} className={classNames("align-self-center", {"ms-sm-3 ms-md-2": isPhy && (i > 0), "d-flex d-md-block": isPhy, "d-block text-center mx-2 my-1": isAda})}> | ||
{view.stage && view.stage !== STAGE.ALL && <div className="hierarchy-tags text-center"> | ||
{stageLabelMap[view.stage]} | ||
</div>} | ||
{view.difficulty && <div className={classNames("hierarchy-tags text-center", {"ms-md-0 ms-2": isPhy})}> | ||
<DifficultyIcons difficulty={view.difficulty} /> | ||
</div>} | ||
</div>) | ||
} | ||
</div> | ||
export function StageAndDifficultySummaryIcons({audienceViews, className, stack}: { | ||
audienceViews: ViewingContext[], | ||
className?: string, | ||
stack?: boolean, | ||
}) { | ||
const difficulties: Difficulty[] = audienceViews.map(v => v.difficulty).filter(v => v !== undefined); | ||
return siteSpecific( | ||
<div className={classNames(className, "mt-1 d-sm-flex mt-md-0")}> | ||
{audienceViews.map((view, i) => | ||
<div key={`${view.stage} ${view.difficulty} ${view.examBoard}`} className={classNames("align-self-center d-flex d-md-block", {"ms-sm-3 ms-md-2": i > 0})}> | ||
{view.stage && view.stage !== STAGE.ALL && <div className="hierarchy-tags text-center"> | ||
{stageLabelMap[view.stage]} | ||
</div>} | ||
{view.difficulty && <div className="hierarchy-tags text-center ms-md-0 ms-2"> | ||
<DifficultyIcons difficulty={view.difficulty} /> | ||
</div>} | ||
</div>) | ||
} | ||
</div>, | ||
<div className={classNames(className, "d-sm-flex flex-wrap mt-1 align-items-baseline", {"justify-content-end": !stack})}> | ||
{ | ||
difficulties.every((v, _i, arr) => v === arr[0]) | ||
? <div key={`${difficulties[0]}`} className={classNames("align-self-center d-flex align-items-center")}> | ||
{difficulties.length > 0 && <> | ||
<div className="hierarchy-tags text-center me-2"> | ||
{simpleDifficultyLabelMap[difficulties[0]]} | ||
</div> | ||
<div className="hierarchy-tags text-center"> | ||
<DifficultyIcons difficulty={difficulties[0]} blank classnames="mt-n1"/> | ||
</div> | ||
</>} | ||
</div> | ||
: audienceViews.map(view => | ||
<div key={`${view.difficulty}`} className={classNames("align-self-center d-block text-center mx-2 my-1")}> | ||
{view.stage && view.stage !== STAGE.ALL && <div className="hierarchy-tags text-center"> | ||
{stageLabelMap[view.stage]} | ||
</div>} | ||
{view.difficulty && <div className="hierarchy-tags text-center"> | ||
<DifficultyIcons difficulty={view.difficulty} /> | ||
</div>} | ||
</div>) | ||
} | ||
</div>, | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.