mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-02-03 22:15:42 -06:00
fix: type error
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
dba5a9c920
commit
2d7793062b
@ -1,3 +1,4 @@
|
|||||||
|
import { JSX } from "preact"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import { classNames } from "../util/lang"
|
import { classNames } from "../util/lang"
|
||||||
import { resolveRelative } from "../util/path"
|
import { resolveRelative } from "../util/path"
|
||||||
@ -5,7 +6,7 @@ import { resolveRelative } from "../util/path"
|
|||||||
import script from "./scripts/base-view-selector.inline"
|
import script from "./scripts/base-view-selector.inline"
|
||||||
import baseViewSelectorStyle from "./styles/baseViewSelector.scss"
|
import baseViewSelectorStyle from "./styles/baseViewSelector.scss"
|
||||||
|
|
||||||
const icons = {
|
const icons: Record<string, JSX.Element> = {
|
||||||
table: (
|
table: (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -127,7 +128,7 @@ const icons = {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewTypeIcons: Record<string, JSX.Element> = {
|
const viewTypeIcons: Record<string, JSX.Element | undefined> = {
|
||||||
table: icons.table,
|
table: icons.table,
|
||||||
list: icons.list,
|
list: icons.list,
|
||||||
gallery: icons.card,
|
gallery: icons.card,
|
||||||
@ -147,8 +148,7 @@ const BaseViewSelector: QuartzComponent = ({ fileData, displayClass }: QuartzCom
|
|||||||
const currentViewName = baseMeta.currentView
|
const currentViewName = baseMeta.currentView
|
||||||
const allViews = baseMeta.allViews
|
const allViews = baseMeta.allViews
|
||||||
const currentIcon =
|
const currentIcon =
|
||||||
viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ??
|
viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ?? icons.table
|
||||||
icons.table
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classNames(displayClass, "bases-toolbar")} data-base-view-selector>
|
<div class={classNames(displayClass, "bases-toolbar")} data-base-view-selector>
|
||||||
|
|||||||
@ -8,9 +8,7 @@ export default (() => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="popover-hint">
|
<div class="popover-hint">
|
||||||
<article
|
<article class={["base-content", ...(fileData.frontmatter?.cssclasses ?? [])].join(" ")}>
|
||||||
class={["base-content", ...(fileData.frontmatter?.cssclasses ?? [])].join(" ")}
|
|
||||||
>
|
|
||||||
{htmlToJsx(fileData.filePath!, fileData.basesRenderedTree ?? tree)}
|
{htmlToJsx(fileData.filePath!, fileData.basesRenderedTree ?? tree)}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -28,12 +28,17 @@ function setupBaseViewSelector() {
|
|||||||
if (selector.hasAttribute("data-initialized")) return
|
if (selector.hasAttribute("data-initialized")) return
|
||||||
selector.setAttribute("data-initialized", "true")
|
selector.setAttribute("data-initialized", "true")
|
||||||
|
|
||||||
const trigger = selector.querySelector(".text-icon-button") as HTMLElement | null
|
const triggerEl = selector.querySelector(".text-icon-button") as HTMLElement | null
|
||||||
const searchInput = selector.querySelector("[data-search-input]") as HTMLInputElement | null
|
const searchInputEl = selector.querySelector("[data-search-input]") as HTMLInputElement | null
|
||||||
const clearButton = selector.querySelector("[data-clear-search]") as HTMLElement | null
|
const clearButtonEl = selector.querySelector("[data-clear-search]") as HTMLElement | null
|
||||||
const viewList = selector.querySelector("[data-view-list]") as HTMLElement | null
|
const viewListEl = selector.querySelector("[data-view-list]") as HTMLElement | null
|
||||||
|
|
||||||
if (!trigger || !searchInput || !clearButton || !viewList) return
|
if (!triggerEl || !searchInputEl || !clearButtonEl || !viewListEl) return
|
||||||
|
|
||||||
|
const trigger = triggerEl
|
||||||
|
const searchInput = searchInputEl
|
||||||
|
const clearButton = clearButtonEl
|
||||||
|
const viewList = viewListEl
|
||||||
|
|
||||||
function toggleDropdown() {
|
function toggleDropdown() {
|
||||||
if (trigger.getAttribute("aria-expanded") === "true") {
|
if (trigger.getAttribute("aria-expanded") === "true") {
|
||||||
|
|||||||
@ -73,7 +73,9 @@
|
|||||||
background: var(--light);
|
background: var(--light);
|
||||||
border: 1px solid var(--lightgray);
|
border: 1px solid var(--lightgray);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
box-shadow:
|
||||||
|
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
||||||
|
0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
min-width: 280px;
|
min-width: 280px;
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@ -111,7 +111,9 @@ export function createFileParser(ctx: BuildCtx, fps: FilePath[]) {
|
|||||||
res.push([newAst, file])
|
res.push([newAst, file])
|
||||||
|
|
||||||
if (argv.verbose) {
|
if (argv.verbose) {
|
||||||
console.log(`[${isBaseFile ? "base" : "markdown"}] ${fp} -> ${file.data.slug} (${perf.timeSince()})`)
|
console.log(
|
||||||
|
`[${isBaseFile ? "base" : "markdown"}] ${fp} -> ${file.data.slug} (${perf.timeSince()})`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
trace(`\nFailed to process markdown \`${fp}\``, err as Error)
|
trace(`\nFailed to process markdown \`${fp}\``, err as Error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user