-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Disentangle Search Bar from Blog page * Create use-data; use for blog-context * Explore sections and search bar are components shared by blog and webinars * Make Breadcrumb a component * Latest webinars page * Explore pages * Search page * Fix dependency lists * Remove use of any * Code review * 2
- Loading branch information
1 parent
d2e6259
commit 4fe02e3
Showing
53 changed files
with
1,164 additions
and
706 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.breadcrumb { | ||
align-items: center; | ||
font-weight: bold; | ||
display: flex; | ||
gap: 1rem; | ||
margin: 3rem 0 2rem; | ||
text-decoration: none; | ||
width: 100%; | ||
} |
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,40 @@ | ||
import React from 'react'; | ||
import {Link, useNavigate, useLocation} from 'react-router-dom'; | ||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; | ||
import {faChevronLeft} from '@fortawesome/free-solid-svg-icons/faChevronLeft'; | ||
import './breadcrumb.scss'; | ||
|
||
type BreadcrumbArgs = { | ||
name: string; | ||
}; | ||
|
||
export default function Breadcrumb({name}: BreadcrumbArgs) { | ||
const {pathname} = useLocation(); | ||
// Remove everything after the first slash that follows a character | ||
const topLevel = pathname.replace(/(?<=.)\/.*/, ''); | ||
const goBack = useGoBack(topLevel); | ||
|
||
return ( | ||
<Link to={topLevel} onClick={goBack} className='breadcrumb'> | ||
<FontAwesomeIcon icon={faChevronLeft} /> | ||
<span>Back to Main {name}</span> | ||
</Link> | ||
); | ||
} | ||
|
||
function useGoBack(path: string) { | ||
const navigate = useNavigate(); | ||
const {state} = useLocation(); | ||
|
||
return React.useCallback( | ||
(e: React.MouseEvent<HTMLAnchorElement>) => { | ||
if (state?.from === path) { | ||
navigate(-1); | ||
} else { | ||
navigate(path, {replace: true}); | ||
} | ||
e.preventDefault(); | ||
}, | ||
[navigate, path, state?.from] | ||
); | ||
} |
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
46 changes: 46 additions & 0 deletions
46
src/app/components/explore-by-collection/explore-by-collection.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,46 @@ | ||
import React from 'react'; | ||
import {Link, useLocation} from 'react-router-dom'; | ||
import {Collection} from './types'; | ||
import './explore-by-collection.scss'; | ||
|
||
export default function ExploreCollections({ | ||
collections, | ||
analyticsNav | ||
}: { | ||
collections: Collection[]; | ||
analyticsNav: string; | ||
}) { | ||
const {pathname} = useLocation(); | ||
|
||
return ( | ||
<section id='explore-collections'> | ||
<h2>Explore collections</h2> | ||
<div className='cards' data-analytics-nav={analyticsNav}> | ||
{collections.map((c) => ( | ||
<CollectionLink collection={c} key={c.id} from={pathname} /> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
function CollectionLink({ | ||
collection, | ||
from | ||
}: { | ||
collection: Collection; | ||
from: string; | ||
}) { | ||
return ( | ||
<Link | ||
to={`./explore/collections/${encodeURIComponent(collection.name)}`} | ||
state={{from}} | ||
className='card' | ||
> | ||
<div className='centered-image'> | ||
<img src={collection.collectionImage} alt='' /> | ||
</div> | ||
<div className='name'>{collection.name}</div> | ||
</Link> | ||
); | ||
} |
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,5 @@ | ||
export type Collection = { | ||
id: string; | ||
name: string; | ||
collectionImage?: string; | ||
}; |
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
46 changes: 46 additions & 0 deletions
46
src/app/components/explore-by-subject/explore-by-subject.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,46 @@ | ||
import React from 'react'; | ||
import {Link, useLocation} from 'react-router-dom'; | ||
import {Category} from './types'; | ||
import './explore-by-subject.scss'; | ||
|
||
export default function ExploreBySubject({ | ||
categories, | ||
analyticsNav | ||
}: { | ||
categories: Category[]; | ||
analyticsNav: string; | ||
}) { | ||
const {pathname} = useLocation(); | ||
|
||
return ( | ||
<section id='explore-by-subject'> | ||
<h2>Explore by subject</h2> | ||
<div className='subject-links' data-analytics-nav={analyticsNav}> | ||
{categories.map((c) => ( | ||
<SubjectLink category={c} key={c.id} from={pathname} /> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
function SubjectLink({ | ||
category: {name, subjectIcon}, | ||
from | ||
}: { | ||
category: Category; | ||
from: string; | ||
}) { | ||
return ( | ||
<div className='card'> | ||
<Link to={`./explore/subjects/${encodeURIComponent(name)}`} state={{from}}> | ||
<div className='icon-holder'> | ||
{subjectIcon && <img src={subjectIcon} alt='' />} | ||
</div> | ||
<div className='subject-name'> | ||
{name} | ||
</div> | ||
</Link> | ||
</div> | ||
); | ||
} |
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,5 @@ | ||
export type Category = { | ||
id: string; | ||
name: string; | ||
subjectIcon?: string; | ||
}; |
File renamed without changes.
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,30 @@ | ||
import React from 'react'; | ||
import './section.scss'; | ||
|
||
type SectionArgs = React.PropsWithChildren<{ | ||
name: string; | ||
topicHeading?: string; | ||
}> & React.HTMLAttributes<HTMLDivElement>; | ||
|
||
export default function Section({name, topicHeading, children, ...divAttributes}: SectionArgs) { | ||
return ( | ||
<section {...divAttributes}> | ||
<SectionHeader head={name} subhead={topicHeading} /> | ||
{children} | ||
</section> | ||
); | ||
} | ||
|
||
type SectionHeaderArgs = { | ||
head: string; | ||
subhead?: string; | ||
} | ||
|
||
function SectionHeader({head, subhead}: SectionHeaderArgs) { | ||
return ( | ||
<h2 className="section-header"> | ||
{head} | ||
{subhead && <span className="section-subhead">{subhead}</span>} | ||
</h2> | ||
); | ||
} |
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
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
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
Oops, something went wrong.