-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(documentation): documentation updated
resolves #23
- Loading branch information
1 parent
3a74086
commit ec61962
Showing
69 changed files
with
2,018 additions
and
1,441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
import { CodeBlock, dracula } from 'react-code-blocks' | ||
import Usage from './Details/Usage' | ||
import { unified } from "unified"; | ||
import remarkParse from "remark-parse"; | ||
import remarkRehype from "remark-rehype"; | ||
import rehypeStringify from "rehype-stringify"; | ||
import rehypePrettyCode from "rehype-pretty-code"; | ||
import { useEffect, useRef } from "react"; | ||
|
||
export default function CodeSample({ code }: any) { | ||
|
||
const ref = useRef<any>(); | ||
|
||
useEffect(() => { | ||
const process = async () => { | ||
|
||
const processor = await unified() | ||
.use(remarkParse) | ||
.use(remarkRehype) | ||
.use(rehypePrettyCode, { | ||
theme: 'rose-pine', | ||
grid: false | ||
}) | ||
.use(rehypeStringify) | ||
.process("```ts \n" + code); | ||
|
||
if (ref.current) | ||
ref.current.innerHTML = processor.toString(); | ||
} | ||
|
||
process(); | ||
|
||
}, [code]); | ||
|
||
return ( | ||
<Usage title="Syntex"> | ||
<CodeBlock | ||
customStyle={{ | ||
padding: "0 0.1rem" | ||
}} | ||
theme={dracula} | ||
text={code} | ||
language="jsx" | ||
wrapLongLines | ||
showLineNumbers={false} | ||
/> | ||
</Usage> | ||
<div ref={ref}></div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
import React, { lazy, Suspense } from 'react' | ||
import React, { lazy, Suspense, useState } from 'react' | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; | ||
|
||
const Title = lazy(() => import('@/common/Details/Title')); | ||
const Lead = lazy(() => import('@/common/Lead')); | ||
const CodeSample = lazy(() => import('@/common/CodeSample')); | ||
|
||
export default function Documentation({ hook, info, usage, children }: any) { | ||
const [activeTab, setActiveTab] = useState('docs'); | ||
|
||
return ( | ||
<> | ||
<Suspense fallback={<></>}> | ||
<Title>{hook}</Title> | ||
</Suspense> | ||
|
||
<Suspense fallback={<>Loading Code Block</>}> | ||
<Lead className='text-md'> | ||
<h2 className='text-sm'> | ||
{info} | ||
</Lead> | ||
</h2> | ||
</Suspense> | ||
|
||
<Suspense fallback={<></>}> | ||
<CodeSample code={usage} /> | ||
</Suspense> | ||
<Tabs defaultValue={activeTab} className="w-full" onValueChange={(newTab) => { | ||
setActiveTab(newTab); | ||
}}> | ||
<TabsList className="w-full my-4"> | ||
<TabsTrigger className="w-1/2" value="docs">Docs</TabsTrigger> | ||
<TabsTrigger className="w-1/2" value="demo">Demo</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="docs"> | ||
<CodeSample code={usage} /> | ||
</TabsContent> | ||
{ | ||
activeTab === 'demo' | ||
? <TabsContent value="demo"> | ||
<div className='border rounded-md p-4 bg-slate-50'> | ||
{children} | ||
</div> | ||
</TabsContent> | ||
: "" | ||
} | ||
</Tabs> | ||
|
||
{children} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import { useArray } from '../../../..'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
export default function Demo() { | ||
const { array, set, push, remove, filter, update, clear } = useArray([1, 2, 3, 4, 5, 6]) | ||
|
||
return ( | ||
<> | ||
<div>{array.join(", ")}</div> | ||
|
||
<div className="flex flex-row flex-wrap gap-3 mt-2"> | ||
<Button size="sm" onClick={() => push(Math.floor(Math.random() * 50))}>Add random number</Button> | ||
<Button size="sm" onClick={() => update(1, 9)}>Update 2nd element to 9</Button> | ||
<Button size="sm" onClick={() => remove(1)}>Remove Second Element</Button> | ||
<Button size="sm" onClick={() => filter((f: number) => f < 3)}>Keep numbers less than 3</Button> | ||
<Button size="sm" onClick={() => set([1, 2])}>Set 1 to 2</Button> | ||
<Button size="sm" onClick={clear}>Clear</Button> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import { useAsync } from '../../../..'; | ||
|
||
export default function Demo() { | ||
const { loading, value, error } = useAsync(() => { | ||
return new Promise((resolve, reject) => { | ||
const success = true; | ||
|
||
setTimeout(() => { | ||
success ? resolve("Success") : reject("Error"); | ||
}, 1500) | ||
}) | ||
}) | ||
|
||
return ( | ||
<> | ||
<div>Loading: {loading.toString()}</div> | ||
|
||
<div className="flex flex-row flex-wrap gap-3 mt-2"> | ||
<div className='text-green-600 font-semibold'>{value}</div> | ||
<div className='text-red-600 font-semibold'>{error}</div> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.