Added power button and external link

This commit is contained in:
z0ccc 2022-07-21 22:44:28 -04:00
parent 8f59d35283
commit 1408e55894
3 changed files with 70 additions and 54 deletions

View file

@ -1,24 +1,24 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { Box } from 'theme-ui' import { Box, Flex, Button } from 'theme-ui'
import LocationInput from './LocationInput' import LocationInput from './LocationInput'
import ConfigurationSelect from './ConfigurationSelect' import ConfigurationSelect from './ConfigurationSelect'
import IPData from './IPData' import IPData from './IPData'
import getIP from '../../utils/getIP' import getIP from '../../utils/getIP'
import { Power } from 'react-feather'
const LocationPage = () => { const LocationPage = () => {
const [ip, setIP] = useState(null) const [on, setOn] = useState(true)
const [configuration, setConfiguration] = useState('default')
useEffect(() => { // useEffect(() => {
chrome.storage.sync.get(['configuration', 'ipData'], (result) => { // chrome.storage.sync.get(['configuration', 'ipData'], (result) => {
result.configuration && setConfiguration(result.configuration) // result.configuration && setConfiguration(result.configuration)
if (result.ipData) { // if (result.ipData) {
setIP(result.ipData) // setIP(result.ipData)
} else { // } else {
Promise.resolve(getIP()).then((ipData) => setIP(ipData)) // Promise.resolve(getIP()).then((ipData) => setIP(ipData))
} // }
}) // })
}, []) // }, [])
return ( return (
<Box <Box
@ -27,40 +27,34 @@ const LocationPage = () => {
width: '100%', width: '100%',
}} }}
> >
<Box sx={{ fontSize: '20px', mb: '8px' }}>Location</Box> <Flex
<ConfigurationSelect sx={{ justifyContent: 'center', alignItems: 'center', height: '100%' }}
configuration={configuration} >
setConfiguration={setConfiguration} <Button
/> variant="power"
{configuration === 'match' && <IPData ip={ip} setIP={setIP} />} onClick={() => {
<LocationInput setOn(!on)
type="timezone" }}
title="Timezone" sx={{
ip={ip} bg: on ? 'green' : 'red',
configuration={configuration} '&:hover': {
setConfiguration={setConfiguration} bg: on ? 'greenDark' : 'redDark',
/> },
<LocationInput transition: 'background 0.25s',
type="locale" }}
title="Locale" >
ip={ip} <Box
configuration={configuration} sx={{
setConfiguration={setConfiguration} height: '108px',
/> width: '100px',
<LocationInput transform: on ? 'rotate(0deg)' : 'rotate(-180deg)',
type="lat" transition: 'transform 0.25s',
title="Latitude" }}
ip={ip} >
configuration={configuration} <Power size={100} />
setConfiguration={setConfiguration} </Box>
/> </Button>
<LocationInput </Flex>
type="lon"
title="Longitude"
ip={ip}
configuration={configuration}
setConfiguration={setConfiguration}
/>
</Box> </Box>
) )
} }

View file

@ -1,12 +1,12 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import { ThemeProvider, Flex } from 'theme-ui' import { ThemeProvider, Flex } from 'theme-ui'
import { theme } from '../../theme' import { theme } from '../../theme'
import { Home, MapPin, Globe, Command, List } from 'react-feather' import { Home, MapPin, Globe, Command, List, ExternalLink } from 'react-feather'
import TabItem from './TabItem' import TabItem from './TabItem'
import Page from './Page' import Page from './Page'
const Popup = () => { const Popup = () => {
const [tab, setTab] = useState(2) const [tab, setTab] = useState(1)
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
@ -24,11 +24,15 @@ const Popup = () => {
flexDirection: 'column', flexDirection: 'column',
}} }}
> >
<TabItem Icon={Home} onClick={() => setTab(0)} /> {/* <TabItem Icon={Home} onClick={() => setTab(0)} /> */}
<TabItem Icon={MapPin} onClick={() => setTab(1)} /> <TabItem Icon={MapPin} onClick={() => setTab(1)} />
<TabItem Icon={Globe} onClick={() => setTab(2)} /> <TabItem Icon={Globe} onClick={() => setTab(2)} />
<TabItem Icon={Command} onClick={() => setTab(3)} /> {/* <TabItem Icon={Command} onClick={() => setTab(3)} /> */}
<TabItem Icon={List} onClick={() => setTab(4)} /> <TabItem Icon={List} onClick={() => setTab(3)} />
<TabItem
Icon={ExternalLink}
onClick={() => window.open('https://vytal.io')}
/>
</Flex> </Flex>
<Page tab={tab} /> <Page tab={tab} />
</Flex> </Flex>

View file

@ -4,8 +4,13 @@ export const theme: Theme = {
colors: { colors: {
text: '#333333', text: '#333333',
background: '#FDFDFD', background: '#FDFDFD',
primary: '#a965d1', primary: '#a55eea',
primaryDark: '#8750A7', primaryDark: '#9454d2',
red: '#fc5c65',
redDark: '#e2525a',
green: '#26de81',
greenDark: '#22c774',
grey: '#BCC2C9',
}, },
styles: { styles: {
root: { root: {
@ -48,5 +53,18 @@ export const theme: Theme = {
bg: 'primaryDark', bg: 'primaryDark',
}, },
}, },
power: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
py: '12px',
px: '16px',
color: 'background',
borderRadius: '50%',
cursor: 'pointer',
// '&:hover': {
// bg: 'primaryDark',
// },
},
}, },
} }