Visualize Your Ideas With Code
feat(ui): add external link to docs (#346)
Daniel Breinerfc4ee5d02831
diff --git a/packages/ui/src/components/icons/Docs.tsx b/packages/ui/src/components/icons/Docs.tsxnew file mode 100644index 00000000..9ad16cfa--- /dev/null+++ b/packages/ui/src/components/icons/Docs.tsx@@ -0,0 +1,7 @@+export function Docs() {+ return (+ <svg viewBox="0 0 24 24" fill="currentColor">+ <path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z" />+ </svg>+ );+}diff --git a/packages/ui/src/components/sidebar/Sidebar.tsx b/packages/ui/src/components/sidebar/Sidebar.tsxindex 6f5d4f23..922cc172 100644--- a/packages/ui/src/components/sidebar/Sidebar.tsx+++ b/packages/ui/src/components/sidebar/Sidebar.tsx@@ -8,6 +8,7 @@ import {useEffect, useRef, useState} from 'preact/hooks';import {shake} from '../animations';import {useStorage} from '../../hooks';import {MotionCanvas, Bug, Tune, VideoSettings, Schedule} from '../icons';+import {Docs} from '../icons/Docs';interface SidebarProps {setOpen?: (value: boolean) => void;@@ -52,6 +53,13 @@ export function Sidebar({setOpen}: SidebarProps) {icon: <MotionCanvas />,url: window.location.pathname === '/' ? undefined : '../',}}+ {{+ title: 'Docs',+ id: 'docs-external-link',+ type: TabType.ExternalLink,+ icon: <Docs />,+ url: 'https://motion-canvas.github.io/docs/',+ }}{{type: TabType.Space,}}diff --git a/packages/ui/src/components/tabs/Tabs.tsx b/packages/ui/src/components/tabs/Tabs.tsxindex a03b65e1..f1835aac 100644--- a/packages/ui/src/components/tabs/Tabs.tsx+++ b/packages/ui/src/components/tabs/Tabs.tsx@@ -6,6 +6,7 @@ import clsx from 'clsx';export enum TabType {Link,+ ExternalLink,Pane,Space,}@@ -26,6 +27,13 @@ type Tab =title?: string;id?: string;}+ | {+ type: TabType.ExternalLink;+ icon: ComponentChildren;+ url: string;+ title?: string;+ id?: string;+ }| {type: TabType.Space;};@@ -66,6 +74,16 @@ export function Tabs({children, tab, onToggle}: TabsProps) {>{data.icon}</a>+ ) : data.type === TabType.ExternalLink ? (+ <a+ title={data.title}+ href={data.url}+ id={data.id}+ className={clsx(styles.tab)}+ target="_blank"+ >+ {data.icon}+ </a>) : data.type === TabType.Pane ? (<buttontitle={data.title}