chore: update floating-ui and dependencies

This commit is contained in:
DIYgod
2023-02-02 18:09:35 +00:00
parent f20df3c0b7
commit c8354d1c8c
4 changed files with 311 additions and 292 deletions
+9 -9
View File
@@ -32,7 +32,7 @@
"@crossbell/util-metadata": "0.0.13",
"@emoji-mart/data": "1.1.2",
"@emoji-mart/react": "1.1.1",
"@floating-ui/react-dom-interactions": "0.13.3",
"@floating-ui/react": "^0.19.1",
"@headlessui/react": "1.7.8",
"@heroicons/react": "2.0.14",
"@iconify-json/akar-icons": "1.1.12",
@@ -44,11 +44,11 @@
"@uiw/codemirror-extensions-events": "4.19.7",
"@uiw/react-codemirror": "4.19.7",
"@urql/core": "3.1.1",
"axios": "1.2.6",
"axios": "1.3.1",
"canvas-confetti": "^1.6.0",
"chroma-js": "^2.4.2",
"clsx": "1.2.1",
"crossbell.js": "0.16.3",
"crossbell.js": "0.16.4",
"dayjs": "1.11.7",
"dotenv": "16.0.3",
"emoji-mart": "5.5.2",
@@ -101,7 +101,7 @@
"unist-util-visit": "4.1.2",
"use-onclickoutside": "0.4.1",
"uuid": "9.0.0",
"wagmi": "0.11.0",
"wagmi": "0.11.3",
"zustand": "4.3.2"
},
"devDependencies": {
@@ -109,7 +109,7 @@
"@iconify-json/bxs": "1.1.5",
"@iconify-json/carbon": "1.1.14",
"@iconify-json/fluent": "1.1.17",
"@iconify-json/mdi": "1.1.44",
"@iconify-json/mdi": "1.1.45",
"@next/bundle-analyzer": "13.1.6",
"@playwright/test": "1.30.0",
"@tailwindcss/line-clamp": "^0.4.2",
@@ -128,8 +128,8 @@
"@types/sortablejs": "1.15.0",
"@types/ua-parser-js": "0.7.36",
"@types/uuid": "9.0.0",
"@unocss/cli": "0.49.1",
"@unocss/preset-icons": "0.49.1",
"@unocss/cli": "0.49.4",
"@unocss/preset-icons": "0.49.4",
"autoprefixer": "10.4.13",
"cross-spawn": "7.0.3",
"esbuild": "0.17.5",
@@ -142,8 +142,8 @@
"postcss-import": "15.1.0",
"prettier": "2.8.3",
"tailwindcss": "3.2.4",
"typescript": "4.9.4",
"unocss": "0.49.1",
"typescript": "4.9.5",
"unocss": "0.49.4",
"vitest": "0.28.3"
},
"engines": {
+255 -248
View File
File diff suppressed because it is too large Load Diff
+27 -19
View File
@@ -10,7 +10,8 @@ import {
useFocus,
useRole,
useDismiss,
} from "@floating-ui/react-dom-interactions"
useTransitionStyles,
} from "@floating-ui/react"
import { CharacterCard } from "~/components/common/CharacterCard"
export const CharacterFloatCard: React.FC<{
@@ -19,7 +20,7 @@ export const CharacterFloatCard: React.FC<{
}> = ({ siteId, children }) => {
const [open, setOpen] = useState(false)
const { x, y, reference, floating, strategy, context } = useFloating({
const { x, y, refs, strategy, context } = useFloating({
placement: "bottom-start",
open,
onOpenChange: setOpen,
@@ -34,31 +35,38 @@ export const CharacterFloatCard: React.FC<{
useDismiss(context),
])
const { isMounted, styles } = useTransitionStyles(context, {
duration: 100,
})
const [buttonLoading, setButtonLoading] = useState(false)
return (
<span {...getReferenceProps({ ref: reference, ...children.props })}>
{children}
{
<span
{...getFloatingProps({
ref: floating,
className:
"z-10 block w-80" + (open || buttonLoading ? "" : " hidden"),
style: {
position: strategy,
top: y ?? "0",
left: x ?? "0",
},
})}
<>
<div ref={refs.setReference} {...getReferenceProps()}>
{children}
</div>
{isMounted && (
<div
ref={refs.setFloating}
className={
"z-10 block w-80" + (open || buttonLoading ? "" : " hidden")
}
style={{
position: strategy,
top: y ?? "0",
left: x ?? "0",
...styles,
}}
{...getFloatingProps()}
>
<CharacterCard
siteId={siteId}
open={open}
setButtonLoading={setButtonLoading}
/>
</span>
}
</span>
</div>
)}
</>
)
}
+20 -16
View File
@@ -11,7 +11,8 @@ import {
useFocus,
useRole,
useDismiss,
} from "@floating-ui/react-dom-interactions"
useTransitionStyles,
} from "@floating-ui/react"
interface Props {
label: string
@@ -22,7 +23,7 @@ interface Props {
export const Tooltip = ({ children, label, placement = "top" }: Props) => {
const [open, setOpen] = useState(false)
const { x, y, reference, floating, strategy, context } = useFloating({
const { x, y, refs, strategy, context } = useFloating({
placement,
open,
onOpenChange: setOpen,
@@ -37,23 +38,26 @@ export const Tooltip = ({ children, label, placement = "top" }: Props) => {
useDismiss(context),
])
const { isMounted, styles } = useTransitionStyles(context, {
duration: 100,
})
return (
<>
{cloneElement(
children,
getReferenceProps({ ref: reference, ...children.props }),
)}
{open && (
<div ref={refs.setReference} {...getReferenceProps()}>
{children}
</div>
{isMounted && (
<div
{...getFloatingProps({
ref: floating,
className: "bg-zinc-600 text-white rounded-lg shadow-lg px-3 py-1",
style: {
position: strategy,
top: y ?? "",
left: x ?? "",
},
})}
ref={refs.setFloating}
className="bg-zinc-600 text-white rounded-lg shadow-lg px-3 py-1"
style={{
position: strategy,
top: y ?? "0",
left: x ?? "0",
...styles,
}}
{...getFloatingProps()}
>
{label}
</div>