diff --git a/__tests__/__snapshots__/storyshots.test.js.snap b/__tests__/__snapshots__/storyshots.test.js.snap
index 56c73e1ae..bc233d808 100644
--- a/__tests__/__snapshots__/storyshots.test.js.snap
+++ b/__tests__/__snapshots__/storyshots.test.js.snap
@@ -866,46 +866,6 @@ Array [
]
`;
-exports[`Storyshots Components/AdminLessonNav Basic 1`] = `
-
-`;
-
exports[`Storyshots Components/AdminLessonSideNav Basic 1`] = `
`;
+exports[`Storyshots Components/NavCard Basic 1`] = `
+
+`;
+
exports[`Storyshots Components/NavLink Active Link 1`] = `
Array [
{
await act(() => new Promise(res => setTimeout(res, 0)))
expect(screen.getByText('MODULES').className).not.toEqual(
- 'lessons_tabsNav__nav__item'
+ 'navCard__tabsNav__nav__item'
)
})
})
diff --git a/components/NavCard.tsx b/components/NavCard.tsx
new file mode 100644
index 000000000..de01356c8
--- /dev/null
+++ b/components/NavCard.tsx
@@ -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 (
+
+
+ {tabs.map((tab, i) => (
+
+ ))}
+
+
+ )
+}
+
+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 (
+
+ {tab.text.toUpperCase()}
+
+ )
+}
+
+export default NavCard
diff --git a/components/admin/lessons/AdminLessonSideNavLayout.tsx b/components/admin/lessons/AdminLessonSideNavLayout.tsx
deleted file mode 100644
index 3827fe4cb..000000000
--- a/components/admin/lessons/AdminLessonSideNavLayout.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React, { FunctionComponent } from 'react'
-import styles from '../../../scss/adminLessonNav.module.scss'
-
-type Tab = { tabName: string; urlPageName: string }
-
-type Props = {
- tabs: Tab[]
- Component: FunctionComponent<{ tab: Tab }>
-}
-
-const AdminLessonNav: React.FC
= ({ tabs, Component }: Props) => {
- return (
-
-
-
- {tabs.map((tab, i) => (
-
- ))}
-
-
-
- )
-}
-
-export default AdminLessonNav
diff --git a/pages/admin/lessons/[lessonSlug]/[pageName]/index.tsx b/pages/admin/lessons/[lessonSlug]/[pageName]/index.tsx
index ed7b7283f..1a1bd9001 100644
--- a/pages/admin/lessons/[lessonSlug]/[pageName]/index.tsx
+++ b/pages/admin/lessons/[lessonSlug]/[pageName]/index.tsx
@@ -1,18 +1,15 @@
import { gql, useQuery } from '@apollo/client'
import { GetAppProps, withGetApp } from '../../../../../graphql'
-import { toUpper } from 'lodash'
import React, { useMemo, useState } from 'react'
-import AdminLessonNav from '../../../../../components/admin/lessons/AdminLessonSideNavLayout'
import AdminLessonSideNav from '../../../../../components/admin/lessons/AdminLessonSideNav'
import AdminLessonInputs from '../../../../../components/admin/lessons/AdminLessonInputs'
import { Props } from '../../../../../components/admin/lessons/AdminLessonInputs/AdminLessonInputs'
import Breadcrumbs from '../../../../../components/Breadcrumbs'
import styles from '../../../../../scss/modules.module.scss'
-import navStyles from '../../../../../scss/adminLessonNav.module.scss'
import { AdminLayout } from '../../../../../components/admin/AdminLayout'
import { useRouter } from 'next/router'
-import Link from 'next/link'
import { compose, filter, get, sortBy } from 'lodash/fp'
+import NavCard from '../../../../../components/NavCard'
const MAIN_PATH = '/admin/lessons'
@@ -114,25 +111,13 @@ const Lessons = ({ data }: GetAppProps) => {
return sortModules(modulesData)
}, [lesson.id, get('modules', modulesData)])
- const LessonNav = ({
- tab
- }: {
- tab: { tabName: string; urlPageName: string }
- }) => {
- const isSelected = tab.urlPageName === pageName
- const className =
- navStyles[
- isSelected
- ? 'lessons_tabsNav__nav__item'
- : 'lessons_tabsNav__nav__item--inactive'
- ]
-
- return (
-
- {toUpper(tab.tabName)}
-
- )
- }
+ const tabs = [
+ {
+ text: 'modules',
+ url: `${MAIN_PATH}/${lesson.slug}/modules`
+ }
+ ]
+ const tabSelected = tabs.findIndex(tab => tab.text === pageName)
return (
@@ -148,15 +133,7 @@ const Lessons = ({ data }: GetAppProps) => {
/>
{
- const router = useRouter()
-
- const SideNavComponent = ({
- tab
- }: {
- tab: { tabName: string; urlPageName: string }
- }) => {
- const isSelected = router.asPath.split('/').slice(-1)[0] === tab.urlPageName
-
- const className =
- styles[
- isSelected
- ? 'lessons_tabsNav__nav__item'
- : 'lessons_tabsNav__nav__item--inactive'
- ]
-
- return (
-
- {toUpper(tab.tabName)}
-
- )
- }
-
- return (
-
- )
-}
-
-const parameters = {
- nextRouter: {
- asPath: 'c0d3.com/admin/lessons/1/introduction'
- }
-}
-
-Basic.parameters = parameters
diff --git a/stories/components/NavCard.stories.tsx b/stories/components/NavCard.stories.tsx
new file mode 100644
index 000000000..62b96ef9a
--- /dev/null
+++ b/stories/components/NavCard.stories.tsx
@@ -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
+}
+
+const parameters = {
+ nextRouter: {
+ asPath: 'c0d3.com/admin/lessons/1/introduction'
+ }
+}
+
+Basic.parameters = parameters