mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
* support for svg files Support to load svg files and include them as bas64 encoded images in the bundle. * navbar svgs * replace NavBar SVGs with heroicons * layercontrol icons * lint fix * quest - questionmark * plusbutton - plus * linkeditem - elipse-vertical - link-slash * contactinfo - envelope & phone * avatar - arrow-up-tray * ActionButton - link & plus * StartEndView - calendar x2 * HeaderView - ellipse-vertical & pencil & trash * SidebarControl - bars-3 * SearchControl - flag & magnifying-glass * GratitudeControl - heart * FilterControl - funnel * AddButton - plus * reduce test coverage requirements * remove wrongfully commit dummy svg * updated obsolete package.lock * migrate more svgs from code to file, use hero icons where it seems applicable * moved share icons to subfolder * fixed layout --------- Co-authored-by: Anton Tranelis <mail@antontranelis.de>
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
import PlusSVG from '#assets/plus.svg'
|
|
import { useLayers } from '#components/Map/hooks/useLayers'
|
|
import { useHasUserPermission } from '#components/Map/hooks/usePermissions'
|
|
|
|
export default function AddButton({
|
|
triggerAction,
|
|
}: {
|
|
triggerAction: React.Dispatch<React.SetStateAction<any>>
|
|
}) {
|
|
const layers = useLayers()
|
|
const hasUserPermission = useHasUserPermission()
|
|
|
|
const canAddItems = () => {
|
|
let canAdd = false
|
|
layers.map((layer) => {
|
|
if (
|
|
layer.api?.createItem &&
|
|
hasUserPermission(layer.api.collectionName!, 'create', undefined, layer) &&
|
|
layer.listed
|
|
)
|
|
canAdd = true
|
|
return null
|
|
})
|
|
return canAdd
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{canAddItems() ? (
|
|
<div className='tw-dropdown tw-dropdown-top tw-dropdown-end tw-dropdown-hover tw-z-500 tw-absolute tw-right-4 tw-bottom-4'>
|
|
<label tabIndex={0} className='tw-z-500 tw-btn tw-btn-circle tw-shadow tw-bg-base-100'>
|
|
<img src={PlusSVG} alt='Layers' className='tw-h-5 tw-w-5' />
|
|
</label>
|
|
<ul tabIndex={0} className='tw-dropdown-content tw-pr-1 tw-list-none'>
|
|
{layers.map(
|
|
(layer) =>
|
|
layer.api?.createItem &&
|
|
hasUserPermission(layer.api.collectionName!, 'create', undefined, layer) &&
|
|
layer.listed && (
|
|
<li key={layer.name}>
|
|
<a>
|
|
<div className='tw-tooltip tw-tooltip-left' data-tip={layer.menuText}>
|
|
<button
|
|
tabIndex={0}
|
|
className='tw-z-500 tw-border-0 tw-pl-2 tw-p-0 tw-mb-3 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 focus:tw-outline-none'
|
|
style={{ backgroundColor: layer.menuColor || '#777' }}
|
|
onClick={() => {
|
|
triggerAction(layer)
|
|
}}
|
|
onTouchEnd={(e) => {
|
|
triggerAction(layer)
|
|
e.preventDefault()
|
|
}}
|
|
>
|
|
<img
|
|
src={layer.menuIcon}
|
|
className='tw-h-6 tw-w-6 tw-text-white'
|
|
style={{ filter: 'invert(100%) brightness(200%)' }}
|
|
/>
|
|
</button>
|
|
</div>
|
|
</a>
|
|
</li>
|
|
),
|
|
)}
|
|
</ul>
|
|
</div>
|
|
) : (
|
|
''
|
|
)}
|
|
</>
|
|
)
|
|
}
|