174 lines
6.9 KiB
JavaScript
174 lines
6.9 KiB
JavaScript
import { Fragment, useContext, useEffect, useRef, useState } from "react"
|
|
import { useRouter } from "next/router"
|
|
import { Event, getAllLocalStorageItems, getRefValue, getRefValues, isTrue, preventDefault, refs, set_val, spreadArraysOrObjects, uploadFiles, useEventLoop } from "/utils/state"
|
|
import { ColorModeContext, EventLoopContext, initialEvents, StateContext } from "/utils/context.js"
|
|
import "focus-visible/dist/focus-visible"
|
|
import { Box, Heading, HStack, Image, Input, Link, Menu, MenuButton, MenuDivider, MenuItem, MenuList, Modal, ModalBody, ModalContent, ModalHeader, ModalOverlay, Spacer, Text, VStack } from "@chakra-ui/react"
|
|
import { getEventURL } from "/utils/state.js"
|
|
import NextLink from "next/link"
|
|
import ReactDropzone from "react-dropzone"
|
|
import { HamburgerIcon } from "@chakra-ui/icons"
|
|
import NextHead from "next/head"
|
|
|
|
|
|
|
|
export default function Component() {
|
|
const state = useContext(StateContext)
|
|
const router = useRouter()
|
|
const [ colorMode, toggleColorMode ] = useContext(ColorModeContext)
|
|
const focusRef = useRef();
|
|
|
|
// Main event loop.
|
|
const [addEvents, connectError] = useContext(EventLoopContext)
|
|
|
|
// Set focus to the specified element.
|
|
useEffect(() => {
|
|
if (focusRef.current) {
|
|
focusRef.current.focus();
|
|
}
|
|
})
|
|
|
|
// Route after the initial page hydration.
|
|
useEffect(() => {
|
|
const change_complete = () => addEvents(initialEvents())
|
|
router.events.on('routeChangeComplete', change_complete)
|
|
return () => {
|
|
router.events.off('routeChangeComplete', change_complete)
|
|
}
|
|
}, [router])
|
|
|
|
const [files, setFiles] = useState([]);
|
|
|
|
return (
|
|
<Fragment>
|
|
<Fragment>
|
|
{isTrue(connectError !== null) ? (
|
|
<Fragment>
|
|
<Modal isOpen={connectError !== null}>
|
|
<ModalOverlay>
|
|
<ModalContent>
|
|
<ModalHeader>
|
|
{`Connection Error`}
|
|
</ModalHeader>
|
|
<ModalBody>
|
|
<Text>
|
|
{`Cannot connect to server: `}
|
|
{(connectError !== null) ? connectError.message : ''}
|
|
{`. Check if server is reachable at `}
|
|
{getEventURL().href}
|
|
</Text>
|
|
</ModalBody>
|
|
</ModalContent>
|
|
</ModalOverlay>
|
|
</Modal>
|
|
</Fragment>
|
|
) : (
|
|
<Fragment/>
|
|
)}
|
|
</Fragment>
|
|
<HStack alignItems={`flex-start`} sx={{"transition": "left 0.5s, width 0.5s", "position": "relative"}}>
|
|
<Box sx={{"display": ["none", "none", "block"], "minWidth": "20em", "height": "100%", "position": "sticky", "top": "0px", "borderRight": "1px solid #F4F3F6"}}>
|
|
<VStack sx={{"height": "100em"}}>
|
|
<HStack sx={{"width": "100%", "borderBottom": "1px solid #F4F3F6", "padding": "1em"}}>
|
|
<Image src={`/icon.png`} sx={{"height": "4.5em"}}/>
|
|
<Spacer/>
|
|
</HStack>
|
|
<VStack alignItems={`flex-start`} sx={{"width": "100%", "overflowY": "auto", "padding": "1em"}}>
|
|
<Link as={NextLink} href={`/`} sx={{"width": "100%"}}>
|
|
<HStack sx={{"bg": isTrue((state.router.page.path === "/strona g\\u0142\\u00f3wna") || (((state.router.page.path === "/") && "Strona g\\u0142\\u00f3wna") === "Home")) ? `#fff0f7` : `transparent`, "color": isTrue((state.router.page.path === "/strona g\\u0142\\u00f3wna") || (((state.router.page.path === "/") && "Strona g\\u0142\\u00f3wna") === "Home")) ? `#1A1060` : `black`, "borderRadius": "0.375rem", "boxShadow": "0px 0px 0px 1px rgba(84, 82, 95, 0.14)", "width": "100%", "paddingX": "1.3em", "height": "2.5em"}}>
|
|
<Image src={`/home-icon.png`} sx={{"height": "2.5em", "padding": "0.5em"}}/>
|
|
<Text>
|
|
{`Strona główna`}
|
|
</Text>
|
|
</HStack>
|
|
</Link>
|
|
<Link as={NextLink} href={`/dashboard`} sx={{"width": "100%"}}>
|
|
<HStack sx={{"bg": isTrue((state.router.page.path === "/kontakt") || (((state.router.page.path === "/") && "Kontakt") === "Home")) ? `#fff0f7` : `transparent`, "color": isTrue((state.router.page.path === "/kontakt") || (((state.router.page.path === "/") && "Kontakt") === "Home")) ? `#1A1060` : `black`, "borderRadius": "0.375rem", "boxShadow": "0px 0px 0px 1px rgba(84, 82, 95, 0.14)", "width": "100%", "paddingX": "1.3em", "height": "2.5em"}}>
|
|
<Image src={`/contact-icon.png`} sx={{"height": "2.5em", "padding": "0.5em"}}/>
|
|
<Text>
|
|
{`Kontakt`}
|
|
</Text>
|
|
</HStack>
|
|
</Link>
|
|
<Link as={NextLink} href={`/settings`} sx={{"width": "100%"}}>
|
|
<HStack sx={{"bg": isTrue((state.router.page.path === "/zdj\\u0119cie") || (((state.router.page.path === "/") && "Zdj\\u0119cie") === "Home")) ? `#fff0f7` : `transparent`, "color": isTrue((state.router.page.path === "/zdj\\u0119cie") || (((state.router.page.path === "/") && "Zdj\\u0119cie") === "Home")) ? `#1A1060` : `black`, "borderRadius": "0.375rem", "boxShadow": "0px 0px 0px 1px rgba(84, 82, 95, 0.14)", "width": "100%", "paddingX": "1.3em", "height": "2.5em"}}>
|
|
<Image src={`/image-icon.png`} sx={{"height": "2.5em", "padding": "0.5em"}}/>
|
|
<Text>
|
|
{`Zdjęcie`}
|
|
</Text>
|
|
</HStack>
|
|
</Link>
|
|
</VStack>
|
|
<Spacer/>
|
|
</VStack>
|
|
</Box>
|
|
<Box sx={{"paddingTop": "5em", "paddingX": ["auto", "2em"], "flex": "1"}}>
|
|
<Box sx={{"alignItems": "flex-start", "boxShadow": "0px 0px 0px 1px rgba(84, 82, 95, 0.14)", "borderRadius": "0.375rem", "padding": "1em", "marginBottom": "2em"}}>
|
|
<VStack>
|
|
<Heading sx={{"fontSize": "3em", "marginBottom": "25px", "backgroundImage": "linear-gradient(271.68deg, #7566fe 0.75%, #f96caf 88.52%)", "backgroundClip": "text", "padding": "10px"}}>
|
|
{`BlurMe`}
|
|
</Heading>
|
|
<Text sx={{"fontSize": "1.2em"}}>
|
|
{`Dodaj zdjęcie, które chcesz zanonimizować`}
|
|
</Text>
|
|
<ReactDropzone multiple={true} onDrop={e => setFiles((files) => e)}>
|
|
{({ getRootProps, getInputProps }) => (
|
|
<Box sx={{"border": "1px dotted rgb(107,99,246)", "padding": "5em"}} {...getRootProps()}>
|
|
<Input type={`file`} {...getInputProps()}/>
|
|
<Text>
|
|
{`Drag and drop files here or click to select files`}
|
|
</Text>
|
|
</Box>
|
|
)}
|
|
</ReactDropzone>
|
|
</VStack>
|
|
</Box>
|
|
</Box>
|
|
<Box sx={{"position": "fixed", "right": "1.5em", "top": "1.5em", "zIndex": "500"}}>
|
|
<Menu>
|
|
<MenuButton sx={{"width": "3em", "height": "3em", "backgroundColor": "white", "border": "1px solid #F4F3F6", "borderRadius": "0.375rem"}}>
|
|
<HamburgerIcon sx={{"size": "4em", "color": "black"}}/>
|
|
</MenuButton>
|
|
<MenuList>
|
|
<MenuItem sx={{"_hover": {"bg": "#fff0f7"}}}>
|
|
<Link as={NextLink} href={`/`} sx={{"width": "100%"}}>
|
|
{`Strona główna`}
|
|
</Link>
|
|
</MenuItem>
|
|
<MenuItem sx={{"_hover": {"bg": "#fff0f7"}}}>
|
|
<Link as={NextLink} href={`/dashboard`} sx={{"width": "100%"}}>
|
|
{`Kontakt`}
|
|
</Link>
|
|
</MenuItem>
|
|
<MenuItem sx={{"_hover": {"bg": "#fff0f7"}}}>
|
|
<Link as={NextLink} href={`/settings`} sx={{"width": "100%"}}>
|
|
{`Zdjęcie`}
|
|
</Link>
|
|
</MenuItem>
|
|
<MenuDivider/>
|
|
<MenuItem sx={{"_hover": {"bg": "#fff0f7"}}}>
|
|
<Link as={NextLink} href={`/about`} sx={{"width": "100%"}}>
|
|
{`About`}
|
|
</Link>
|
|
</MenuItem>
|
|
<MenuItem sx={{"_hover": {"bg": "#fff0f7"}}}>
|
|
<Link as={NextLink} href={`mailto:founders@=reflex.dev`} sx={{"width": "100%"}}>
|
|
{`Contact`}
|
|
</Link>
|
|
</MenuItem>
|
|
</MenuList>
|
|
</Menu>
|
|
</Box>
|
|
</HStack>
|
|
<NextHead>
|
|
<title>
|
|
{`Zdjęcie`}
|
|
</title>
|
|
<meta content={`A Reflex app.`} name={`description`}/>
|
|
<meta content={`/image-icon.png`} property={`og:image`}/>
|
|
<meta content={`width=device-width, shrink-to-fit=no, initial-scale=1`} name={`viewport`}/>
|
|
</NextHead>
|
|
</Fragment>
|
|
)
|
|
}
|