From 9be07334f5f17463830ed07d25fb245729d4c91c Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 27 May 2025 12:08:11 +0200 Subject: [PATCH] frame for onboarding process --- src/Components/Gaming/Modal.tsx | 36 ++-- src/Components/Gaming/Onboarding.tsx | 0 src/Components/Onboarding/Onboarding.tsx | 156 ++++++++++++++++++ src/Components/Onboarding/index.tsx | 1 + .../Profile/Subcomponents/AvatarWidget.tsx | 2 +- src/index.tsx | 2 + 6 files changed, 176 insertions(+), 21 deletions(-) create mode 100644 src/Components/Gaming/Onboarding.tsx create mode 100644 src/Components/Onboarding/Onboarding.tsx create mode 100644 src/Components/Onboarding/index.tsx diff --git a/src/Components/Gaming/Modal.tsx b/src/Components/Gaming/Modal.tsx index 32f66058..af1e1f6e 100644 --- a/src/Components/Gaming/Modal.tsx +++ b/src/Components/Gaming/Modal.tsx @@ -1,8 +1,5 @@ import { useEffect } from 'react' -/** - * @category Gaming - */ export function Modal({ children, showOnStartup, @@ -12,25 +9,24 @@ export function Modal({ }) { useEffect(() => { if (showOnStartup) { - window.my_modal_3.showModal() + window.my_modal_3?.showModal() } - // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return ( - <> - {/* You can open the modal using ID.showModal() method */} - -
- - {children} -
-
- -
-
- + +
+ + {children} +
+
+ +
+
) -} +} \ No newline at end of file diff --git a/src/Components/Gaming/Onboarding.tsx b/src/Components/Gaming/Onboarding.tsx new file mode 100644 index 00000000..e69de29b diff --git a/src/Components/Onboarding/Onboarding.tsx b/src/Components/Onboarding/Onboarding.tsx new file mode 100644 index 00000000..6f692f61 --- /dev/null +++ b/src/Components/Onboarding/Onboarding.tsx @@ -0,0 +1,156 @@ +import { useState } from 'react' +import SVG from 'react-inlinesvg' +import { Link, useNavigate } from 'react-router-dom' + +import { useLayers } from '#components/Map/hooks/useLayers' +import { AvatarWidget } from '#components/Profile/Subcomponents/AvatarWidget' + +import type { LayerProps } from '#src/index' + +// Schritt-Komponenten +const Step1 = () => { + const layers = useLayers() + return ( +
+

+ Willkommen auf der Karte der Menschlich Wirtschaften eG +

+

+ Diese interaktiven Karte zeigt das Netzwerk von Menschlich Wirtschaften eG. +

+

Hier findest du verschiedene Layer:

+ {layers.map((layer: LayerProps) => ( + + code.replace(/fill=".*?"/g, 'fill="currentColor"')} + /> +

{layer.name}

+
+ ))} +

Erstelle dir im nächsten Schritt dein Profil zu erstellen

+
+ ) +} + +const Step2 = () => { + const [userName, setUserName] = useState('') + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + return ( +
+

Erstelle dir deinen Acount

+

+ Werde Teil des Netzwerks und erstelle dir dein Profil und zeige dich auf der Karte! +

+ setUserName(e.target.value)} + className='tw:input tw:input-bordered tw:w-full tw:max-w-xs' + /> + setEmail(e.target.value)} + className='tw:input tw:input-bordered tw:w-full tw:max-w-xs' + /> + setPassword(e.target.value)} + className='tw:input tw:input-bordered tw:w-full tw:max-w-xs' + /> +

+ Du hast schon einen Account?{' '} + close()} + to='/login' + > + Dann logge dich ein! + +

+
+ ) +} + +const Step3 = () => { + const [avatar, setAvatar] = useState('') + return ( +
+

Lade ein Bild von dir hoch

+
+ +
+
+ +
+
+ ) +} + +const Step4 = () => ( +
+

Place your Profile on the Map!

+

Let's get started! Add your first project or profile.

+
+) + +const stepsTitles = ['Willkommen', 'Account', 'Avatar', 'Marker'] + +export const Onboarding = () => { + const close = () => { + navigate('/') + } + + const navigate = useNavigate() + + const [stepIndex, setStepIndex] = useState(0) + + const steps = [, , , ] + + const isLast = stepIndex === steps.length - 1 + const isFirst = stepIndex === 0 + + return ( +
+
+ {steps[stepIndex]} + +
+ +
+ {Array.from({ length: steps.length }).map((_, i) => ( +
+ ))} +
+ {!isLast ? ( + + ) : ( + + )} +
+
+
+ ) +} diff --git a/src/Components/Onboarding/index.tsx b/src/Components/Onboarding/index.tsx new file mode 100644 index 00000000..cf672978 --- /dev/null +++ b/src/Components/Onboarding/index.tsx @@ -0,0 +1 @@ +export { Onboarding } from './Onboarding' diff --git a/src/Components/Profile/Subcomponents/AvatarWidget.tsx b/src/Components/Profile/Subcomponents/AvatarWidget.tsx index 9434c535..f3852453 100644 --- a/src/Components/Profile/Subcomponents/AvatarWidget.tsx +++ b/src/Components/Profile/Subcomponents/AvatarWidget.tsx @@ -169,7 +169,7 @@ export const AvatarWidget: React.FC = ({ avatar, setAvatar }) className='tw:file-input tw:w-full tw:max-w-xs' onChange={onImageChange} /> -
+
{avatar ? ( diff --git a/src/index.tsx b/src/index.tsx index 07ec6212..498ad695 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,10 +9,12 @@ export * from './Components/Gaming' export * from './Components/Templates' export * from './Components/Input' export * from './Components/Item' +export * from './Components/Onboarding' declare global { interface Window { my_modal_3: { + [x: string]: any showModal(): void } }