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 { classNames } from "../util/lang"
|
||||
import { resolveRelative } from "../util/path"
|
||||
@ -5,7 +6,7 @@ import { resolveRelative } from "../util/path"
|
||||
import script from "./scripts/base-view-selector.inline"
|
||||
import baseViewSelectorStyle from "./styles/baseViewSelector.scss"
|
||||
|
||||
const icons = {
|
||||
const icons: Record<string, JSX.Element> = {
|
||||
table: (
|
||||
<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,
|
||||
list: icons.list,
|
||||
gallery: icons.card,
|
||||
@ -147,8 +148,7 @@ const BaseViewSelector: QuartzComponent = ({ fileData, displayClass }: QuartzCom
|
||||
const currentViewName = baseMeta.currentView
|
||||
const allViews = baseMeta.allViews
|
||||
const currentIcon =
|
||||
viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ??
|
||||
icons.table
|
||||
viewTypeIcons[allViews.find((view) => view.name === currentViewName)?.type ?? ""] ?? icons.table
|
||||
|
||||
return (
|
||||
<div class={classNames(displayClass, "bases-toolbar")} data-base-view-selector>
|
||||
|
||||
@ -8,9 +8,7 @@ export default (() => {
|
||||
|
||||
return (
|
||||
<div class="popover-hint">
|
||||
<article
|
||||
class={["base-content", ...(fileData.frontmatter?.cssclasses ?? [])].join(" ")}
|
||||
>
|
||||
<article class={["base-content", ...(fileData.frontmatter?.cssclasses ?? [])].join(" ")}>
|
||||
{htmlToJsx(fileData.filePath!, fileData.basesRenderedTree ?? tree)}
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@ -28,12 +28,17 @@ function setupBaseViewSelector() {
|
||||
if (selector.hasAttribute("data-initialized")) return
|
||||
selector.setAttribute("data-initialized", "true")
|
||||
|
||||
const trigger = selector.querySelector(".text-icon-button") as HTMLElement | null
|
||||
const searchInput = selector.querySelector("[data-search-input]") as HTMLInputElement | null
|
||||
const clearButton = selector.querySelector("[data-clear-search]") as HTMLElement | null
|
||||
const viewList = selector.querySelector("[data-view-list]") as HTMLElement | null
|
||||
const triggerEl = selector.querySelector(".text-icon-button") as HTMLElement | null
|
||||
const searchInputEl = selector.querySelector("[data-search-input]") as HTMLInputElement | null
|
||||
const clearButtonEl = selector.querySelector("[data-clear-search]") 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() {
|
||||
if (trigger.getAttribute("aria-expanded") === "true") {
|
||||
|
||||
@ -73,7 +73,9 @@
|
||||
background: var(--light);
|
||||
border: 1px solid var(--lightgray);
|
||||
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;
|
||||
min-width: 280px;
|
||||
display: none;
|
||||
|
||||
@ -111,7 +111,9 @@ export function createFileParser(ctx: BuildCtx, fps: FilePath[]) {
|
||||
res.push([newAst, file])
|
||||
|
||||
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) {
|
||||
trace(`\nFailed to process markdown \`${fp}\``, err as Error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user