Make docs pages responsive
Browse files- docs/public/burger.svg +1 -0
- docs/public/cross.svg +1 -0
- docs/src/components/DocsHeader.astro +0 -13
- docs/src/components/DocsHeader.tsx +43 -0
- docs/src/components/Sidebar.astro +2 -11
- docs/src/layouts/DocsLayout.astro +6 -2
- docs/src/lib/guide.ts +14 -0
docs/public/burger.svg
ADDED
|
docs/public/cross.svg
ADDED
|
docs/src/components/DocsHeader.astro
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
---
|
2 |
-
import { getFormattedStars } from "../lib/github";
|
3 |
-
|
4 |
-
const starCount = await getFormattedStars('kamranahmedse/driver.js');
|
5 |
-
---
|
6 |
-
<div class="border-b flex items-center justify-between" docs-header>
|
7 |
-
<div class="w-[200px] lg:w-[300px] text-right flex justify-end">
|
8 |
-
|
9 |
-
</div>
|
10 |
-
<div class="flex items-center pr-12">
|
11 |
-
|
12 |
-
</div>
|
13 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/src/components/DocsHeader.tsx
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useState } from "react";
|
2 |
+
import type { CollectionEntry } from "astro:content";
|
3 |
+
|
4 |
+
type DocsHeaderProps = {
|
5 |
+
groupedGuides: Record<string, CollectionEntry<"guides">[]>;
|
6 |
+
};
|
7 |
+
|
8 |
+
export function DocsHeader(props: DocsHeaderProps) {
|
9 |
+
const { groupedGuides } = props;
|
10 |
+
const [isActive, setIsActive] = useState(false);
|
11 |
+
|
12 |
+
return (
|
13 |
+
<>
|
14 |
+
<div className="border-b flex items-center justify-between" docs-header>
|
15 |
+
<div className="text-right flex justify-end py-3 px-6">
|
16 |
+
<a href="/" className="flex items-center justify-end text-xl font-bold">
|
17 |
+
<img src="/driver-head.svg" alt="Astro" className="w-10 h-10 mr-2" />
|
18 |
+
driver.js
|
19 |
+
</a>
|
20 |
+
</div>
|
21 |
+
<div className="flex items-center pr-12">
|
22 |
+
<button onClick={() => setIsActive(!isActive)} className="p-[12px] -mr-[12px] hover:bg-gray-100 rounded-md">
|
23 |
+
<img src={isActive ? "/cross.svg" : "/burger.svg"} alt="menu" className="w-[14px] h-[14px]" />
|
24 |
+
</button>
|
25 |
+
</div>
|
26 |
+
</div>
|
27 |
+
<div className={`bg-gray-50 flex flex-col gap-5 px-6 py-6 border-b ${isActive ? "block" : "hidden"}`}>
|
28 |
+
{Object.entries(groupedGuides).map(([category, guides]) => (
|
29 |
+
<div key={category} className="flex flex-col gap-2">
|
30 |
+
<div className="font-bold text-gray-900 text-sm uppercase">{category}</div>
|
31 |
+
<div className="flex flex-col">
|
32 |
+
{guides.map((guide) => (
|
33 |
+
<a key={guide.slug} href={`/docs/${guide.slug}`} className="text-gray-500 hover:text-gray-900 py-1">
|
34 |
+
{guide.data.title}
|
35 |
+
</a>
|
36 |
+
))}
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
))}
|
40 |
+
</div>
|
41 |
+
</>
|
42 |
+
);
|
43 |
+
}
|
docs/src/components/Sidebar.astro
CHANGED
@@ -1,24 +1,15 @@
|
|
1 |
---
|
2 |
import { getCollection, getEntry } from "astro:content";
|
3 |
import { getFormattedStars } from "../lib/github";
|
|
|
4 |
|
5 |
export interface Props {
|
6 |
activePath: string;
|
7 |
}
|
8 |
|
9 |
-
const
|
10 |
-
const sortedGuides = allGuides.sort((a, b) => a.data.sort - b.data.sort);
|
11 |
-
const groupedGuides = sortedGuides.reduce((acc, curr) => {
|
12 |
-
const { groupTitle } = curr.data;
|
13 |
-
acc[groupTitle] = acc[groupTitle] || [];
|
14 |
-
acc[groupTitle].push(curr);
|
15 |
-
|
16 |
-
return acc;
|
17 |
-
}, {});
|
18 |
|
19 |
const { activePath } = Astro.props;
|
20 |
-
|
21 |
-
const starCount = getFormattedStars("kamranahmedse/driver.js");
|
22 |
---
|
23 |
<div class="hidden md:block w-[200px] lg:w-[350px] border-r border-gray-200 text-right min-h-screen flex-shrink-0">
|
24 |
<div class="relative sh:sticky top-0">
|
|
|
1 |
---
|
2 |
import { getCollection, getEntry } from "astro:content";
|
3 |
import { getFormattedStars } from "../lib/github";
|
4 |
+
import { getAllGuides } from "../lib/guide";
|
5 |
|
6 |
export interface Props {
|
7 |
activePath: string;
|
8 |
}
|
9 |
|
10 |
+
const groupedGuides = getAllGuides();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
const { activePath } = Astro.props;
|
|
|
|
|
13 |
---
|
14 |
<div class="hidden md:block w-[200px] lg:w-[350px] border-r border-gray-200 text-right min-h-screen flex-shrink-0">
|
15 |
<div class="relative sh:sticky top-0">
|
docs/src/layouts/DocsLayout.astro
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
---
|
2 |
import BaseLayout from "./BaseLayout.astro";
|
3 |
-
import DocsHeader from "../components/DocsHeader
|
4 |
import Container from "../components/Container.astro";
|
5 |
import { getFormattedStars } from "../lib/github";
|
6 |
import Sidebar from "../components/Sidebar.astro";
|
7 |
import type { CollectionEntry } from "astro:content";
|
|
|
8 |
|
9 |
type GuideType = CollectionEntry<"guides">;
|
10 |
|
@@ -12,15 +13,18 @@ export interface Props {
|
|
12 |
guide: GuideType;
|
13 |
}
|
14 |
|
|
|
|
|
15 |
const { guide } = Astro.props;
|
16 |
const { groupTitle, sort, title } = guide.data;
|
17 |
---
|
18 |
|
19 |
<BaseLayout title={title}>
|
|
|
20 |
<div class="flex">
|
21 |
<Sidebar />
|
22 |
<div
|
23 |
-
class="min-w-0 max-w-[800px] py-
|
24 |
<slot />
|
25 |
</div>
|
26 |
</div>
|
|
|
1 |
---
|
2 |
import BaseLayout from "./BaseLayout.astro";
|
3 |
+
import { DocsHeader } from "../components/DocsHeader";
|
4 |
import Container from "../components/Container.astro";
|
5 |
import { getFormattedStars } from "../lib/github";
|
6 |
import Sidebar from "../components/Sidebar.astro";
|
7 |
import type { CollectionEntry } from "astro:content";
|
8 |
+
import { getAllGuides } from "../lib/guide";
|
9 |
|
10 |
type GuideType = CollectionEntry<"guides">;
|
11 |
|
|
|
13 |
guide: GuideType;
|
14 |
}
|
15 |
|
16 |
+
const groupedGuides = await getAllGuides();
|
17 |
+
|
18 |
const { guide } = Astro.props;
|
19 |
const { groupTitle, sort, title } = guide.data;
|
20 |
---
|
21 |
|
22 |
<BaseLayout title={title}>
|
23 |
+
<DocsHeader groupedGuides={groupedGuides} client:load />
|
24 |
<div class="flex">
|
25 |
<Sidebar />
|
26 |
<div
|
27 |
+
class="min-w-0 max-w-[800px] py-6 md:py-12 prose px-6 md:px-14 prose-base md:proxe-xl mb-24 prose-blockquote:font-normal prose-blockquote:not-italic prose-blockquote:text-gray-500 prose-p:before:content-['']">
|
28 |
<slot />
|
29 |
</div>
|
30 |
</div>
|
docs/src/lib/guide.ts
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { CollectionEntry, getCollection } from "astro:content";
|
2 |
+
|
3 |
+
export async function getAllGuides(): Promise<Record<string, CollectionEntry<"guides">[]>> {
|
4 |
+
const allGuides: CollectionEntry<"guides">[] = await getCollection("guides");
|
5 |
+
const sortedGuides = allGuides.sort((a, b) => a.data.sort - b.data.sort);
|
6 |
+
return sortedGuides.reduce((acc: Record<string, CollectionEntry<"guides">[]>, curr: CollectionEntry<"guides">) => {
|
7 |
+
const { groupTitle } = curr.data;
|
8 |
+
|
9 |
+
acc[groupTitle] = acc[groupTitle] || [];
|
10 |
+
acc[groupTitle].push(curr);
|
11 |
+
|
12 |
+
return acc;
|
13 |
+
}, {});
|
14 |
+
}
|