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

Make DOJO exercise list responsive #2342

Merged
merged 2 commits into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 27 additions & 19 deletions pages/exercises/[lessonSlug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { NewButton } from '../../components/theme/Button'
import ExerciseCard, { ExerciseCardProps } from '../../components/ExerciseCard'
import { ArrowLeftIcon } from '@primer/octicons-react'
import GET_EXERCISES from '../../graphql/queries/getExercises'
import styles from '../../scss/exercises.module.scss'

const exampleProblem = `const a = 5
a = a + 10
Expand All @@ -24,6 +25,11 @@ a = a + 10
const mockExercisePreviews: ExercisePreviewCardProps[] = [
{ moduleName: 'Variables', state: 'ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'NOT ANSWERED', problem: exampleProblem },
{ moduleName: 'Variables', state: 'ANSWERED', problem: exampleProblem }
]

Expand Down Expand Up @@ -163,27 +169,29 @@ const ExerciseList = ({
tabs={tabs}
/>
</div>
<div className="d-flex justify-content-between align-items-center">
<h1 className="my-5 fs-2">{lessonTitle}</h1>
<NewButton onClick={() => setExerciseIndex(0)}>
SOLVE EXERCISES
</NewButton>
</div>
<div className="container">
<div className="row">
{mockExercisePreviews.map((exercisePreview, i) => (
<ExercisePreviewCard
key={i}
moduleName={exercisePreview.moduleName}
state={exercisePreview.state}
problem={exercisePreview.problem}
className={`col ${
i < mockExercisePreviews.length - 1 ? 'me-4' : ''
}`}
/>
))}
<div className="d-flex flex-column flex-md-row justify-content-between align-items-center">
<h1 className="my-2 my-md-5 fs-2">{lessonTitle}</h1>
<div
className={`mb-3 mb-md-0 d-flex d-md-block ${styles.exerciseList__solveExercisesButtonContainer}`}
>
<NewButton
className="flex-grow-1"
onClick={() => setExerciseIndex(0)}
>
SOLVE EXERCISES
</NewButton>
</div>
</div>
<div className={styles.exerciseList__container}>
{mockExercisePreviews.map((exercisePreview, i) => (
<ExercisePreviewCard
key={i}
moduleName={exercisePreview.moduleName}
state={exercisePreview.state}
problem={exercisePreview.problem}
/>
))}
</div>
</>
)
}
Expand Down
11 changes: 11 additions & 0 deletions scss/exercises.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.exerciseList__container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 2em;
}

.exerciseList__solveExercisesButtonContainer {
@media (max-width: 767px) {
width: 100%;
}
}
flacial marked this conversation as resolved.
Show resolved Hide resolved