mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
feat(lib): add Fullscreen Control to UtopiaMap Component (#408)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: antontranelis <31516529+antontranelis@users.noreply.github.com> Co-authored-by: Anton Tranelis <mail@antontranelis.de>
This commit is contained in:
parent
6050903ce5
commit
b25ded083f
@ -86,6 +86,7 @@ function MapContainer({ layers, map }: { layers: LayerProps[]; map: any }) {
|
|||||||
expandLayerControl={map.expand_layer_control}
|
expandLayerControl={map.expand_layer_control}
|
||||||
tileServerUrl={map.tile_server_url}
|
tileServerUrl={map.tile_server_url}
|
||||||
tileServerAttribution={map.tile_server_attribution}
|
tileServerAttribution={map.tile_server_attribution}
|
||||||
|
showFullscreenControl={map.show_fullscreen_control}
|
||||||
>
|
>
|
||||||
{layers &&
|
{layers &&
|
||||||
apis &&
|
apis &&
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 12,
|
"sort": 11,
|
||||||
"special": [
|
"special": [
|
||||||
"alias",
|
"alias",
|
||||||
"no-data",
|
"no-data",
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 15,
|
"sort": 14,
|
||||||
"special": [
|
"special": [
|
||||||
"alias",
|
"alias",
|
||||||
"no-data",
|
"no-data",
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 13,
|
"sort": 12,
|
||||||
"special": null,
|
"special": null,
|
||||||
"translations": null,
|
"translations": null,
|
||||||
"validation": null,
|
"validation": null,
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 10,
|
"sort": 9,
|
||||||
"special": [
|
"special": [
|
||||||
"m2o"
|
"m2o"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 11,
|
"sort": 10,
|
||||||
"special": [
|
"special": [
|
||||||
"cast-boolean"
|
"cast-boolean"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 14,
|
"sort": 13,
|
||||||
"special": [
|
"special": [
|
||||||
"cast-json"
|
"cast-json"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 17,
|
"sort": 16,
|
||||||
"special": [
|
"special": [
|
||||||
"cast-boolean"
|
"cast-boolean"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"collection": "maps",
|
||||||
|
"field": "show_fullscreen_control",
|
||||||
|
"type": "boolean",
|
||||||
|
"meta": {
|
||||||
|
"collection": "maps",
|
||||||
|
"conditions": null,
|
||||||
|
"display": null,
|
||||||
|
"display_options": null,
|
||||||
|
"field": "show_fullscreen_control",
|
||||||
|
"group": "Controls",
|
||||||
|
"hidden": false,
|
||||||
|
"interface": "boolean",
|
||||||
|
"note": null,
|
||||||
|
"options": null,
|
||||||
|
"readonly": false,
|
||||||
|
"required": false,
|
||||||
|
"sort": 6,
|
||||||
|
"special": [
|
||||||
|
"cast-boolean"
|
||||||
|
],
|
||||||
|
"translations": null,
|
||||||
|
"validation": null,
|
||||||
|
"validation_message": null,
|
||||||
|
"width": "half"
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"name": "show_fullscreen_control",
|
||||||
|
"table": "maps",
|
||||||
|
"data_type": "boolean",
|
||||||
|
"default_value": false,
|
||||||
|
"max_length": null,
|
||||||
|
"numeric_precision": null,
|
||||||
|
"numeric_scale": null,
|
||||||
|
"is_nullable": true,
|
||||||
|
"is_unique": false,
|
||||||
|
"is_indexed": false,
|
||||||
|
"is_primary_key": false,
|
||||||
|
"is_generated": false,
|
||||||
|
"generation_expression": null,
|
||||||
|
"has_auto_increment": false,
|
||||||
|
"foreign_key_table": null,
|
||||||
|
"foreign_key_column": null
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"options": null,
|
"options": null,
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 18,
|
"sort": 17,
|
||||||
"special": [
|
"special": [
|
||||||
"cast-boolean"
|
"cast-boolean"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"required": false,
|
"required": false,
|
||||||
"sort": 16,
|
"sort": 15,
|
||||||
"special": [
|
"special": [
|
||||||
"alias",
|
"alias",
|
||||||
"no-data",
|
"no-data",
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
import ArrowsPointingInIcon from '@heroicons/react/24/outline/ArrowsPointingInIcon'
|
||||||
|
import ArrowsPointingOutIcon from '@heroicons/react/24/outline/ArrowsPointingOutIcon'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
export const FullscreenControl = () => {
|
||||||
|
const [isFullscreen, setIsFullscreen] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleFullscreenChange = () => {
|
||||||
|
setIsFullscreen(document.fullscreenElement != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('fullscreenchange', handleFullscreenChange)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('fullscreenchange', handleFullscreenChange)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const toggleFullscreen = () => {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
void document.documentElement.requestFullscreen()
|
||||||
|
} else {
|
||||||
|
void document.exitFullscreen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='tw:card tw:bg-base-100 tw:shadow-xl tw:mt-2 tw:w-fit'>
|
||||||
|
<div
|
||||||
|
className='tw:card-body tw:hover:bg-slate-300 tw:card tw:p-2 tw:h-10 tw:w-10 tw:transition-all tw:duration-300 tw:hover:cursor-pointer'
|
||||||
|
onClick={toggleFullscreen}
|
||||||
|
>
|
||||||
|
{isFullscreen ? (
|
||||||
|
<ArrowsPointingInIcon className='tw:stroke-[2.5]' />
|
||||||
|
) : (
|
||||||
|
<ArrowsPointingOutIcon className='tw:stroke-[2.5]' />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -53,6 +53,7 @@ function UtopiaMap({
|
|||||||
showLayerControl = true,
|
showLayerControl = true,
|
||||||
showZoomControl = false,
|
showZoomControl = false,
|
||||||
showThemeControl = false,
|
showThemeControl = false,
|
||||||
|
showFullscreenControl = false,
|
||||||
defaultTheme,
|
defaultTheme,
|
||||||
donationWidget,
|
donationWidget,
|
||||||
expandLayerControl,
|
expandLayerControl,
|
||||||
@ -81,6 +82,8 @@ function UtopiaMap({
|
|||||||
showZoomControl?: boolean
|
showZoomControl?: boolean
|
||||||
/** show a widget to switch the theme */
|
/** show a widget to switch the theme */
|
||||||
showThemeControl?: boolean
|
showThemeControl?: boolean
|
||||||
|
/** show fullscreen control widget (default false) */
|
||||||
|
showFullscreenControl?: boolean
|
||||||
/** the defaut theme */
|
/** the defaut theme */
|
||||||
defaultTheme?: string
|
defaultTheme?: string
|
||||||
/** ask to donate to the Utopia Project OpenCollective campaign (default false) */
|
/** ask to donate to the Utopia Project OpenCollective campaign (default false) */
|
||||||
@ -106,6 +109,7 @@ function UtopiaMap({
|
|||||||
showFilterControl={showFilterControl}
|
showFilterControl={showFilterControl}
|
||||||
showGratitudeControl={showGratitudeControl}
|
showGratitudeControl={showGratitudeControl}
|
||||||
showLayerControl={showLayerControl}
|
showLayerControl={showLayerControl}
|
||||||
|
showFullscreenControl={showFullscreenControl}
|
||||||
donationWidget={donationWidget}
|
donationWidget={donationWidget}
|
||||||
showThemeControl={showThemeControl}
|
showThemeControl={showThemeControl}
|
||||||
defaultTheme={defaultTheme}
|
defaultTheme={defaultTheme}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import { useTags } from './hooks/useTags'
|
|||||||
import AddButton from './Subcomponents/AddButton'
|
import AddButton from './Subcomponents/AddButton'
|
||||||
import { Control } from './Subcomponents/Controls/Control'
|
import { Control } from './Subcomponents/Controls/Control'
|
||||||
import { FilterControl } from './Subcomponents/Controls/FilterControl'
|
import { FilterControl } from './Subcomponents/Controls/FilterControl'
|
||||||
|
import { FullscreenControl } from './Subcomponents/Controls/FullscreenControl'
|
||||||
import { GratitudeControl } from './Subcomponents/Controls/GratitudeControl'
|
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'
|
||||||
@ -51,6 +52,7 @@ export function UtopiaMapInner({
|
|||||||
showFilterControl = false,
|
showFilterControl = false,
|
||||||
showGratitudeControl = false,
|
showGratitudeControl = false,
|
||||||
showLayerControl = true,
|
showLayerControl = true,
|
||||||
|
showFullscreenControl = false,
|
||||||
showThemeControl = false,
|
showThemeControl = false,
|
||||||
defaultTheme = '',
|
defaultTheme = '',
|
||||||
donationWidget,
|
donationWidget,
|
||||||
@ -63,6 +65,7 @@ export function UtopiaMapInner({
|
|||||||
showFilterControl?: boolean
|
showFilterControl?: boolean
|
||||||
showLayerControl?: boolean
|
showLayerControl?: boolean
|
||||||
showGratitudeControl?: boolean
|
showGratitudeControl?: boolean
|
||||||
|
showFullscreenControl?: boolean
|
||||||
donationWidget?: boolean
|
donationWidget?: boolean
|
||||||
showThemeControl?: boolean
|
showThemeControl?: boolean
|
||||||
defaultTheme?: string
|
defaultTheme?: string
|
||||||
@ -276,6 +279,7 @@ export function UtopiaMapInner({
|
|||||||
<TagsControl />
|
<TagsControl />
|
||||||
</Control>
|
</Control>
|
||||||
<Control position='bottomLeft' zIndex='999' absolute>
|
<Control position='bottomLeft' zIndex='999' absolute>
|
||||||
|
{showFullscreenControl && <FullscreenControl />}
|
||||||
{showFilterControl && <FilterControl />}
|
{showFilterControl && <FilterControl />}
|
||||||
{showLayerControl && <LayerControl expandLayerControl={expandLayerControl ?? false} />}
|
{showLayerControl && <LayerControl expandLayerControl={expandLayerControl ?? false} />}
|
||||||
{showGratitudeControl && <GratitudeControl />}
|
{showGratitudeControl && <GratitudeControl />}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user