From 7e613be0199dd2f17f59e359bfd3029dde4c701a Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Thu, 21 Mar 2024 15:45:30 +0100 Subject: [PATCH] add button for index page --- .../Map/Subcomponents/AddButton.tsx | 60 +++---- src/Components/Profile/OverlayItemProfile.tsx | 14 +- .../Profile/OverlayItemProfileSettings.tsx | 2 - src/Components/Profile/PlusButton.tsx | 5 +- src/Components/Profile/index.tsx | 3 +- src/Components/Templates/ItemsIndexPage.tsx | 146 ++++++++++++++---- src/index.tsx | 2 +- 7 files changed, 163 insertions(+), 69 deletions(-) diff --git a/src/Components/Map/Subcomponents/AddButton.tsx b/src/Components/Map/Subcomponents/AddButton.tsx index daad12c9..f57e690b 100644 --- a/src/Components/Map/Subcomponents/AddButton.tsx +++ b/src/Components/Map/Subcomponents/AddButton.tsx @@ -11,43 +11,43 @@ export default function AddButton({ triggerAction }: { triggerAction: React.Disp const canAddItems = () => { let canAdd = false; layers.map(layer => { - if(layer.api?.createItem && hasUserPermission(layer.api.collectionName!,"create")) canAdd = true; + if (layer.api?.createItem && hasUserPermission(layer.api.collectionName!, "create")) canAdd = true; }) return canAdd; } return ( - <>{ - canAddItems() ? -
- - +
: "" + } + ) } diff --git a/src/Components/Profile/OverlayItemProfile.tsx b/src/Components/Profile/OverlayItemProfile.tsx index 1744246a..7fec5c1d 100644 --- a/src/Components/Profile/OverlayItemProfile.tsx +++ b/src/Components/Profile/OverlayItemProfile.tsx @@ -13,7 +13,7 @@ import { useAddTag, useTags } from '../Map/hooks/useTags'; import { useAddFilterTag, useResetFilterTags } from '../Map/hooks/useFilter'; import { HeaderView } from '../Map/Subcomponents/ItemPopupComponents/HeaderView'; import { useHasUserPermission } from '../Map/hooks/usePermissions'; -import PlusButton from './PlusButton'; +import {PlusButton} from './PlusButton'; import { TextAreaInput, TextInput } from '../Input'; import { hashTagRegex } from '../../Utils/HashTagRegex'; import { randomColor } from '../../Utils/RandomColor'; @@ -56,11 +56,15 @@ export function OverlayItemProfile() { const hasUserPermission = useHasUserPermission(); - const tabRef = useRef(null); + const tabRef = useRef(null); function scroll() { - tabRef.current?.scrollTo(0, 800); + tabRef.current?.scrollIntoView(); } + + useEffect(() => { + scroll(); + }, [addItemPopupType]) useEffect(() => { @@ -170,7 +174,7 @@ export function OverlayItemProfile() { setActiveTab(2)} /> -
+
{relations && relations.map(i => { @@ -187,7 +191,7 @@ export function OverlayItemProfile() { else return null })} {addItemPopupType == "project" ? -
submitNewItem(e, addItemPopupType)} > + submitNewItem(e, addItemPopupType)} >
+
: <> + }
+ {setAddItemPopupType("project"); scroll();}} color={'#777'} /> diff --git a/src/index.tsx b/src/index.tsx index f1feb529..1b47895c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,7 @@ export { UtopiaMap, Layer, Tags, Permissions, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, PopupTextInput, PopupButton, TextView, StartEndView } from './Components/Map'; export {AppShell, Content, SideBar} from "./Components/AppShell" export {AuthProvider, useAuth, LoginPage, SignupPage, RequestPasswordPage, SetNewPasswordPage} from "./Components/Auth" -export {UserSettings, ProfileSettings, OverlayProfile, OverlayProfileSettings, OverlayUserSettings, OverlayItemProfile, OverlayItemProfileSettings} from './Components/Profile' +export {UserSettings, ProfileSettings, OverlayProfile, OverlayProfileSettings, OverlayUserSettings, OverlayItemProfile, OverlayItemProfileSettings, PlusButton} from './Components/Profile' export {Quests, Modal} from './Components/Gaming' export {TitleCard, CardPage, MapOverlayPage, CircleLayout, MoonCalendar, ItemsIndexPage, ItemViewPage} from './Components/Templates' export {TextInput, TextAreaInput, SelectBox} from './Components/Input'