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

Handle styling of varying amounts of DOJO exercise previews #2341

Closed
wants to merge 1 commit into from
Closed
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
29 changes: 16 additions & 13 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 chunk from 'lodash/chunk'

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

Expand Down Expand Up @@ -170,19 +172,20 @@ const ExerciseList = ({
</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>
{chunk(mockExercisePreviews, 3).map((exercisePreviewChunk, i) => (
Copy link
Collaborator Author

@bryanjenningz bryanjenningz Sep 23, 2022

Choose a reason for hiding this comment

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

This works well for 1000px width screens and above. We'll need to handle smaller screens in the future when the designs are ready.

<div key={i} className="row mb-4">
{exercisePreviewChunk.map((exercisePreview, j) => (
<div key={j} className="col-4 d-flex">
<ExercisePreviewCard
moduleName={exercisePreview.moduleName}
state={exercisePreview.state}
problem={exercisePreview.problem}
className="flex-grow-1"
/>
</div>
))}
</div>
))}
</div>
</>
)
Expand Down