Skip to content

Commit 3ef5110

Browse files
committed
cards
1 parent fc33a8d commit 3ef5110

File tree

3 files changed

+45
-48
lines changed

3 files changed

+45
-48
lines changed

src/components/card/card.jsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import styles from "./card.module.scss";
22

33
const Card = (props) => {
44
return (
5-
<div className={`${styles.root} ${props.extraClasses}`}>
5+
<div
6+
className={`${styles.root} ${props.extraClasses} card`}
7+
data-tags={props.tags?.map((tag) => tag)}
8+
>
69
{props.logo && (
710
<a href={props.link} className={styles.logoHeader}>
811
<img
@@ -35,15 +38,16 @@ const Card = (props) => {
3538
<img src="/images/topic.svg" alt="" />
3639
Topics
3740
</span>
38-
{props.tags.map((tag) => (
39-
<button
40-
className={styles.topic}
41-
key={tag}
42-
onClick={() => props.tagChanger(tag)}
43-
>
44-
{tag}
45-
</button>
46-
))}
41+
<div className="card-tags">
42+
{props.tags.map((tag) => (
43+
<button
44+
className={styles.topic}
45+
onClick={() => props.tagChanger(tag)}
46+
>
47+
{tag}
48+
</button>
49+
))}
50+
</div>
4751
</div>
4852
)}
4953
{props.topics && (
@@ -52,11 +56,13 @@ const Card = (props) => {
5256
<img src="/images/focus.svg" alt="" />
5357
Focus Areas
5458
</span>
55-
{props.topics.map((topic) => (
56-
<span key={topic} className={styles.topic}>
57-
{topic}
58-
</span>
59-
))}
59+
<div className="card-tags">
60+
{props.topics.map((topic) => (
61+
<span key={topic} className={styles.topic}>
62+
{topic}
63+
</span>
64+
))}
65+
</div>
6066
</div>
6167
)}
6268
</div>

src/components/card/card.module.scss

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
.service-card {
1313
padding-bottom: 20px;
1414
}
15+
.hidden {
16+
display: none;
17+
}
1518
}
1619

1720
.logoHeader {
@@ -78,33 +81,6 @@
7881
}
7982
}
8083

81-
.cmsLink {
82-
position: absolute;
83-
bottom: 0;
84-
right: 0;
85-
border-top-left-radius: 5px;
86-
background: #ece9f7;
87-
text-decoration: none;
88-
font-size: 0.9rem;
89-
padding: 0.33rem 1rem;
90-
&::after {
91-
content: "";
92-
display: inline-block;
93-
width: 1rem;
94-
height: 1rem;
95-
background: #4caa9f;
96-
mask: url(/images/netlify-cms.png);
97-
mask-size: cover;
98-
position: relative;
99-
top: 2px;
100-
margin-left: 0.25rem;
101-
}
102-
&:hover {
103-
background: #1a0e41;
104-
color: white;
105-
}
106-
}
107-
10884
.cardContent {
10985
padding: 1.5rem;
11086
color: #47356f;
@@ -156,7 +132,7 @@
156132
padding: 0;
157133
color: #6a5a8a;
158134
text-transform: capitalize;
159-
&:not(:nth-child(2)) {
135+
&:not(:nth-child(1)) {
160136
&::before {
161137
content: "·";
162138
margin: 0 0.33rem;

src/pages/resources.astro

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ const tags = [...new Set(flatTags.map(JSON.stringify))].map(JSON.parse);
2222
<nav class="nav closed" id="tagList">
2323
Topics:{" "}
2424
{tags.map((tag, i) => {
25-
return (
26-
<button key={tag} onClick={() => onTagClick(tag)} class="tag">
27-
{tag}
28-
</button>
29-
);
25+
return <button class="tag">{tag}</button>;
3026
})}
3127
<button class="more" id="moreResourcesButton"> More </button>
3228
</nav>
@@ -51,6 +47,25 @@ const tags = [...new Set(flatTags.map(JSON.stringify))].map(JSON.parse);
5147
moreResourcesButton.addEventListener("click", () => {
5248
tagList.classList.toggle("closed");
5349
});
50+
51+
const cards = document.querySelectorAll(".card");
52+
const tagButtons = document.querySelectorAll(
53+
".nav button:not(#moreResourcesButton), .card-tags button"
54+
);
55+
tagButtons.forEach((button) => {
56+
button.addEventListener("click", () => {
57+
let tagText = button.innerText.toLowerCase();
58+
cards.forEach((card) => {
59+
card.classList.add("hidden");
60+
});
61+
const cardsToShow = document.querySelectorAll(
62+
".card[data-tags*='" + tagText + "']"
63+
);
64+
cardsToShow.forEach((card) => {
65+
card.classList.remove("hidden");
66+
});
67+
});
68+
});
5469
</script>
5570

5671
<style lang="scss">

0 commit comments

Comments
 (0)