-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2272 from bryanjenningz/make-admin-lesson-nav-gen…
…eric Make AdminLessonNav more generic
- Loading branch information
Showing
8 changed files
with
129 additions
and
163 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
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,47 @@ | ||
import Link from 'next/link' | ||
import React from 'react' | ||
import styles from '../scss/navCard.module.scss' | ||
|
||
type Tab = { | ||
text: string | ||
url: string | ||
} | ||
|
||
type NavCardProps = { | ||
tabSelected: number | ||
tabs: Tab[] | ||
} | ||
|
||
const NavCard = ({ tabSelected, tabs }: NavCardProps) => { | ||
return ( | ||
<div className={styles.navCard__tabsNav}> | ||
<div className={styles.navCard__tabsNav__nav}> | ||
{tabs.map((tab, i) => ( | ||
<NavCardItem key={i} isSelected={i === tabSelected} tab={tab} /> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
type NavCardItemProps = { | ||
isSelected: boolean | ||
tab: Tab | ||
} | ||
|
||
const NavCardItem = ({ isSelected, tab }: NavCardItemProps) => { | ||
const className = | ||
styles[ | ||
isSelected | ||
? 'navCard__tabsNav__nav__item' | ||
: 'navCard__tabsNav__nav__item--inactive' | ||
] | ||
|
||
return ( | ||
<Link href={tab.url}> | ||
<a className={`${className} nav-pills`}>{tab.text.toUpperCase()}</a> | ||
</Link> | ||
) | ||
} | ||
|
||
export default NavCard |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,28 @@ | ||
import { useRouter } from 'next/router' | ||
import * as React from 'react' | ||
import NavCard from '../../components/NavCard' | ||
|
||
export default { | ||
component: NavCard, | ||
title: 'Components/NavCard' | ||
} | ||
|
||
export const Basic = () => { | ||
const router = useRouter() | ||
const pageName = router.asPath.split('/').slice(-1)[0] | ||
const tabs = ['introduction', 'modules', 'challenges'].map(text => ({ | ||
text, | ||
url: `/admin/lessons/1/${text}` | ||
})) | ||
const tabSelected = tabs.findIndex(tab => tab.text === pageName) | ||
|
||
return <NavCard tabSelected={tabSelected} tabs={tabs} /> | ||
} | ||
|
||
const parameters = { | ||
nextRouter: { | ||
asPath: 'c0d3.com/admin/lessons/1/introduction' | ||
} | ||
} | ||
|
||
Basic.parameters = parameters |
5a78298
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
c0d3-app – ./
www.c0d3.com
c0d3-app.vercel.app
v2.c0d3.app
c0d3-app-c0d3-prod.vercel.app
c0d3-app-git-master-c0d3-prod.vercel.app