Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 56018f1c

Přidáno uživatelem Václav Honzík před asi 2 roky(ů)

right click popup menu

re #9741

Zobrazit rozdíly:

frontend/src/features/Theme/ThemeWrapper.tsx
8 8
    children: ReactNode
9 9
}
10 10

  
11
const ThemeWrapper: FunctionComponent<ThemeWrapperProps> = ({ children }) => {
12
    const lightThemePalette = {
13
        primary: {
14
            main: '#A28253',
15
        },
16
        secondary: {
17
            main: '#E3DBCF',
18
        },
19
        selected: {
20
            main: '#C0C0C0'
21
        }
22
    }
11
export const lightThemePalette = {
12
    primary: {
13
        main: '#A28253',
14
    },
15
    secondary: {
16
        main: '#E3DBCF',
17
    },
18
    selected: {
19
        main: '#C0C0C0',
20
    },
21
}
23 22

  
24
    const darkThemePalette = {
25
        primary: {
26
            main: '#e0bb84',
27
        },
28
        secondary: {
29
            main: '#E3DBCF',
30
        },
31
    }
23
export const darkThemePalette = {
24
    primary: {
25
        main: '#e0bb84',
26
    },
27
    secondary: {
28
        main: '#E3DBCF',
29
    },
30
}
32 31

  
33
    const getPalette = (paletteMode: PaletteMode) => {
34
        switch (paletteMode) {
35
            case 'light':
36
                return lightThemePalette
37
            case 'dark':
38
                return darkThemePalette
39
            default:
40
                return lightThemePalette
41
        }
32
export const getPalette = (paletteMode: PaletteMode) => {
33
    switch (paletteMode) {
34
        case 'light':
35
            return lightThemePalette
36
        case 'dark':
37
            return darkThemePalette
38
        default:
39
            return lightThemePalette
42 40
    }
41
}
43 42

  
44
    const buildTheme = (paletteMode: PaletteMode) =>
43
export const buildTheme = (paletteMode: PaletteMode) =>
45 44
        createTheme({
46 45
            palette: {
47 46
                mode: paletteMode,
......
66 65
            },
67 66
        })
68 67

  
68
const ThemeWrapper: FunctionComponent<ThemeWrapperProps> = ({ children }) => {
69
    
70

  
69 71
    const paletteMode = useSelector(
70 72
        (state: RootState) => state.theme.paletteMode
71 73
    )
frontend/src/features/TrackingTool/DraggableList/DraggableListItem.tsx
50 50
                    {...provided.draggableProps}
51 51
                    {...provided.dragHandleProps}
52 52
                    sx={{
53
                        background: snapshot.isDragging ? 'rgb(235,235,235)' : 'inherit',
53
                        background: snapshot.isDragging
54
                            ? 'rgb(235,235,235)'
55
                            : 'inherit',
54 56
                    }}
55 57
                >
56 58
                    <ListItemAvatar>
frontend/src/features/TrackingTool/Map/RightClickPopupMenu.tsx
1
import { LeafletMouseEvent } from 'leaflet'
2
import { Fragment, useState } from 'react'
3
import { Popup, useMap, useMapEvents } from 'react-leaflet'
4

  
5
import * as React from 'react'
6
import Divider from '@mui/material/Divider'
7
import Paper from '@mui/material/Paper'
8
import MenuList from '@mui/material/MenuList'
9
import MenuItem from '@mui/material/MenuItem'
10
import ListItemText from '@mui/material/ListItemText'
11
import ListItemIcon from '@mui/material/ListItemIcon'
12
import Typography from '@mui/material/Typography'
13
import ContentCut from '@mui/icons-material/ContentCut'
14
import ContentCopy from '@mui/icons-material/ContentCopy'
15
import ContentPaste from '@mui/icons-material/ContentPaste'
16
import Cloud from '@mui/icons-material/Cloud'
17

  
18
export function IconMenu() {
19
    return (
20
        // <Paper sx={{ width: 320, maxWidth: '100%' }}>
21
            <MenuList>
22
                <MenuItem>
23
                    <ListItemIcon>
24
                        <ContentCut fontSize="small" />
25
                    </ListItemIcon>
26
                    <ListItemText>Cut</ListItemText>
27
                    <Typography variant="body2" color="text.secondary">
28
                        ⌘X
29
                    </Typography>
30
                </MenuItem>
31
                <MenuItem>
32
                    <ListItemIcon>
33
                        <ContentCopy fontSize="small" />
34
                    </ListItemIcon>
35
                    <ListItemText>Copy</ListItemText>
36
                    <Typography variant="body2" color="text.secondary">
37
                        ⌘C
38
                    </Typography>
39
                </MenuItem>
40
                <MenuItem>
41
                    <ListItemIcon>
42
                        <ContentPaste fontSize="small" />
43
                    </ListItemIcon>
44
                    <ListItemText>Paste</ListItemText>
45
                    <Typography variant="body2" color="text.secondary">
46
                        ⌘V
47
                    </Typography>
48
                </MenuItem>
49
                <Divider />
50
                <MenuItem>
51
                    <ListItemIcon>
52
                        <Cloud fontSize="small" />
53
                    </ListItemIcon>
54
                    <ListItemText>Web Clipboard</ListItemText>
55
                </MenuItem>
56
            </MenuList>
57
        // </Paper>
58
    )
59
}
60

  
61
const RightClickPopupMenu = () => {
62
    const [open, setOpen] = useState(false)
63
    const [latLng, setLatLng] = useState<[number, number]>([0, 0])
64
    const mapEvents = useMapEvents({
65
        contextmenu: (e: LeafletMouseEvent) => {
66
            setLatLng([e.latlng.lat, e.latlng.lng])
67
            setOpen(true)
68
        },
69
    })
70

  
71
    return (
72
        <Fragment>
73
            {open && <Popup onClose={() => setOpen(false)} position={latLng}>
74
                <IconMenu />
75
                </Popup>}
76
        </Fragment>
77
    )
78
}
79

  
80
export default RightClickPopupMenu
frontend/src/features/TrackingTool/TrackingTool.tsx
4 4
    CardContent,
5 5
    Grid,
6 6
    Stack,
7
    ThemeProvider,
7 8
    Typography,
8 9
} from '@mui/material'
9 10
import { Fragment, useEffect, useRef } from 'react'
......
23 24
import GeoJsonImportDialog from './Upload/GeoJsonImportDialog'
24 25
import ProcessedTextDisplay from './ProcessedText/ProcessedTextDisplay'
25 26
import DraggableMarkerList from './DraggableList/DraggableMarkerList'
27
import RightClickPopupMenu from './Map/RightClickPopupMenu'
28
import { buildTheme, getPalette } from '../Theme/ThemeWrapper'
29

  
30
const mapTheme = buildTheme('light')
26 31

  
27 32
// Page with tracking tool
28 33
const TrackingTool = () => {
......
136 141
                        width: '100%',
137 142
                    }}
138 143
                >
139
                    <MapContainer
140
                        center={[mapCenter[0], mapCenter[1]]}
141
                        zoom={mapConfig.defaultZoom}
142
                        style={{ height: '100%', minHeight: '100%' }}
143
                        whenCreated={(map) => {
144
                            mapRef.current = map
145
                        }}
146
                    >
147
                        <TileLayer
148
                            attribution={mapConfig.attribution}
149
                            url={mapConfig.url}
150
                        />
151
                        {pathVariants?.map((pathVariant, idx) => (
152
                            <MapPath idx={idx} />
153
                        ))}
154
                    </MapContainer>
144
                    <ThemeProvider theme={mapTheme}>
145
                        <MapContainer
146
                            center={[mapCenter[0], mapCenter[1]]}
147
                            zoom={mapConfig.defaultZoom}
148
                            style={{ height: '100%', minHeight: '100%' }}
149
                            whenCreated={(map) => {
150
                                mapRef.current = map
151
                            }}
152
                        >
153
                            <TileLayer
154
                                attribution={mapConfig.attribution}
155
                                url={mapConfig.url}
156
                            />
157
                            {pathVariants?.map((pathVariant, idx) => (
158
                                <MapPath idx={idx} />
159
                            ))}
160
                            <RightClickPopupMenu />
161
                        </MapContainer>
162
                    </ThemeProvider>
155 163
                </Grid>
156 164
                <Grid container sx={{ mt: 1, mb: 20 }} spacing={1}>
157 165
                    <Grid item xs={12} md={6}>

Také k dispozici: Unified diff