Skip to content

Commit 3acc7bc

Browse files
Add tags to questions page (#19)
* Pills - Created Pill component - Added pill component to questions webpage - Added pill component to solution webpage as well - Updated Color * Created Tags Collection - Filled a newly created folder with tags - Created python program to updated tags if program is run - Updated tag collection format - Hardcoded lists of tags were erased from different pages that used getStaticPath and others * Update script formatting * Add tag style site fixes * Remove comment --------- Co-authored-by: Matthew M-B <[email protected]>
1 parent 0e99a4c commit 3acc7bc

File tree

60 files changed

+578
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+578
-351
lines changed

src/components/MultipleChoiceQuestion/MultipleChoiceQuestion.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
const { index, question, interactive } = Astro.props;
2+
const { index, question, interactive, displaySolution } = Astro.props;
33
import MultipleChoiceQuestionOption from "./MultipleChoiceQuestionOption.astro";
44
import "./MultipleChoiceQuestion.scss";
55
const numberString =
@@ -16,6 +16,7 @@ const numberString =
1616
<MultipleChoiceQuestionOption
1717
option={option}
1818
interactive={interactive}
19+
displaySolution={displaySolution}
1920
questionIndex={index}
2021
optionIndex={optionIndex}
2122
/>

src/components/MultipleChoiceQuestion/MultipleChoiceQuestionOption.astro

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
2-
const { questionIndex, optionIndex, option, interactive } = Astro.props;
2+
const { questionIndex, optionIndex, option, interactive, displaySolution } =
3+
Astro.props;
34
import "./MultipleChoiceQuestionOption.scss";
45
56
const letterOptions = ["a", "b", "c", "d", "e"];
7+
const initiallyDisplaySelectedSolution = displaySolution && option.correct;
68
---
79

810
<div
9-
id={`MultipleChoiceQuestion-${questionIndex}-option-${optionIndex}`}
11+
id={`MultipleChoiceQuestion-${questionIndex}-option-${optionIndex}}`}
1012
class={`MultipleChoiceQuestionOption`}
1113
data-correct={option.correct ? "true" : "false"}
12-
data-selected="false"
13-
data-revealed={interactive ? "false" : "true"}
14+
data-selected={initiallyDisplaySelectedSolution ? "true" : "false"}
15+
data-revealed={displaySolution ? "true" : "false"}
1416
data-interactive={interactive ? "true" : "false"}
1517
>
1618
<div class="MultipleChoiceQuestionOption__letter">

src/components/MultipleChoiceQuestion/MultipleChoiceQuestionOption.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
&:hover {
1818
&[data-interactive="true"] {
1919
background-color: #ededed;
20-
}
21-
&[data-selected="false"] {
22-
cursor: pointer;
20+
&[data-selected="false"] {
21+
cursor: pointer;
22+
}
2323
}
2424
}
2525

src/components/Tag/Tag.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
const { id, label } = Astro.props;
3+
import "./Tag.scss";
4+
---
5+
6+
<a href={`/practice/tag/${id}`}>
7+
<button class="Tag">
8+
<div class="Tag__label">{label}</div>
9+
</button>
10+
</a>

src/components/Tag/Tag.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.Tag {
2+
border-radius: 0.7rem;
3+
border-width: 0px;
4+
background-color: #efefef;
5+
color: #3a3a3a;
6+
transition: all 0.15s;
7+
font-weight: 600;
8+
font-size: 0.85rem;
9+
cursor: pointer;
10+
padding: 0.3rem 0.95rem;
11+
height: 1.9rem;
12+
display: inline-flex;
13+
align-items: center;
14+
width: fit-content;
15+
16+
&:hover {
17+
color: white;
18+
background-color: #ff4d4d;
19+
}
20+
21+
&__label {
22+
display: flex;
23+
align-items: center;
24+
gap: 0.2rem;
25+
}
26+
}

src/content/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ const evaluationCollection = defineCollection({
2424
}),
2525
});
2626

27+
const tagCollection = defineCollection({
28+
type: "content",
29+
schema: z.object({
30+
course: z.string(),
31+
tag: z.string(),
32+
title: z.string(),
33+
}),
34+
});
35+
2736
export const collections = {
2837
questions: questionCollection,
2938
evaluations: evaluationCollection,
39+
tags: tagCollection,
3040
};
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)