Merge pull request #115 from utopia-os/info-dialog

feat(source): info dialog
This commit is contained in:
antontranelis 2025-02-11 13:55:22 +00:00 committed by GitHub
commit 7bc4e34718
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 5 deletions

View File

@ -27,7 +27,7 @@ export const PopupButton = ({
<Link to={`${url}/${parameterField ? getValue(item, parameterField) : ''}?${params}`}> <Link to={`${url}/${parameterField ? getValue(item, parameterField) : ''}?${params}`}>
<button <button
style={{ style={{
backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : item && getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor}`, backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : item && getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor ? item?.layer?.markerDefaultColor : '#000'}`,
}} }}
className='tw-btn tw-text-white tw-btn-sm tw-float-right tw-mt-1' className='tw-btn tw-text-white tw-btn-sm tw-float-right tw-mt-1'
> >

View File

@ -19,6 +19,7 @@ function UtopiaMap({
showGratitudeControl = false, showGratitudeControl = false,
showLayerControl = true, showLayerControl = true,
infoText, infoText,
donationWidget,
}: UtopiaMapProps) { }: UtopiaMapProps) {
return ( return (
<ContextWrapper> <ContextWrapper>
@ -35,6 +36,7 @@ function UtopiaMap({
showGratitudeControl={showGratitudeControl} showGratitudeControl={showGratitudeControl}
showLayerControl={showLayerControl} showLayerControl={showLayerControl}
infoText={infoText} infoText={infoText}
donationWidget={donationWidget}
> >
{children} {children}
</UtopiaMapInner> </UtopiaMapInner>

View File

@ -33,6 +33,7 @@ import { GratitudeControl } from './Subcomponents/Controls/GratitudeControl'
import { LayerControl } from './Subcomponents/Controls/LayerControl' import { LayerControl } from './Subcomponents/Controls/LayerControl'
import { SearchControl } from './Subcomponents/Controls/SearchControl' import { SearchControl } from './Subcomponents/Controls/SearchControl'
import { TagsControl } from './Subcomponents/Controls/TagsControl' import { TagsControl } from './Subcomponents/Controls/TagsControl'
import { PopupButton } from './Subcomponents/ItemPopupComponents/PopupButton'
import { TextView } from './Subcomponents/ItemPopupComponents/TextView' import { TextView } from './Subcomponents/ItemPopupComponents/TextView'
import { SelectPosition } from './Subcomponents/SelectPosition' import { SelectPosition } from './Subcomponents/SelectPosition'
@ -46,7 +47,7 @@ export function UtopiaMapInner({
showFilterControl = false, showFilterControl = false,
showGratitudeControl = false, showGratitudeControl = false,
showLayerControl = true, showLayerControl = true,
infoText, donationWidget,
}: UtopiaMapProps) { }: UtopiaMapProps) {
const selectNewItemPosition = useSelectPosition() const selectNewItemPosition = useSelectPosition()
const setSelectNewItemPosition = useSetSelectPosition() const setSelectNewItemPosition = useSetSelectPosition()
@ -70,10 +71,21 @@ export function UtopiaMapInner({
const init = useRef(false) const init = useRef(false)
useEffect(() => { useEffect(() => {
if (!init.current) { if (!init.current) {
infoText && donationWidget &&
setTimeout(() => { setTimeout(() => {
toast(<TextView rawText={infoText} />, { autoClose: false }) toast(
}, 10000) <>
<TextView rawText={'## Do you like this Map?'} />
<div>
<TextView
rawText={'Support us building free opensource maps and help us grow 🌱☀️'}
/>
<PopupButton url={'https://opencollective.com/utopia-project'} text={'Donate'} />
</div>
</>,
{ autoClose: false },
)
}, 600000)
init.current = true init.current = true
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps

View File

@ -13,4 +13,5 @@ export interface UtopiaMapProps {
showLayerControl?: boolean showLayerControl?: boolean
showGratitudeControl?: boolean showGratitudeControl?: boolean
infoText?: string infoText?: string
donationWidget?: boolean
} }