Skip to content

Commit

Permalink
Make exercise list responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjenningz committed Sep 24, 2022
1 parent 482e8a5 commit caa7909
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
29 changes: 15 additions & 14 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 @@ -169,20 +175,15 @@ const ExerciseList = ({
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>
<div className={styles.exerciseList__container}>
{mockExercisePreviews.map((exercisePreview, i) => (
<ExercisePreviewCard
key={i}
moduleName={exercisePreview.moduleName}
state={exercisePreview.state}
problem={exercisePreview.problem}
/>
))}
</div>
</>
)
Expand Down
5 changes: 5 additions & 0 deletions scss/exercises.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.exerciseList__container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 2em;
}

0 comments on commit caa7909

Please sign in to comment.