Skip to content

Commit f6d2f1e

Browse files
authored
Merge branch 'main' into shilman/add-preact-to-frameworks
2 parents e71973a + ee165d0 commit f6d2f1e

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

apps/addon-catalog/components/addon/addon-hero.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import { StorybookIcon } from '@repo/ui';
1414
import { type Addon } from '../../types';
1515

1616
export function AddonHero({ addon }: { addon: Addon }) {
17+
const installCommand = `npm install -D ${addon.name ?? ''}`;
1718
const [state, setState] = useState(false);
1819

1920
const onClick = () => {
20-
copy(`npx install ${addon.name ?? ''}`);
21+
copy(installCommand);
2122
setState(true);
2223
setTimeout(() => {
2324
setState(false);
@@ -49,7 +50,7 @@ export function AddonHero({ addon }: { addon: Addon }) {
4950
onClick={onClick}
5051
type="button"
5152
>
52-
npm install {addon.name} <CopyIcon />
53+
{installCommand} <CopyIcon />
5354
<AnimatePresence>
5455
{state ? (
5556
<motion.div

apps/frontpage/components/docs/content.tsx

+43-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { cn } from '@repo/utils';
21
import { type FC } from 'react';
2+
import Link from 'next/link';
3+
import { cn } from '@repo/utils';
34
import { type PageDataProps } from '../../lib/get-page';
45
import { Renderers } from './renderers';
56
import { DocsFooter } from './footer/footer';
@@ -8,36 +9,56 @@ import { TableOfContent } from './table-of-content';
89
export const Content: FC<{ page: PageDataProps }> = ({ page }) => {
910
return (
1011
<>
11-
<div className="flex-1 w-full min-w-0 py-12">
12+
<div className="w-full min-w-0 flex-1 py-12">
1213
<main className="mx-auto max-w-[720px]">
1314
<h1
14-
className="relative mt-0 mb-6 text-4xl font-bold text-black transition-colors duration-200 group-hover:text-blue-500 dark:text-white"
15+
className="relative mb-6 mt-0 text-4xl font-bold text-black transition-colors duration-200 group-hover:text-blue-500 dark:text-white"
1516
data-docs-heading
1617
>
1718
{page.title ?? 'Title is missing'}
1819
</h1>
1920
{!page.hideRendererSelector && <Renderers />}
20-
{/* TODO: Bring back tabs */}
21-
{/* {page.tabs && page.tabs.length > 0 ? (
22-
<div className="flex items-center gap-8 border-b border-zinc-200">
23-
{page.tabs.map((tab) => {
24-
const isActive = tab.slug === `/docs/${slug?.join('/')}`;
25-
26-
return (
27-
<Link
28-
className={cn(
21+
{page.tabs && page.tabs.length > 0 ? (
22+
<div className="mb-8 flex items-center gap-8 border-b border-zinc-200">
23+
{page.tabs.map((tab) => {
24+
const tabTitle = tab.tab?.title ?? tab.title;
25+
const isActive = tab.pathSegment === page.path;
26+
const className = cn(
2927
'-mb-px border-b px-2 pb-2 text-sm capitalize transition-colors hover:text-blue-500',
3028
isActive && 'border-b border-blue-500 text-blue-500',
31-
)}
32-
href={tab.slug}
33-
key={tab.name}
34-
>
35-
{tab.tab?.title || tab.title}
36-
</Link>
37-
);
38-
})}
39-
</div>
40-
) : null} */}
29+
);
30+
31+
if (isActive) {
32+
return (
33+
<span className={className} key={tab.name}>
34+
{tabTitle}
35+
</span>
36+
);
37+
}
38+
39+
const relevantPathSegments = (
40+
tab.name === 'index.mdx'
41+
? tab.pathSegment.split('/').slice(-2, -1)
42+
: tab.pathSegment.split('/').slice(-2)
43+
)
44+
.join('/')
45+
.replace('.mdx', '');
46+
const href = page.isIndexPage
47+
? `./${relevantPathSegments}`
48+
: `../${relevantPathSegments}`;
49+
50+
return (
51+
<Link
52+
className={className}
53+
href={href}
54+
key={tab.name}
55+
>
56+
{tabTitle}
57+
</Link>
58+
);
59+
})}
60+
</div>
61+
) : null}
4162
<div
4263
className={cn(
4364
'[&>details]:my-6',

apps/frontpage/lib/get-docs-tree-from-path.ts

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ export const getDocsTreeFromPath = (
8484
a.sidebar?.order && b.sidebar?.order
8585
? a.sidebar.order - b.sidebar.order
8686
: 0,
87+
).sort((a, b) =>
88+
a.tab?.order && b.tab?.order
89+
? a.tab.order - b.tab.order
90+
: 0,
8791
);
8892
// TODO: Remove the index page from the tree, probably from pathSegment instead of slug
8993
// .filter((item) => {

apps/frontpage/lib/get-page.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface PageDataProps {
2323
isIndexPage: boolean;
2424
tabs: RawTreeProps[];
2525
content: ReactElement;
26+
path: string;
2627
}
2728

2829
export const getPageData = async (
@@ -109,6 +110,7 @@ export const getPageData = async (
109110
return {
110111
...frontmatter,
111112
isIndexPage: isIndexMDX || isIndexMD,
113+
path: newPath,
112114
tabs: index?.isTab ? parent : [],
113115
content,
114116
};

packages/ui/src/mdx/components/headings.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ export const H3: FC<Omit<HeadingProps, 'level'>> = (props) => {
6666
};
6767

6868
export const H4: FC<Omit<HeadingProps, 'level'>> = (props) => {
69-
return <Heading className="ui-mb-4 ui-text-xl" level={4} {...props} />;
69+
return <Heading className="ui-mb-4 ui-text-lg" level={4} {...props} />;
7070
};

packages/ui/src/mdx/themes/firefox-theme-vscode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ export const firefoxThemeLight = {
523523
{
524524
scope: "markup.inserted",
525525
settings: {
526-
foreground: "#86DE74",
526+
foreground: "#2f8800",
527527
},
528528
},
529529
{

0 commit comments

Comments
 (0)