Skip to content

Commit 176780e

Browse files
authored
Move StyledExercise outside component (#96)
* move styledexercise outside component * remove extra space * snapshots update
1 parent 41087ae commit 176780e

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openstax/assessment-components",
3-
"version": "1.2.6",
3+
"version": "1.2.10",
44
"license": "MIT",
55
"source": "./src/index.ts",
66
"types": "./dist/src/index.d.ts",

src/components/ExercisePreview.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ import { ExerciseData, ExerciseQuestionData, StepBase } from "src/types";
33
import { Exercise } from "./Exercise";
44
import styled from "styled-components";
55

6+
7+
const StyledExercise = styled(Exercise)<{ showAllFeedback?: boolean; showCorrectAnswer?: boolean }>`
8+
${({ showAllFeedback }) => !showAllFeedback &&
9+
`.step-card-footer {
10+
display: none;
11+
}`
12+
}
13+
${({ showCorrectAnswer }) => !showCorrectAnswer &&
14+
`.answer-answer {
15+
font-weight: normal;
16+
& > div {
17+
display: none;
18+
}
19+
}`
20+
}
21+
`;
622
export interface ExercisePreviewProps {
723
exercise: ExerciseData;
824
selected?: boolean;
@@ -78,30 +94,15 @@ export const ExercisePreview = (
7894
};
7995
};
8096

81-
const StyledExercise = styled(Exercise)`
82-
83-
${(!showAllFeedback) &&
84-
`.step-card-footer {
85-
display: none;
86-
}`
87-
}
88-
${!showCorrectAnswer &&
89-
`.answer-answer {
90-
font-weight: normal;
91-
& > div {
92-
display: none;
93-
}
94-
}`
95-
}
96-
`;
97-
9897
return (
9998
<StyledExercise
10099
exercise={showAllFeedback ? exercise : hideAnswerFeedback(exercise)}
101100
className={`preview-card ${selected ? 'is-selected' : ''}`}
102101
previewMode
103102
overlayChildren={overlayChildren}
104103
{...exercisePreviewProps(exercise)}
104+
showAllFeedback={showAllFeedback}
105+
showCorrectAnswer={showCorrectAnswer}
105106
/>
106107
);
107108
};

src/components/__snapshots__/ExercisePreview.spec.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and corre
99
data-task-step-id={1}
1010
>
1111
<div
12-
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fEOsli QCsJH ubRcZ preview-card is-selected"
12+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH ghrOKm preview-card is-selected"
1313
>
1414
<div
1515
onBlur={[Function]}
@@ -199,7 +199,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
199199
data-task-step-id={1}
200200
>
201201
<div
202-
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-bjUoiL QCsJH cePIaL preview-card is-selected"
202+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH ignuyR preview-card is-selected"
203203
>
204204
<div
205205
onBlur={[Function]}
@@ -383,7 +383,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
383383
data-task-step-id={1}
384384
>
385385
<div
386-
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH kKGUqH preview-card is-selected"
386+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH ignuyR preview-card is-selected"
387387
>
388388
<div
389389
onBlur={[Function]}
@@ -567,7 +567,7 @@ exports[`ExercisePreview using step data matches snapshot without overlay 1`] =
567567
data-task-step-id={1}
568568
>
569569
<div
570-
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-idiyUo QCsJH mjsmp preview-card "
570+
className="sc-bczRLJ eAXREJ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-fnykZs QCsJH JxRcU preview-card "
571571
>
572572
<div>
573573
<div

0 commit comments

Comments
 (0)