Skip to content

Commit 3c3c6c5

Browse files
committed
chore: cleanup
1 parent a788555 commit 3c3c6c5

11 files changed

Lines changed: 106 additions & 117 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"solid-jsx": "^0.9.1",
3636
"solid-markdown": "^1.2.0",
3737
"solid-transition-group": "^0.0.11",
38-
"typedoc-json-parser": "^7.0.1"
38+
"typedoc-json-parser": "^7.1.0"
3939
},
4040
"devDependencies": {
4141
"@commitlint/cli": "^17.1.2",
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,28 @@ import { Link } from '@solidjs/router';
22
import { Accessor, Show } from 'solid-js';
33
import type { DocsPageParams, ExtraClassMethod } from '../types';
44

5-
export const DocsSideBar = ({
6-
scrollValue,
5+
export const DocsContents = ({
76
params,
8-
allMethods,
9-
onUpdateScroll
7+
allMethods
108
}: {
11-
scrollValue: Accessor<number>;
129
params: Accessor<DocsPageParams>;
1310
allMethods: Accessor<ExtraClassMethod[]>;
14-
onUpdateScroll: (value: boolean) => void;
1511
}) => {
1612
return (
1713
<div
18-
class='hidden sm:block sm:w-80 max-h-[75vh] will-change-transform'
19-
style={{ transform: `translateY(${scrollValue() > 20 ? scrollValue() - 20 : 0}px)` }}
14+
class='hidden sm:block sm:w-80 max-h-[75vh]'
2015
>
2116
<Show when={params().type.length > 0}>
2217
<h1 class='text-primary font-bold text-xl mb-2 font-ledger'>Contents</h1>
23-
<div class='overflow-y-scroll h-full' id='sidebar'>
18+
<div class='overflow-y-scroll h-full'>
2419
<Show when={params().type === 'methods'}>
2520
{allMethods().map((method) => (
2621
<div class='pt-2 pr-4'>
2722
<div
28-
class={`transition px-2 border-l ${
29-
location.hash.slice(1) === `${method.from.name}-${method.name}` ? 'border-primary' : 'dark:border-zinc-800'
30-
}`}
23+
class={`transition px-2 border-l ${location.hash.slice(1) === `${method.from.name}-${method.name}` ? 'border-primary' : 'dark:border-zinc-800'
24+
}`}
3125
>
3226
<Link
33-
onClick={() => onUpdateScroll(true)}
3427
class='dark:text-gray-300 break-words'
3528
href={`/docs/${params().pkg}/${params().type}#${method.from.name}-${method.name}`}
3629
>

src/components/docs/Navigation.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FiChevronDown } from 'solid-icons/fi';
33
import { createMemo, Show } from 'solid-js';
44
import type { NavigationProps } from '../types';
55

6-
export const NavigationDocs = ({ params, onSetPackage, onChoosePackage, folders, scrollValue, selectedPkg, allMethods, docs }: NavigationProps) => {
6+
export const NavigationDocs = ({ params, onSetPackage, onChoosePackage, folders, selectedPkg, allMethods, docs }: NavigationProps) => {
77
const navigateTo = useNavigate();
88

99
const maxH = createMemo(() => {
@@ -29,18 +29,14 @@ export const NavigationDocs = ({ params, onSetPackage, onChoosePackage, folders,
2929
return (
3030
<div
3131
class='sm:w-72 sm:max-h-[75vh] sm:overflow-y-scroll will-change-transform'
32-
style={{
33-
transform: `translateY(${scrollValue() > 20 ? scrollValue() - 20 : 0}px)`
34-
}}
3532
>
3633
<h1 class='text-primary font-bold text-xl font-ledger'>Documentation</h1>
3734

3835
<div>
3936
{docs.map((category) => (
4037
<div
41-
class={`transition my-2 rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${
42-
params().category === category.category ? 'dark:bg-zinc-800 bg-zinc-100' : ''
43-
}`}
38+
class={`transition my-2 rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${params().category === category.category ? 'dark:bg-zinc-800 bg-zinc-100' : ''
39+
}`}
4440
>
4541
<button
4642
onClick={() => {
@@ -87,9 +83,8 @@ export const NavigationDocs = ({ params, onSetPackage, onChoosePackage, folders,
8783
<div class={folder.packages.length > 1 ? 'pl-4' : ''}>
8884
{folder.packages.map((pkg) => (
8985
<div
90-
class={`transition my-2 rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${
91-
params().pkg === pkg.name ? 'dark:bg-zinc-800 bg-zinc-100' : ''
92-
}`}
86+
class={`transition my-2 rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${params().pkg === pkg.name ? 'dark:bg-zinc-800 bg-zinc-100' : ''
87+
}`}
9388
>
9489
<button
9590
onClick={() => {

src/components/docs/packages/classes.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Show } from 'solid-js';
33
import { md } from '../../../utils/mdit';
44
import type { ClassesProps } from '../../types';
55

6-
export const DocsClasses = ({ onUpdateScroll, selectedPkg, params }: ClassesProps) => {
6+
export const DocsClasses = ({ selectedPkg, params }: ClassesProps) => {
77
return (
88
<div class='pt-4 sm:pt-0 sm:px-10'>
99
<h1 class='dark:text-white text-4xl font-ledger'>{params().type[0].toUpperCase() + params().type.slice(1)}</h1>
@@ -13,7 +13,6 @@ export const DocsClasses = ({ onUpdateScroll, selectedPkg, params }: ClassesProp
1313
<div class='my-4'>
1414
<div>
1515
<Link
16-
onClick={() => onUpdateScroll(true)}
1716
class='hover:opacity-70 transition'
1817
href={`/docs/${params().pkg}/${params().type}#${cls.name}`}
1918
>

src/components/docs/packages/enums.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Show } from 'solid-js';
33
import { md } from '../../../utils/mdit';
44
import type { EnumsProps } from '../../types';
55

6-
export const DocsEnums = ({ selectedPkg, onUpdateScroll, params }: EnumsProps) => {
6+
export const DocsEnums = ({ selectedPkg, params }: EnumsProps) => {
77
return (
88
<div class='pt-4 sm:pt-0 sm:px-10'>
99
<h1 class='dark:text-white text-4xl font-ledger'>{params().type[0].toUpperCase() + params().type.slice(1)}</h1>
@@ -13,7 +13,6 @@ export const DocsEnums = ({ selectedPkg, onUpdateScroll, params }: EnumsProps) =
1313
<div class='my-4'>
1414
<div>
1515
<Link
16-
onClick={() => onUpdateScroll(true)}
1716
class='hover:opacity-70 transition'
1817
href={`/docs/${params().pkg}/${params().type}#${enu.name}`}
1918
>

src/components/docs/packages/interfaces.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Show } from 'solid-js';
33
import { md } from '../../../utils/mdit';
44
import type { InterfacesProps } from '../../types';
55

6-
export const DocsInterfaces = ({ selectedPkg, onUpdateScroll, params }: InterfacesProps) => {
6+
export const DocsInterfaces = ({ selectedPkg, params }: InterfacesProps) => {
77
return (
88
<div class='pt-4 sm:pt-0 sm:px-10'>
99
<h1 class='dark:text-white text-4xl font-ledger'>{params().type[0].toUpperCase() + params().type.slice(1)}</h1>
@@ -13,7 +13,6 @@ export const DocsInterfaces = ({ selectedPkg, onUpdateScroll, params }: Interfac
1313
<div class='my-4'>
1414
<div>
1515
<Link
16-
onClick={() => onUpdateScroll(true)}
1716
class='hover:opacity-70 transition'
1817
href={`/docs/${params().pkg}/${params().type}#${intf.name}`}
1918
>

src/components/docs/packages/methods.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Link } from '@solidjs/router';
22
import { Show } from 'solid-js';
3+
import { ReferenceTypeParser } from 'typedoc-json-parser';
34
import { md } from '../../../utils/mdit';
45
import type { MethodsProps } from '../../types';
56

6-
export const DocsMethods = ({ params, allMethods, selectedPkg, onUpdateScroll }: MethodsProps) => {
7+
export const DocsMethods = ({ params, allMethods, selectedPkg }: MethodsProps) => {
78
return (
89
<div class='pt-4 sm:pt-0 sm:px-5'>
910
<h1 class='dark:text-white text-4xl font-ledger'>{params().type[0].toUpperCase() + params().type.slice(1)}</h1>
@@ -14,11 +15,10 @@ export const DocsMethods = ({ params, allMethods, selectedPkg, onUpdateScroll }:
1415
{method.signatures.map((sig) => (
1516
<div>
1617
<Link
17-
onClick={() => onUpdateScroll(true)}
1818
class='hover:opacity-70 transition'
1919
href={`/docs/${params().pkg}/${params().type}#${method.from.name}-${method.name}`}
2020
>
21-
<h1 class='sm:text-lg md:text-2xl dark:text-white break-words'>
21+
<h1 class='sm:text-lg md:text-2xl dark:text-white break-all'>
2222
<code>
2323
<span class='text-primary'>{`${method.accessibility} `}</span>
2424
{method.from.name}.{sig.name}
@@ -49,7 +49,20 @@ export const DocsMethods = ({ params, allMethods, selectedPkg, onUpdateScroll }:
4949
<th scope='row' class='py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white'>
5050
{param.name}
5151
</th>
52-
<td class='py-4 px-6'>{param.type.toString()}</td>
52+
<td class='py-4 px-6'>
53+
{/* {param.type instanceof ReferenceTypeParser ? 'h' : param.type.constructor.name + JSON.stringify(param)} */}
54+
{/* <Show when={param.}>
55+
</Show> */}
56+
<Show when={param.type instanceof ReferenceTypeParser && (param.type.packageName?.split('joshdb').length || 0) > 1}
57+
fallback={param.type.toString()}>
58+
<Link
59+
class='hover:opacity-70 transition text-primary'
60+
href={`/docs/${(param.type as ReferenceTypeParser).packageName?.split("/")[1]}/search?id=${(param.type as ReferenceTypeParser).id}`}
61+
>
62+
{(param.type as ReferenceTypeParser).name}
63+
</Link>
64+
</Show>
65+
</td>
5366
</tr>
5467
))}
5568
</tbody>

src/components/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ export interface ExtraClassMethod extends ClassMethodParser {
1414

1515
type selectedPkg = Accessor<ProjectParser | undefined>;
1616
type params = Accessor<DocsPageParams>;
17-
type onUpdateScroll = (value: boolean) => void;
1817

1918
export interface ClassesProps {
2019
selectedPkg: selectedPkg;
2120
params: params;
22-
onUpdateScroll: onUpdateScroll;
2321
}
2422
export interface InterfacesProps {
2523
selectedPkg: selectedPkg;
26-
onUpdateScroll: onUpdateScroll;
2724
params: params;
2825
}
2926
export interface EnumsProps {
3027
selectedPkg: selectedPkg;
31-
onUpdateScroll: onUpdateScroll;
3228
params: params;
3329
}
3430
export interface MethodsProps {
3531
params: params;
3632
allMethods: Accessor<ExtraClassMethod[]>;
3733
selectedPkg: selectedPkg;
38-
onUpdateScroll: onUpdateScroll;
3934
}
4035
export interface ReadmeProps {
4136
selectedPkg: selectedPkg;
@@ -59,7 +54,6 @@ export interface NavigationProps {
5954
component: JSX.Element;
6055
}[];
6156
}[];
62-
scrollValue: Accessor<number>;
6357
onSetPackage: (pkg?: string) => void;
6458
onChoosePackage: (pkg: string) => void;
6559
}

src/pages/Docs.tsx

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Title } from '@solidjs/meta';
22
import { useLocation, useNavigate, useParams } from '@solidjs/router';
3-
import { createEffect, createMemo, createSignal, onCleanup, Show } from 'solid-js';
3+
import { createEffect, createMemo, createSignal, Show } from 'solid-js';
44
import { ProjectParser } from 'typedoc-json-parser';
5+
import { DocsContents } from '../components/docs/Contents';
56
import { DocsLoading } from '../components/docs/Loading';
67
import { NavigationDocs } from '../components/docs/Navigation';
78
import { DocsClasses, DocsEnums, DocsInterfaces, DocsMethods, DocsReadme } from '../components/docs/packages';
8-
import { DocsSideBar } from '../components/docs/SideBar';
99
import type { ExtraClassMethod } from '../components/types';
1010
import DevelopmentIntro from '../docs/development/intro.mdx';
1111
import WelcomFaq from '../docs/welcome/faq.mdx';
@@ -28,36 +28,6 @@ const Docs = () => {
2828

2929
const location = useLocation();
3030
const [selectedPkg, setPackage] = createSignal<ProjectParser>();
31-
const [scrollValue, setScroll] = createSignal(window.innerWidth < 640 ? 0 : window.scrollY);
32-
const updateScroll = (forced = false, smooth = false) => {
33-
if (forced) {
34-
setTimeout(() => {
35-
updateScroll(false, true);
36-
}, 50);
37-
38-
return;
39-
}
40-
41-
setScroll(window.scrollY);
42-
43-
const sideBar = document.getElementById('sidebar');
44-
45-
if (sideBar) {
46-
const perc = scrollValue() / document.body.scrollHeight;
47-
const max = sideBar.scrollHeight - sideBar.clientHeight;
48-
49-
sideBar.scrollTo({ top: perc * max, behavior: smooth ? 'smooth' : 'auto' });
50-
}
51-
};
52-
53-
const ev = () => updateScroll();
54-
55-
if (window.innerWidth > 640) window.addEventListener('scroll', ev, { passive: true });
56-
57-
onCleanup(() => {
58-
window.removeEventListener('scroll', ev);
59-
});
60-
6131
const choosePackage = async (name: string) => {
6232
if (pkgs.loading) {
6333
setTimeout(() => {
@@ -69,10 +39,10 @@ const Docs = () => {
6939

7040
const found = pkgs().find((x) => x.name === name);
7141
const stored = localStorage.getItem(`docs-${name}`);
72-
let json: ProjectParser.JSON | undefined;
42+
let json: ProjectParser.Json | undefined;
7343

7444
if (stored) {
75-
const parsed: { docs: ProjectParser.JSON; date: Date } = JSON.parse(stored);
45+
const parsed: { docs: ProjectParser.Json; date: Date } = JSON.parse(stored);
7646

7747
if (new Date().getTime() - new Date(parsed.date).getTime() < 1000 * 60 * 10) {
7848
json = parsed.docs;
@@ -92,6 +62,10 @@ const Docs = () => {
9262
if (location.hash) {
9363
document.getElementById(location.hash.slice(1))?.scrollIntoView();
9464
}
65+
66+
if (params().type === 'search') {
67+
const found = selectedPkg()!.find(parseInt(location.query.id, 10));
68+
}
9569
}
9670
};
9771

@@ -188,7 +162,6 @@ const Docs = () => {
188162
onChoosePackage={choosePackage}
189163
onSetPackage={setPackage}
190164
params={params}
191-
scrollValue={scrollValue}
192165
/>
193166
<div class='w-full overflow-x-scroll'>
194167
<div>
@@ -200,16 +173,16 @@ const Docs = () => {
200173
<DocsReadme selectedPkg={selectedPkg} />
201174
</Show>
202175
<Show when={params().type === 'methods'}>
203-
<DocsMethods params={params} onUpdateScroll={updateScroll} allMethods={allMethods} selectedPkg={selectedPkg} />
176+
<DocsMethods params={params} allMethods={allMethods} selectedPkg={selectedPkg} />
204177
</Show>
205178
<Show when={params().type === 'interfaces'}>
206-
<DocsInterfaces params={params} onUpdateScroll={updateScroll} selectedPkg={selectedPkg} />
179+
<DocsInterfaces params={params} selectedPkg={selectedPkg} />
207180
</Show>
208181
<Show when={params().type === 'classes'}>
209-
<DocsClasses params={params} onUpdateScroll={updateScroll} selectedPkg={selectedPkg} />
182+
<DocsClasses params={params} selectedPkg={selectedPkg} />
210183
</Show>
211184
<Show when={params().type === 'enums'}>
212-
<DocsEnums params={params} onUpdateScroll={updateScroll} selectedPkg={selectedPkg} />
185+
<DocsEnums params={params} selectedPkg={selectedPkg} />
213186
</Show>
214187
</Show>
215188
<Show when={params().category}>
@@ -231,7 +204,7 @@ const Docs = () => {
231204
</Show>
232205
</div>
233206
</div>
234-
<DocsSideBar params={params} onUpdateScroll={updateScroll} allMethods={allMethods} scrollValue={scrollValue} />
207+
<DocsContents params={params} allMethods={allMethods} />
235208
</Show>
236209
</div>
237210
);

src/pages/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ await josh.set("foo", "bar");\n\`\`\``);
6969
way to manage your data.
7070
</p>
7171
<div class='space-x-2'>
72-
<Link href='/docs' class='bg-white shadow-lg dark:shadow px-6 py-4 rounded-lg inline-block bg-primary text-white'>
72+
<Link href='/docs' class='shadow-lg dark:shadow px-6 py-4 rounded-lg inline-block bg-primary text-white'>
7373
<div class='flex'>
7474
<FiBook class='mt-[0.2rem] mr-2'></FiBook> Documentation
7575
</div>

0 commit comments

Comments
 (0)