Skip to content
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

enhance(apps/frontend-manage): make activity evaluation pages resizable #4362

Merged
merged 16 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { ChoicesElementInstanceEvaluation } from '@klicker-uzh/graphql/dist/ops'
import { ChartType } from '@klicker-uzh/shared-components/src/constants'
import { useLocalStorage } from '@uidotdev/usehooks'
import { twMerge } from 'tailwind-merge'
import ElementChart from '../ElementChart'
import { TextSizeType } from '../textSizes'
import ChoicesSidebar from './ChoicesSidebar'

import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@uzh-bf/design-system/dist/future'

interface ChoicesEvaluationProps {
instanceEvaluation: ChoicesElementInstanceEvaluation
textSize: TextSizeType
Expand All @@ -18,29 +25,43 @@ function ChoicesEvaluation({
chartType,
showSolution,
}: ChoicesEvaluationProps) {
const [isCollapsed, setIsCollapsed] = useLocalStorage(
TheHummel marked this conversation as resolved.
Show resolved Hide resolved
`evaluation-${instanceEvaluation.id}-isCollapsed`,
false
)

return (
<>
<div className="order-2 flex-1 px-4 md:order-1">
<ResizablePanelGroup direction="horizontal">
<ResizablePanel
defaultSize={isCollapsed ? 100 : 80}
minSize={50}
className="px-4"
>
<ElementChart
chartType={chartType}
instanceEvaluation={instanceEvaluation}
showSolution={showSolution}
textSize={textSize}
/>
</div>
<div
className={twMerge(
'order-1 flex flex-none flex-col gap-2 border-l px-4 py-2 md:order-2 md:w-64 lg:w-72 xl:w-80',
textSize.text
)}
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel
key={`parent-${instanceEvaluation.id}-${isCollapsed ? 'collapsed' : 'expanded'}`}
defaultSize={isCollapsed ? 0 : 20}
minSize={10}
collapsible
collapsedSize={0}
onCollapse={() => setIsCollapsed(true)}
TheHummel marked this conversation as resolved.
Show resolved Hide resolved
onExpand={() => setIsCollapsed(false)}
className={twMerge('gap-2 border-l px-4 py-2', textSize.text)}
>
<ChoicesSidebar
instance={instanceEvaluation}
textSize={textSize}
showSolution={showSolution}
/>
</div>
</>
</ResizablePanel>
</ResizablePanelGroup>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import ElementChart from '../ElementChart'
import { TextSizeType } from '../textSizes'
import FTSidebar from './FTSidebar'

import { useLocalStorage } from '@uidotdev/usehooks'
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@uzh-bf/design-system/dist/future'

interface FTEvaluationProps {
instanceEvaluation: FreeElementInstanceEvaluation
textSize: TextSizeType
Expand All @@ -18,27 +25,56 @@ function FTEvaluation({
chartType,
showSolution,
}: FTEvaluationProps) {
const [isCollapsed, setIsCollapsed] = useLocalStorage(
rschlaefli marked this conversation as resolved.
Show resolved Hide resolved
`evaluation-${instanceEvaluation.id}-isCollapsed`,
false
)

return (
<>
<div className="order-2 flex-1 px-4 md:order-1">
<ElementChart
chartType={chartType}
instanceEvaluation={instanceEvaluation}
showSolution={showSolution}
textSize={textSize}
/>
</div>
{instanceEvaluation.results.solutions && showSolution && (
<div
className={twMerge(
'order-1 flex flex-none flex-col gap-2 border-l px-4 py-2 md:order-2 md:w-64 lg:w-72 xl:w-80',
textSize.text
)}
>
<FTSidebar
instance={instanceEvaluation}
textSize={textSize}
{showSolution ? (
<ResizablePanelGroup direction="horizontal">
<ResizablePanel
defaultSize={isCollapsed ? 100 : 80}
minSize={50}
className="px-4"
>
<ElementChart
chartType={chartType}
instanceEvaluation={instanceEvaluation}
showSolution={showSolution}
textSize={textSize}
/>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel
key={`parent-${instanceEvaluation.id}-${isCollapsed ? 'collapsed' : 'expanded'}`}
defaultSize={isCollapsed ? 0 : 20}
minSize={10}
collapsible
collapsedSize={0}
onCollapse={() => setIsCollapsed(true)}
onExpand={() => setIsCollapsed(false)}
className={twMerge('gap-2 border-l px-4 py-2', textSize.text)}
>
{instanceEvaluation.results.solutions &&
showSolution &&
!isCollapsed && (
<FTSidebar
instance={instanceEvaluation}
textSize={textSize}
showSolution={showSolution}
/>
)}
</ResizablePanel>
</ResizablePanelGroup>
) : (
<div className="order-2 flex-1 px-4 md:order-1">
<ElementChart
chartType={chartType}
instanceEvaluation={instanceEvaluation}
showSolution={showSolution}
textSize={textSize}
/>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import ElementChart from '../ElementChart'
import { TextSizeType } from '../textSizes'
import NumericalSidebar from './NumericalSidebar'

import { useLocalStorage } from '@uidotdev/usehooks'
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@uzh-bf/design-system/dist/future'

interface NREvaluationProps {
instanceEvaluation: NumericalElementInstanceEvaluation
textSize: TextSizeType
Expand All @@ -18,29 +25,45 @@ function NREvaluation({
chartType,
showSolution,
}: NREvaluationProps) {
const [isCollapsed, setIsCollapsed] = useLocalStorage(
rschlaefli marked this conversation as resolved.
Show resolved Hide resolved
`evaluation-${instanceEvaluation.id}-isCollapsed`,
false
)

return (
<>
<div className="order-2 flex-1 px-4 md:order-1">
<ResizablePanelGroup direction="horizontal">
<ResizablePanel
defaultSize={isCollapsed ? 100 : 80}
minSize={50}
className="px-4"
>
<ElementChart
chartType={chartType}
instanceEvaluation={instanceEvaluation}
showSolution={showSolution}
textSize={textSize}
/>
</div>
<div
className={twMerge(
'order-1 flex flex-none flex-col gap-2 border-l px-4 py-2 md:order-2 md:w-64 lg:w-72 xl:w-80',
textSize.text
)}
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel
key={`parent-${instanceEvaluation.id}-${isCollapsed ? 'collapsed' : 'expanded'}`}
defaultSize={isCollapsed ? 0 : 20}
minSize={10}
collapsible
collapsedSize={0}
onCollapse={() => setIsCollapsed(true)}
onExpand={() => setIsCollapsed(false)}
className={twMerge('gap-2 border-l px-4 py-2', textSize.text)}
rschlaefli marked this conversation as resolved.
Show resolved Hide resolved
>
<NumericalSidebar
instance={instanceEvaluation}
textSize={textSize}
showSolution={showSolution}
/>
</div>
</>
{!isCollapsed && (
<NumericalSidebar
instance={instanceEvaluation}
textSize={textSize}
showSolution={showSolution}
/>
)}
</ResizablePanel>
</ResizablePanelGroup>
)
}

Expand Down
Loading