'use client'
import { BackgroundColor, Section } from '@/components/Section/Section'
import { ChemnitzMap } from '@/components/ChemnitzMap/ChemnitzMap'
import { Title } from '@/components/Title/Title'
import styles from './styles.module.scss'
import { Container } from '@/components/Container/Container'
import { P } from '@/components/Text/Paragraph'
import { CollapsibleArrow } from '@/components/CollapsibleArrow/CollapsibleArrow'
import React, { useEffect, useRef, useState } from 'react'
import classNames from 'classnames'
type CollapsibleMapWithTextProps = {
backgroundColor?: BackgroundColor
title: string
text: string
content?: React.ReactNode
}
type MoreInformationProps = {
isCollapsed: boolean
onClick: () => void
}
const MoreInformation = ({ isCollapsed, onClick }: MoreInformationProps) => {
const [direction, setDirection] = useState<'UP' | 'DOWN'>(isCollapsed ? 'DOWN' : 'UP')
const toggleDirection = () => {
setDirection(direction == 'UP' ? 'DOWN' : 'UP')
}
const handleClick = () => {
toggleDirection()
onClick()
}
return (
)
}
export function CollapsibleMapWithText({
title,
text,
content,
backgroundColor,
}: CollapsibleMapWithTextProps) {
const ref = useRef(null)
const ref2 = useRef(null)
const [contentHeight, setContentHeight] = useState(0)
const [isCollapsed, setIsCollapsed] = useState(true)
const collapse = () => {
setIsCollapsed(true)
ref.current?.scrollIntoView({ behavior: 'smooth' })
}
const toggle = () => {
if (isCollapsed) {
setIsCollapsed(false)
setTimeout(() => {
ref2.current?.scrollIntoView({ behavior: 'smooth'})
}, 500)
} else {
collapse()
}
}
useEffect(() => {
if (ref2.current) {
setContentHeight(ref2.current.scrollHeight)
}
}, [ref2])
return (
)
}