Skip to content

Commit 468a280

Browse files
committed
fixup! fixup! fixup! feat: Add slots to add tab links and add slots for plugin routes
1 parent 076d750 commit 468a280

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

src/course-tabs/CourseTabLink.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import classNames from 'classnames';
2+
import React from 'react';
3+
4+
interface CourseTabLinkProps {
5+
slug: string;
6+
activeTabSlug?: string;
7+
url: string;
8+
title: string;
9+
}
10+
11+
export const CourseTabLink = ({
12+
slug, activeTabSlug, url, title,
13+
}:CourseTabLinkProps) => (
14+
<a
15+
href={url}
16+
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
17+
>
18+
{title}
19+
</a>
20+
);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { CourseTabLink } from '@src/course-tabs/CourseTabLink';
2+
import React from 'react';
3+
4+
interface CourseTabLinkListProps {
5+
tabs: Array<{
6+
title: string;
7+
slug: string;
8+
url: string;
9+
}>,
10+
activeTabSlug?: string;
11+
}
12+
13+
export const CourseTabLinksList = ({ tabs, activeTabSlug }:CourseTabLinkListProps) => (
14+
<>
15+
{tabs.map(({ url, title, slug }) => (
16+
<CourseTabLink
17+
key={slug}
18+
url={url}
19+
slug={slug}
20+
title={title}
21+
activeTabSlug={activeTabSlug}
22+
/>
23+
))}
24+
</>
25+
);
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PluginSlot } from '@openedx/frontend-plugin-framework';
2-
import classNames from 'classnames';
2+
import { CourseTabLinksList } from '@src/course-tabs/CourseTabLinksList';
33
import React from 'react';
44

55
type CourseTabList = Array<{
@@ -8,16 +8,14 @@ type CourseTabList = Array<{
88
url: string;
99
}>;
1010

11-
export const CourseTabLinksSlot = ({ tabs, activeTabSlug }: { tabs: CourseTabList, activeTabSlug?: string }) => (
12-
<PluginSlot id="org.openedx.frontend.learning.course_tab_links.v1" pluginProps={{ activeTabSlug }}>
13-
{tabs.map(({ url, title, slug }) => (
14-
<a
15-
key={slug}
16-
className={classNames('nav-item flex-shrink-0 nav-link', { active: slug === activeTabSlug })}
17-
href={url}
18-
>
19-
{title}
20-
</a>
21-
))}
11+
export const CourseTabLinksSlot = ({ tabs, activeTabSlug }: {
12+
tabs: CourseTabList,
13+
activeTabSlug?: string
14+
}) => (
15+
<PluginSlot
16+
id="org.openedx.frontend.learning.course_tab_links.v1"
17+
pluginProps={{ activeTabSlug }}
18+
>
19+
<CourseTabLinksList tabs={tabs} activeTabSlug={activeTabSlug} />
2220
</PluginSlot>
2321
);

0 commit comments

Comments
 (0)