|
1 | | -import { useState, useCallback } from "react"; |
| 1 | +import { useState, useCallback, useRef, useEffect } from "react"; |
2 | 2 | import { usePlugin } from "./PluginContext"; |
3 | | -import { Notice } from "obsidian"; |
| 3 | +import { Notice, setIcon } from "obsidian"; |
4 | 4 | import SuggestInput from "./SuggestInput"; |
| 5 | +import { SLACK_LOGO, WHITE_LOGO_SVG } from "~/icons"; |
5 | 6 |
|
| 7 | +const DOCS_URL = "https://discoursegraphs.com/docs/obsidian"; |
| 8 | +const COMMUNITY_URL = |
| 9 | + "https://join.slack.com/t/discoursegraphs/shared_invite/zt-37xklatti-cpEjgPQC0YyKYQWPNgAkEg"; |
| 10 | + |
| 11 | +const InfoSection = () => { |
| 12 | + const plugin = usePlugin(); |
| 13 | + const logoRef = useRef<HTMLDivElement>(null); |
| 14 | + const communityIconRef = useRef<HTMLDivElement>(null); |
| 15 | + |
| 16 | + useEffect(() => { |
| 17 | + if (logoRef.current) { |
| 18 | + logoRef.current.innerHTML = WHITE_LOGO_SVG; |
| 19 | + } |
| 20 | + if (communityIconRef.current) { |
| 21 | + communityIconRef.current.innerHTML = SLACK_LOGO; |
| 22 | + } |
| 23 | + }, []); |
| 24 | + |
| 25 | + return ( |
| 26 | + <div className="flex justify-center"> |
| 27 | + <div |
| 28 | + className="flex w-48 flex-col items-center rounded-lg p-3" |
| 29 | + style={{ background: "var(--tag-background)" }} |
| 30 | + > |
| 31 | + <div |
| 32 | + ref={logoRef} |
| 33 | + className="h-12 w-12" |
| 34 | + style={{ color: "var(--interactive-accent)" }} |
| 35 | + /> |
| 36 | + <div |
| 37 | + className="font-semibold" |
| 38 | + style={{ color: "var(--interactive-accent)" }} |
| 39 | + > |
| 40 | + Discourse Graphs |
| 41 | + </div> |
| 42 | + |
| 43 | + <a |
| 44 | + href={COMMUNITY_URL} |
| 45 | + className="flex items-center gap-1 text-sm no-underline hover:opacity-80" |
| 46 | + style={{ color: "var(--interactive-accent)" }} |
| 47 | + target="_blank" |
| 48 | + rel="noopener noreferrer" |
| 49 | + aria-label="Community" |
| 50 | + > |
| 51 | + <div ref={communityIconRef} className="icon" /> |
| 52 | + <span>Community</span> |
| 53 | + <span |
| 54 | + className="icon" |
| 55 | + ref={(el) => (el && setIcon(el, "arrow-up-right")) || undefined} |
| 56 | + /> |
| 57 | + </a> |
| 58 | + <a |
| 59 | + href={DOCS_URL} |
| 60 | + className="flex items-center gap-1 text-sm no-underline hover:opacity-80" |
| 61 | + style={{ color: "var(--interactive-accent)" }} |
| 62 | + target="_blank" |
| 63 | + rel="noopener noreferrer" |
| 64 | + aria-label="Docs" |
| 65 | + > |
| 66 | + <div |
| 67 | + className="icon" |
| 68 | + ref={(el) => (el && setIcon(el, "book")) || undefined} |
| 69 | + /> |
| 70 | + <span>Docs</span> |
| 71 | + <span |
| 72 | + className="icon" |
| 73 | + ref={(el) => (el && setIcon(el, "arrow-up-right")) || undefined} |
| 74 | + /> |
| 75 | + </a> |
| 76 | + <span |
| 77 | + className="text-muted text-xs" |
| 78 | + style={{ color: "var(--interactive-accent)" }} |
| 79 | + > |
| 80 | + {plugin.manifest.version} |
| 81 | + </span> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + ); |
| 85 | +}; |
6 | 86 | export const FolderSuggestInput = ({ |
7 | 87 | value, |
8 | 88 | onChange, |
@@ -195,6 +275,7 @@ const GeneralSettings = () => { |
195 | 275 | {hasUnsavedChanges && ( |
196 | 276 | <div className="text-muted mt-2">You have unsaved changes</div> |
197 | 277 | )} |
| 278 | + <InfoSection /> |
198 | 279 | </div> |
199 | 280 | ); |
200 | 281 | }; |
|
0 commit comments