Skip to content

Commit

Permalink
Merge branch 'docs-v2' into ADAPP-16869-port-android-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sporiff authored Oct 31, 2023
2 parents 21fd1ca + d00d816 commit ba2d9ca
Show file tree
Hide file tree
Showing 20 changed files with 466 additions and 246 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"classnames": "^2.3.2",
"html-escaper": "^3.0.3",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"nanostores": "^0.9.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -42,6 +43,7 @@
},
"devDependencies": {
"@types/html-escaper": "^3.0.1",
"@types/lodash-es": "^4.17.10",
"@types/node": "^20.8.9",
"@types/react": "^18.2.32",
"@types/react-dom": "^18.2.14",
Expand Down
12 changes: 8 additions & 4 deletions src/components/Header/SidebarToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from "classnames";
import type { FC } from "react";
import { useState, useEffect } from "react";

Expand All @@ -16,7 +17,10 @@ const MenuToggle: FC = () => {
return (
<button
type="button"
className="xs:block lg:hidden top-0 mb-2 z-40 p-0"
className={classNames("xs:block lg:hidden top-0 mb-2 z-40 p-0", {
"bg-secondary": sidebarShown,
"bg-white": !sidebarShown,
})}
id="menu-toggle"
onClick={() => setSidebarShown(!sidebarShown)}
>
Expand All @@ -29,9 +33,9 @@ const MenuToggle: FC = () => {
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
Expand Down
33 changes: 33 additions & 0 deletions src/components/Icons/react/ChevronLeft.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { FC } from "react";

import type { IconProps } from "../types";

const ChevronLeft: FC<IconProps> = (props) => {
return (
<svg
width={24}
height={24}
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M14.265 19.178L7.64 12l6.626-7.178 1.47 1.356L10.36 12l5.374 5.822-1.47 1.356z"
fill="currentColor"
/>
<rect
x={23.5}
y={23.5}
width={23}
height={23}
rx={2.5}
transform="rotate(-180 23.5 23.5)"
stroke="#000"
/>
</svg>
);
};

export default ChevronLeft;
25 changes: 25 additions & 0 deletions src/components/Icons/react/ChevronRight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { FC } from "react";

import type { IconProps } from "../types";

const ChevronRight: FC<IconProps> = (props) => {
return (
<svg
width={24}
height={24}
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M9.735 4.822L16.36 12l-6.626 7.178-1.47-1.356L13.64 12 8.265 6.178l1.47-1.356z"
fill="currentColor"
/>
<rect x={0.5} y={0.5} width={23} height={23} rx={2.5} stroke="#000" />
</svg>
);
};

export default ChevronRight;
1 change: 1 addition & 0 deletions src/components/LeftSidebar/NavigationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const LeftSidebarItem: FC<{
{isOpen
? sidebarData?.children?.map((child) => (
<LeftSidebarItem
key={child.path}
currentPage={currentPage}
sidebarData={child}
level={child.level}
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageBreadcrumbs/PageBreadcrumbs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const currentPageMatch = currentPage.endsWith("/")

<div aria-label="breadcrumbs" class="mb-8">
<nav>
<ul class="flex flex-row gap-x-6">
<ul class="flex flex-row flex-wrap gap-x-6">
{
breadcrumbs.map((breadcrumb, i) => (
<li
Expand Down
17 changes: 11 additions & 6 deletions src/components/PageContent/PageContent.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import type { MarkdownHeading } from "astro";
import TableOfContents from "../RightSidebar/TableOfContents";
import RightSidebar from "@components/RightSidebar/RightSidebar.astro";
type Props = {
title: string;
Expand All @@ -12,10 +13,14 @@ const { title, headings } = Astro.props;

<article id="article" class="article-main w-full">
<section class="main-section">
<h1 class="content-title" id="overview">{title}</h1>
<nav class="block sm:hidden">
<TableOfContents client:media="(max-width: 50em)" headings={headings} />
</nav>
<slot />
<h1 class="text-heading-1 font-bold leading-[1] mb-4" id="overview">
{title}
</h1>
<aside title="Table of Contents">
<RightSidebar headings={headings} title={title} />
</aside>
<div class="article-content" id="article-content">
<slot />
</div>
</section>
</article>
10 changes: 4 additions & 6 deletions src/components/RightSidebar/RightSidebar.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
---
import type { MarkdownHeading } from "astro";
import TableOfContents from "./TableOfContents";
type Props = {
headings: MarkdownHeading[];
title: string;
};
const { headings } = Astro.props;
const { headings, title } = Astro.props;
---

<nav class="w-full sticky top-10" aria-labelledby="grid-right">
<div class="h-full p-0 overflow-auto xs:hidden lg:block">
<TableOfContents client:visible headings={headings} />
</div>
</nav>
<TableOfContents client:only="react" headings={headings} title={title} />
118 changes: 0 additions & 118 deletions src/components/RightSidebar/TableOfContents.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/RightSidebar/TableOfContents/CollapsedTOC.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { FC } from "react";

import ChevronLeft from "@components/Icons/react/ChevronLeft";

interface CollapsedTOCProps {
setIsOpened: (value: boolean) => void;
}

const CollapsedTOC: FC<CollapsedTOCProps> = ({ setIsOpened }) => {
return (
<div className="xs:hidden lg:fixed top-0 bottom-0 md:right-0 xxl:left-0 mt-32 xxl:ml-[calc(100vw-2rem-(100vw-100rem)/2)] items-start w-8 sm:hidden lg:flex z-10 border-[1px] border-t rounded-tl-lg border-bluish-grey">
<button
onClick={() => setIsOpened(true)}
className="toc-state-button absolute rounded-md mt-8 -ml-4 bg-white z-50 w-6 h-6"
>
<ChevronLeft />
</button>
</div>
);
};

export default CollapsedTOC;
39 changes: 39 additions & 0 deletions src/components/RightSidebar/TableOfContents/TOCMobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { MarkdownHeading } from "astro";
import type { FC } from "react";
import { unescape } from "html-escaper";

import "../right-sidebar.css";

interface TableOfContentsMobileProps {
onThisPageID: string;
toc: React.RefObject<HTMLUListElement>;
headingsLocal: MarkdownHeading[];
}

const TableOfContentsMobile: FC<TableOfContentsMobileProps> = ({
onThisPageID,
toc,
headingsLocal,
}) => {
return (
<div className="xs:block lg:hidden border-[1px] p-2 my-4">
<h2 id={onThisPageID} className="heading">
On this page
</h2>
<ul ref={toc} className="pl-4">
{headingsLocal
.filter(({ depth }) => depth > 1 && depth < 4)
.map((heading) => (
<li
key={heading.slug}
className={`header-link before:content-none depth-${heading.depth}`}
>
<a href={`#${heading.slug}`}>{unescape(heading.text)}</a>
</li>
))}
</ul>
</div>
);
};

export default TableOfContentsMobile;
Loading

0 comments on commit ba2d9ca

Please sign in to comment.