-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Encapsulated sample page link logic into its own component, which will be necessary to prevent duplication of the sample initialization code for each sub category of samples * Test * New sidebar layout * First draft * Sketch dropdown before merging main into this branch * Dropdowns complete. Note that dropdowns can easily be removed if they are deemed unecessary for the functionality of this webpage * fix build errors * Implemented most suggested changes, will have further discussions about categorization * Moved stuffed around, added comments justifying each category * Capitalize GPGPU * Added more specific comments to gpgpu section * Cambios pequenos
- Loading branch information
1 parent
41f3e5c
commit 5424f6f
Showing
6 changed files
with
209 additions
and
60 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,8 @@ | ||
.sampleCategory { | ||
display: flex; | ||
} | ||
|
||
|
||
li.selected a { | ||
color: #ff0000; | ||
} |
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,84 @@ | ||
import styles from './SampleCategory.module.css'; | ||
|
||
import { NextRouter } from 'next/router'; | ||
import Link from 'next/link'; | ||
import { PageCategory } from '../pages/samples/[slug]'; | ||
|
||
type PageType = { | ||
[key: string]: React.ComponentType & { render: { preload: () => void } }; | ||
}; | ||
|
||
type PageComponentType = { | ||
[key: string]: React.ComponentType; | ||
}; | ||
|
||
interface SampleCategoryProps { | ||
category: PageCategory; | ||
router: NextRouter; | ||
onClickPageLink: () => void; | ||
} | ||
|
||
export const SampleCategory = ({ | ||
category, | ||
onClickPageLink, | ||
router, | ||
}: SampleCategoryProps) => { | ||
const { title, pages, sampleNames } = category; | ||
return ( | ||
<div> | ||
<div className={styles.sampleCategory}> | ||
<h3 | ||
style={{ | ||
marginTop: '5px', | ||
}} | ||
> | ||
{title} | ||
</h3> | ||
</div> | ||
{sampleNames.map((slug) => { | ||
return ( | ||
<SampleLink | ||
key={`samples/${slug}`} | ||
slug={slug} | ||
router={router} | ||
pages={pages} | ||
onClick={() => onClickPageLink()} | ||
/> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
interface SampleLinkProps { | ||
router: NextRouter; | ||
slug: string; | ||
pages: PageComponentType; | ||
onClick: () => void; | ||
} | ||
|
||
export const SampleLink = ({ | ||
router, | ||
slug, | ||
pages, | ||
onClick, | ||
}: SampleLinkProps) => { | ||
const className = | ||
router.pathname === `/samples/[slug]` && router.query['slug'] === slug | ||
? styles.selected | ||
: undefined; | ||
|
||
return ( | ||
<li | ||
key={slug} | ||
className={className} | ||
onMouseOver={() => { | ||
(pages as PageType)[slug].render.preload(); | ||
}} | ||
> | ||
<Link href={`/samples/${slug}`} onClick={() => onClick()}> | ||
{slug} | ||
</Link> | ||
</li> | ||
); | ||
}; |
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