-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
123 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
} | ||
|
||
.mainContent { | ||
margin-top: 3rem; | ||
margin-top: 2rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
.heading { | ||
text-transform: initial; | ||
} | ||
|
||
.categories { | ||
margin-bottom: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
@import '@/styles/vars'; | ||
|
||
.blogs { | ||
margin-top: 3rem; | ||
gap: 3rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import styles from './styles.module.scss'; | ||
import { Category } from '@/components/categories/types'; | ||
import CategoryLink from './category-link/CategoryLink'; | ||
|
||
interface Props { | ||
categories: Category[] | undefined; | ||
activeCategory?: Category['attributes']['name']; | ||
} | ||
|
||
const Categories: FunctionComponent<Props> = ({ categories, activeCategory }) => { | ||
if (!categories || !categories.length) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ul className={`${styles.categories}`}> | ||
{categories.map((category) => ( | ||
<li key={category.id}> | ||
<CategoryLink activeCategory={activeCategory} name={category.attributes.name} /> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default Categories; |
22 changes: 22 additions & 0 deletions
22
next/src/components/categories/category-link/CategoryLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Link from 'next/link'; | ||
import React, { FunctionComponent } from 'react'; | ||
import styles from './styles.module.scss'; | ||
import { Category } from '@/components/categories/types'; | ||
|
||
interface Props { | ||
name: string; | ||
activeCategory?: Category['attributes']['name']; | ||
} | ||
|
||
const CategoryLink: FunctionComponent<Props> = ({ activeCategory, name }) => { | ||
const isActiveCategory = name === activeCategory; | ||
|
||
const setActiveCategory = isActiveCategory ? styles.active : ''; | ||
const setHref = isActiveCategory ? '/blog' : `/blog?category=${name}`; | ||
|
||
return ( | ||
<Link className={`${styles.link} ${setActiveCategory}`} href={setHref}>#{name}</Link> | ||
); | ||
}; | ||
|
||
export default CategoryLink; |
9 changes: 9 additions & 0 deletions
9
next/src/components/categories/category-link/styles.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import '@/styles/vars'; | ||
|
||
.link { | ||
color: darken($color-text, 40%); | ||
|
||
&.active { | ||
color: $color-accent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@import '@/styles/vars'; | ||
|
||
.categories { | ||
margin-bottom: 3rem; | ||
justify-content: flex-start; | ||
display: flex; | ||
gap: .5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export interface Category { | ||
id: number; | ||
attributes: { | ||
name: string; | ||
color: string; | ||
background: string; | ||
createdAt: string, | ||
updatedAt: string, | ||
publishedAt: string, | ||
}; | ||
} | ||
export interface CategoriesFetchResponse { | ||
data: Category[], | ||
meta: { | ||
pagination: { | ||
page: number, | ||
pageSize: number, | ||
pageCount: number, | ||
total: number | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters