-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add reusable dashboard header; implement profile page design #757
- Loading branch information
1 parent
46a8879
commit 3154fcb
Showing
9 changed files
with
181 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ArrowBackIcon, ChevronRightIcon, CopyIcon } from '@chakra-ui/icons'; | ||
import { | ||
Box, | ||
Input, | ||
InputGroup, | ||
InputRightElement, | ||
Text, | ||
Tooltip, | ||
useBreakpointValue, | ||
useToast, | ||
} from '@chakra-ui/react'; | ||
import { useRouter } from 'next/router'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface DashboardHeaderProps { | ||
pageTitle: string; | ||
} | ||
|
||
const DashboardHeader: React.FC<DashboardHeaderProps> = function Dashboard({ pageTitle }) { | ||
const router = useRouter(); | ||
const { t } = useTranslation('dashboard'); | ||
const [apiKey, setApiKey] = useState(''); | ||
const toast = useToast(); | ||
const ml = useBreakpointValue({ base: 10, lg: 270 }); | ||
const pageHeaderDisplay = useBreakpointValue({ base: 'block', lg: 'flex' }); | ||
|
||
const handleGoBack = () => { | ||
router.back(); | ||
}; | ||
|
||
const handleCopyApiKey = () => { | ||
setApiKey('example-api-key'); | ||
navigator.clipboard.writeText(apiKey); | ||
toast({ | ||
title: t('API key copied'), | ||
description: t('Your API key has been copied to your clipboard.'), | ||
status: 'success', | ||
duration: 5000, | ||
isClosable: true, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box ml={ml} pt={5} display="flex"> | ||
<Text | ||
fontSize="lg" | ||
fontFamily="monospace" | ||
color="blue.400" | ||
fontWeight="bold" | ||
marginRight={3} | ||
cursor="pointer" | ||
onClick={handleGoBack} | ||
> | ||
<ArrowBackIcon boxSize="1rem" marginRight="5px" /> | ||
{t('Back')} | ||
</Text> | ||
| | ||
<Text fontSize="md" fontFamily="monospace" marginLeft={3}> | ||
{t('Dashboard')} <ChevronRightIcon /> {t('App one')} | ||
</Text> | ||
</Box> | ||
<Box ml={ml} pt={4} pr={10} display={pageHeaderDisplay} justifyContent="space-between"> | ||
<Text fontSize="2xl" fontWeight="bold"> | ||
{pageTitle} | ||
</Text> | ||
|
||
<InputGroup style={{ maxWidth: '300px', margin: '0 auto', justifyContent: 'right', marginRight: 0 }}> | ||
{/* TODO: Remove hardcoded value */} | ||
<Input value="00y23804y29b3d9048hend" background="gray.200" padding={6} readOnly /> | ||
<InputRightElement padding={6} onClick={handleCopyApiKey} cursor="pointer"> | ||
<Tooltip label={t('Copy API key')}> | ||
<CopyIcon /> | ||
</Tooltip> | ||
</InputRightElement> | ||
</InputGroup> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default DashboardHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import DashboardHeader from './DashboardHeader'; | ||
|
||
export default DashboardHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { Box, Text, useBreakpointValue } from '@chakra-ui/react'; | ||
|
||
const UserInfo: React.FC = function UserInfo() { | ||
const ml = useBreakpointValue({ base: 10, lg: 260 }); | ||
|
||
return ( | ||
<Box ml={ml} p="3"> | ||
<Box display="flex"> | ||
<Text fontSize="md" fontWeight="bold" fontFamily="monospace" marginTop={3}> | ||
Name: | ||
</Text> | ||
<Text fontSize="md" ml={3} fontWeight="medium" fontFamily="monospace" marginTop={3}> | ||
David Egorp | ||
</Text> | ||
</Box> | ||
<Box display="flex"> | ||
<Text fontSize="md" fontWeight="bold" fontFamily="monospace" marginTop={3}> | ||
Email: | ||
</Text> | ||
<Text fontSize="md" ml={3} fontWeight="medium" fontFamily="monospace" marginTop={3}> | ||
[email protected] | ||
</Text> | ||
</Box> | ||
<Box display="flex"> | ||
<Text fontSize="md" fontWeight="bold" fontFamily="monospace" marginTop={3}> | ||
Date joined: | ||
</Text> | ||
<Text fontSize="md" ml={3} fontWeight="medium" fontFamily="monospace" marginTop={3}> | ||
20 May, 2023 | ||
</Text> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default UserInfo; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Box, useColorModeValue } from '@chakra-ui/react'; | ||
import Sidebar from './components/Sidebar'; | ||
import DashboardHeader from './components/DashboardHeader'; | ||
import UserInfo from './components/UserInformation'; | ||
|
||
const Profile: React.FC = function Profile() { | ||
const { t } = useTranslation('dashboard'); | ||
|
||
return ( | ||
<Box minH="100vh" bg={useColorModeValue('white', 'white')}> | ||
<Sidebar /> | ||
<DashboardHeader pageTitle={t('Profile')} /> | ||
<UserInfo /> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Profile; |