Skip to content

Commit

Permalink
Merge pull request #2342 from bryanjenningz/make-exercise-list-respon…
Browse files Browse the repository at this point in the history
…sive

Make DOJO exercise list responsive
  • Loading branch information
bryanjenningz authored Sep 24, 2022
2 parents 482e8a5 + 12945fb commit 4c87423
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
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%;
}
}

1 comment on commit 4c87423

@vercel
Copy link

@vercel vercel bot commented on 4c87423 Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.