mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-04-06 01:25:33 +00:00
hide tooltips on select position
This commit is contained in:
parent
467f7c249b
commit
7ba2ded1d1
@ -61,7 +61,7 @@
|
|||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"@vitest/coverage-v8": "^3.0.5",
|
"@vitest/coverage-v8": "^3.0.5",
|
||||||
"cypress": "^14.0.3",
|
"cypress": "^14.0.3",
|
||||||
"daisyui": "^5.0.6",
|
"daisyui": "^5.2.3",
|
||||||
"eslint": "^8.24.0",
|
"eslint": "^8.24.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-config-standard": "^17.1.0",
|
"eslint-config-standard": "^17.1.0",
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
import { useState } from 'react'
|
||||||
import SVG from 'react-inlinesvg'
|
import SVG from 'react-inlinesvg'
|
||||||
|
|
||||||
import PlusSVG from '#assets/plus.svg'
|
import PlusSVG from '#assets/plus.svg'
|
||||||
@ -18,6 +19,7 @@ export default function AddButton({
|
|||||||
const appState = useAppState()
|
const appState = useAppState()
|
||||||
const { width } = useWindowDimensions()
|
const { width } = useWindowDimensions()
|
||||||
const isMobile = width < 768
|
const isMobile = width < 768
|
||||||
|
const [hideTooltips, setHideTooltips] = useState(false)
|
||||||
|
|
||||||
const canAddItems = () => {
|
const canAddItems = () => {
|
||||||
let canAdd = false
|
let canAdd = false
|
||||||
@ -33,6 +35,14 @@ export default function AddButton({
|
|||||||
return canAdd
|
return canAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleLayerClick = (layer: any) => {
|
||||||
|
triggerAction(layer)
|
||||||
|
// Verstecke Tooltips auf Mobile nach Layer-Auswahl
|
||||||
|
if (isMobile) {
|
||||||
|
setHideTooltips(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{canAddItems() ? (
|
{canAddItems() ? (
|
||||||
@ -40,6 +50,16 @@ export default function AddButton({
|
|||||||
<label
|
<label
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className='tw:z-500 tw:btn tw:btn-circle tw:btn-lg tw:shadow tw:bg-base-100'
|
className='tw:z-500 tw:btn tw:btn-circle tw:btn-lg tw:shadow tw:bg-base-100'
|
||||||
|
onClick={() => {
|
||||||
|
if (hideTooltips) {
|
||||||
|
setHideTooltips(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onTouchEnd={() => {
|
||||||
|
if (hideTooltips) {
|
||||||
|
setHideTooltips(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<SVG src={PlusSVG} className='tw:h-5 tw:w-5' />
|
<SVG src={PlusSVG} className='tw:h-5 tw:w-5' />
|
||||||
</label>
|
</label>
|
||||||
@ -55,7 +75,7 @@ export default function AddButton({
|
|||||||
<li key={layer.name}>
|
<li key={layer.name}>
|
||||||
<a>
|
<a>
|
||||||
<div
|
<div
|
||||||
className={`tw:tooltip tw:tooltip-left ${isMobile ? 'tw:tooltip-open' : ''}`}
|
className={`tw:tooltip tw:tooltip-left ${isMobile && !hideTooltips ? 'tw:tooltip-open' : ''}`}
|
||||||
data-tip={layer.menuText}
|
data-tip={layer.menuText}
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
@ -68,11 +88,9 @@ export default function AddButton({
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className='tw:z-500 tw:border-0 tw:p-0 tw:w-10 tw:h-10 tw:cursor-pointer tw:rounded-full tw:mouse tw:drop-shadow-md tw:transition tw:ease-in tw:duration-200 tw:focus:outline-hidden tw:flex tw:items-center tw:justify-center'
|
className='tw:z-500 tw:border-0 tw:p-0 tw:w-10 tw:h-10 tw:cursor-pointer tw:rounded-full tw:mouse tw:drop-shadow-md tw:transition tw:ease-in tw:duration-200 tw:focus:outline-hidden tw:flex tw:items-center tw:justify-center'
|
||||||
style={{ backgroundColor: layer.menuColor || '#777' }}
|
style={{ backgroundColor: layer.menuColor || '#777' }}
|
||||||
onClick={() => {
|
onClick={() => handleLayerClick(layer)}
|
||||||
triggerAction(layer)
|
|
||||||
}}
|
|
||||||
onTouchEnd={(e) => {
|
onTouchEnd={(e) => {
|
||||||
triggerAction(layer)
|
handleLayerClick(layer)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@ -121,7 +121,7 @@
|
|||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"@vitest/coverage-v8": "^3.0.5",
|
"@vitest/coverage-v8": "^3.0.5",
|
||||||
"cypress": "^14.0.3",
|
"cypress": "^14.0.3",
|
||||||
"daisyui": "^5.0.6",
|
"daisyui": "^5.2.3",
|
||||||
"eslint": "^8.24.0",
|
"eslint": "^8.24.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-config-standard": "^17.1.0",
|
"eslint-config-standard": "^17.1.0",
|
||||||
@ -7004,9 +7004,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/daisyui": {
|
"node_modules/daisyui": {
|
||||||
"version": "5.1.29",
|
"version": "5.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.1.29.tgz",
|
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.2.3.tgz",
|
||||||
"integrity": "sha512-4eZhqCXO7CJVNGytTZEIQYJz3fah2gPleuqp4qUD4fD8WoEQIYzKwlOewi8nPaz6NX7vvSLZ+YSjt5Z5zqacGw==",
|
"integrity": "sha512-sldBQUIFCsSPoF4LvoHhIi9GnvBX/3aZD9NoTOvpTSX8sDjO484wQx7yEvRyREMpn4rZMvQSKKskHAHdM8+B4Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user