-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
140 additions
and
13 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
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,39 @@ | ||
import { ComponentProps, h } from "preact"; | ||
import { useEffect, useState } from "preact/hooks"; | ||
import { ObsidianIcon } from "src/util"; | ||
|
||
interface ClosableProps extends ComponentProps<"details"> { | ||
title: string; | ||
index: number; | ||
children?: h.JSX.Element | h.JSX.Element[]; | ||
} | ||
export default function Closable({ title, children, index }: ClosableProps): h.JSX.Element { | ||
const [open, setOpen] = useState(false); | ||
|
||
const toggleHandler = (): void => { | ||
setOpen(!open); | ||
}; | ||
|
||
useEffect(() => { | ||
const handle = (e: CustomEvent): void => { | ||
if (e.detail.index === index) { | ||
setOpen(true); | ||
} | ||
}; | ||
addEventListener("cmdr-open-hider-tab", handle); | ||
|
||
return () => removeEventListener("cmdr-open-hider-tab", handle); | ||
}, [index]); | ||
|
||
return ( | ||
<div className="cmdr-accordion" aria-expanded={open}> | ||
<div className="cmdr-accordion-header" onClick={toggleHandler}> | ||
<span>{title}</span> | ||
<ObsidianIcon className="cmdr-accordion-chevron clickable-icon" icon="chevron-down" size={24} /> | ||
</div> | ||
<div className="cmdr-accordion-content"> | ||
{children} | ||
</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
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,21 @@ | ||
import { Fragment, h } from "preact"; | ||
import { useMemo } from "preact/hooks"; | ||
import t from "src/l10n"; | ||
import CommanderPlugin from "src/main"; | ||
import Closable from "./Closable"; | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
export default function HidingViewer({ plugin }: { plugin: CommanderPlugin }): h.JSX.Element { | ||
const tabs = useMemo(() => [ | ||
<Closable title={t("Left Ribbon")} index={0}></Closable>, | ||
<Closable title={t("Statusbar")} index={1}></Closable>, | ||
<Closable title={t("Editor Menu")} index={2}></Closable>, | ||
<Closable title={t("File Menu")} index={3}></Closable>, | ||
], []); | ||
|
||
return ( | ||
<Fragment> | ||
{tabs} | ||
</Fragment> | ||
); | ||
} |
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