diff --git a/src/app/components/previews/DialogPreview.tsx b/src/app/components/previews/DialogPreview.tsx
index 95b4d435..01808b93 100644
--- a/src/app/components/previews/DialogPreview.tsx
+++ b/src/app/components/previews/DialogPreview.tsx
@@ -1,6 +1,6 @@
import { Identifier, ItemStack } from 'deepslate'
-import type { ComponentChild } from 'preact'
-import { useEffect, useRef } from 'preact/hooks'
+import type { ComponentChild, ComponentChildren } from 'preact'
+import { useEffect, useRef, useState } from 'preact/hooks'
import { safeJsonParse } from '../../Utils.js'
import { ItemDisplay } from '../ItemDisplay.jsx'
import { TextComponent } from '../TextComponent.jsx'
@@ -46,7 +46,9 @@ function DialogTitle({ title }: { title: any }) {
// TODO: add warning button tooltip
return
}
@@ -111,7 +113,7 @@ function DialogContent({ dialog }: { dialog: any }) {
if (type === 'multi_action') {
return
{dialog.actions?.map((a: any) =>
-
+
) ?? []}
}
@@ -121,7 +123,7 @@ function DialogContent({ dialog }: { dialog: any }) {
{dialog.inputs?.map((i: any) => )}
{dialog.actions?.map((a: any) =>
-
+
) ?? []}
>
@@ -150,8 +152,8 @@ function DialogFooter({ dialog }: { dialog: any }) {
if (type === 'confirmation') {
return
-
-
+
+
}
@@ -165,7 +167,7 @@ function DialogFooter({ dialog }: { dialog: any }) {
if (type === 'notice') {
return
-
+
}
@@ -175,40 +177,13 @@ function DialogFooter({ dialog }: { dialog: any }) {
if (type === 'simple_input_form') {
return
-
+
}
return <>>
}
-interface ColumnsGridProps {
- columns: number
- children: ComponentChild[]
-}
-function ColumnsGrid({ columns, children }: ColumnsGridProps) {
- const totalCount = children.length
- const gridCount = Math.floor(totalCount / columns) * columns
- return
- {children.slice(0, gridCount)}
- {totalCount > gridCount &&
- {children.slice(gridCount)}
-
}
-
-}
-
-interface ButtonProps {
- label: any
- width: number
- tooltip?: any
-}
-function Button({ label, width }: ButtonProps) {
- // TODO: add tooltip
- return
-
-
-}
-
function InputControl({ input }: { input: any }) {
const type = input.type?.replace(/^minecraft:/, '')
@@ -249,6 +224,64 @@ function InputControl({ input }: { input: any }) {
return <>>
}
+interface ColumnsGridProps {
+ columns: number
+ children: ComponentChild[]
+}
+function ColumnsGrid({ columns, children }: ColumnsGridProps) {
+ const totalCount = children.length
+ const gridCount = Math.floor(totalCount / columns) * columns
+ return
+ {children.slice(0, gridCount)}
+ {totalCount > gridCount &&
+ {children.slice(gridCount)}
+
}
+
+}
+
+interface ButtonProps {
+ label: any
+ width: number
+ tooltip?: any
+}
+function Button({ label, width, tooltip }: ButtonProps) {
+ return
+
+
+
+
+}
+
+interface WithTooltipProps {
+ tooltip?: any
+ children: ComponentChildren
+}
+function WithTooltip({ tooltip, children }: WithTooltipProps) {
+ if (!tooltip) {
+ return <>{children}>
+ }
+
+ const el = useRef(null)
+ const [tooltipOffset, setTooltipOffset] = useState<[number, number]>([0, 0])
+
+ useEffect(() => {
+ const onMove = (e: MouseEvent) => {
+ requestAnimationFrame(() => {
+ setTooltipOffset([e.offsetX + 20, e.offsetY - 10])
+ })
+ }
+ el.current?.addEventListener('mousemove', onMove)
+ return () => el.current?.removeEventListener('mousemove', onMove)
+ }, [])
+
+ return
+}
+
function px(n: number) {
return `calc(var(--dialog-px) * ${n})`
}
diff --git a/src/styles/global.css b/src/styles/global.css
index 0be038f4..8613f0b9 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -1895,7 +1895,8 @@ hr {
.dialog-edit-box,
.dialog-checkbox,
.dialog-slider-track,
-.dialog-slider-handle {
+.dialog-slider-handle,
+.dialog-tooltip {
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-crisp-edges;
image-rendering: crisp-edges;
@@ -1986,6 +1987,38 @@ hr {
padding-bottom: var(--dialog-px);
}
+.tooltip-container {
+ position: relative;
+}
+
+.tooltip-container > * > * {
+ pointer-events: none;
+}
+
+.dialog-tooltip {
+ padding: var(--dialog-px);
+ border: solid calc(var(--dialog-px) * 2) #220044;
+ border-image-source: url(/images/tooltip.png);
+ border-image-slice: 2 fill;
+ border-image-outset: calc(var(--dialog-px) * 1);
+ width: max-content;
+ max-width: calc(var(--dialog-px) * 150);
+ display: none;
+ position: absolute;
+ pointer-events: none;
+ z-index: 5;
+ padding: calc(var(--dialog-px) * 2);
+}
+
+.tooltip-container:hover > .dialog-tooltip {
+ display: block;
+}
+
+.tooltip-container > .dialog-tooltip .text-component {
+ white-space: pre-wrap;
+ text-align: initial;
+}
+
.project-files {
background-color: var(--background-2);
color: var(--text-2);