Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/UI improvements #72

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>LogID</title>
</head>
<body>
<div id="root"></div>
Expand Down
84 changes: 49 additions & 35 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import './App.css';
import '@rainbow-me/rainbowkit/styles.css';

import React from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import { useMediaQuery } from '@mui/material';
import {
lightTheme,
RainbowKitAuthenticationProvider,
RainbowKitProvider,
} from '@rainbow-me/rainbowkit';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Navigate, Route, Routes } from 'react-router-dom';
import { sepolia } from 'wagmi/chains';
import { baseSepolia } from 'viem/chains';
import { useAccount } from 'wagmi';

import MobileScreensContainer from './components/layouts/MobileScreensContainer';
import { CustomSnackbar } from './components/shared/CustomSnackbar';
import useSiweAuth from './hooks/useSiweAuth';
import DefaultLayout from './layouts/DefaultLayout';
Expand All @@ -34,50 +36,62 @@ const queryClient = new QueryClient({
});

const App: React.FC = () => {
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));

const { authStatus, authenticationAdapter } = useSiweAuth();
const { chainId } = useAccount();

globalThis.Buffer = Buffer;

if (isSmallScreen) {
return <MobileScreensContainer />;
}

return (
<QueryClientProvider client={queryClient}>
<RainbowKitAuthenticationProvider
adapter={authenticationAdapter}
status={authStatus}
>
<RainbowKitProvider initialChain={sepolia}>
<ThemeProvider theme={theme}>
<CssBaseline />
<Routes>
<RainbowKitProvider
initialChain={chainId ?? baseSepolia}
theme={lightTheme({
accentColor: '#4200FF',
})}
appInfo={{
appName: 'LogID',
}}
>
<Routes>
<Route
path="/auth/login"
element={
authStatus === 'authenticated' ? (
<Navigate to="/" replace />
) : (
<Login />
)
}
/>
<Route
element={
<ProtectedRoute>
<DefaultLayout />
</ProtectedRoute>
}
>
<Route path="/" element={<Navigate to="/identifiers" />} />
<Route path="/identifiers" element={<Identifiers />} />
<Route
path="/auth/login"
element={
authStatus === 'authenticated' ? (
<Navigate to="/" replace />
) : (
<Login />
)
}
path="identifiers/:provider/attestation"
element={<Attestation />}
/>
<Route
element={
<ProtectedRoute>
<DefaultLayout />
</ProtectedRoute>
}
>
<Route path="/" element={<Navigate to="/identifiers" />} />
<Route path="/identifiers" element={<Identifiers />} />
<Route
path="identifiers/:provider/attestation"
element={<Attestation />}
/>
<Route path="/permissions" element={<Permissions />} />
</Route>
<Route path="/callback" element={<Callback />} />
<Route path="*" element={<div>Not found</div>} />
</Routes>
<CustomSnackbar />
</ThemeProvider>
<Route path="/permissions" element={<Permissions />} />
</Route>
<Route path="/callback" element={<Callback />} />
<Route path="*" element={<div>Not found</div>} />
</Routes>
<CustomSnackbar />
</RainbowKitProvider>
</RainbowKitAuthenticationProvider>
</QueryClientProvider>
Expand Down
31 changes: 31 additions & 0 deletions src/components/layouts/MobileScreensContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Box, Typography } from '@mui/material';

const MobileScreensContainer: React.FC = () => {
return (
<Box
sx={{
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
backgroundColor: 'rgba(0, 0, 0, 0.1)',
mehdi-torabiv marked this conversation as resolved.
Show resolved Hide resolved
color: 'white',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 9999,
textAlign: 'center',
padding: '20px',
}}
>
<Typography variant="subtitle1" color="primary">
We are currently not optimized for mobile devices. Please check back on
a desktop or larger screen.
</Typography>
mehdi-torabiv marked this conversation as resolved.
Show resolved Hide resolved
</Box>
);
};

export default MobileScreensContainer;
2 changes: 1 addition & 1 deletion src/components/layouts/SidebarApp.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('SidebarApp', () => {
const drawer = screen.getByTestId('drawer_app');
expect(drawer).toBeInTheDocument();

const logo = screen.getByText('LOGO');
const logo = screen.getByText('LogID');
expect(logo).toBeInTheDocument();

SIDEBAR_MENU.forEach((item) => {
Expand Down
54 changes: 48 additions & 6 deletions src/components/layouts/SidebarApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { useLocation, useNavigate } from 'react-router-dom';

import { DRAWER_WIDTH, SIDEBAR_MENU } from '../../libs/constants';
import theme from '../../libs/theme';

function SidebarApp() {
const navigate = useNavigate();
Expand Down Expand Up @@ -41,23 +42,64 @@ function SidebarApp() {
}}
>
<Typography variant="h6" fontWeight="bold">
LOGO
LogID
</Typography>
</Box>
</Toolbar>
<Divider />
<List>
<List sx={{ padding: 2 }}>
{' '}
{SIDEBAR_MENU.map((item) => (
<ListItemButton
key={item.title}
sx={{ display: 'flex', justifyContent: 'center', gap: 1 }}
selected={item.path === pathname}
sx={{
display: 'flex',
justifyContent: 'center',
gap: 1,
mt: 1,
padding: '8px 16px',
borderRadius: 2,
backgroundColor:
item.path === pathname
? theme.palette.primary.main
: 'transparent',
color:
item.path === pathname
? theme.palette.primary.contrastText
: theme.palette.text.primary,
'&:hover': {
backgroundColor:
item.path === pathname
? theme.palette.primary.main // Keep the same background for selected item
: theme.palette.action.hover,
},
'&.Mui-selected': {
backgroundColor: `${theme.palette.primary.main} !important`,
color: theme.palette.primary.contrastText,
'&:hover': {
backgroundColor: `${theme.palette.primary.main} !important`, // Prevent hover effect from altering the background
},
},
}}
onClick={() => navigate(item.path)}
>
<ListItemIcon sx={{ minWidth: 'auto' }}>
<ListItemIcon
sx={{
minWidth: 'auto',
color:
item.path === pathname
? theme.palette.primary.contrastText
: theme.palette.text.primary,
}}
>
<item.icon />
</ListItemIcon>
<ListItemText>{item.title}</ListItemText>
<ListItemText
primary={item.title}
sx={{
color: 'inherit',
}}
/>
</ListItemButton>
))}
</List>
Expand Down
5 changes: 3 additions & 2 deletions src/components/shared/CustomTable.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/no-array-index-key */
import {
Avatar,
Card,
Expand Down Expand Up @@ -85,9 +86,9 @@ const CustomTable: React.FC<CustomTableProps<AccessData>> = ({
([applicationName, applications], rowIndex) => (
<TableRow component={Card} key={rowIndex}>
<TableCell align="center" sx={{ padding: 1 }}>
<div className="flex flex-col items-center justify-center text-center mx-auto space-y-2">
<div className="flex flex-row items-center justify-center text-center mx-auto space-x-3">
<Avatar />
<Typography>{applicationName}</Typography>
<Typography>{capitalize(applicationName)}</Typography>
</div>
</TableCell>
{xcolumns.map((platform, colIndex) => {
Expand Down
4 changes: 3 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@

*,
body {
font-family: Inter;
padding: 0;
margin: 0;
box-sizing: border-box;
}
8 changes: 7 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import './index.css';

import React from 'react';
import { ThemeProvider } from '@emotion/react';
import { CssBaseline } from '@mui/material';
import { getDefaultConfig } from '@rainbow-me/rainbowkit';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { baseSepolia, optimismSepolia } from 'viem/chains';
import { http, WagmiProvider } from 'wagmi';

import App from './App';
import theme from './libs/theme';

if (!import.meta.env.VITE_PROJECT_ID) {
throw new Error('VITE_PROJECT_ID environment variable is required');
Expand All @@ -31,7 +34,10 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrowserRouter>
<WagmiProvider config={config}>
<App />
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
</WagmiProvider>
</BrowserRouter>
</React.StrictMode>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Auth/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function Login() {
return (
<div className="h-screen w-full flex">
<Box className="w-1/4 p-8 flex flex-col justify-center items-center shadow-2xl">
<Typography variant="h6" fontWeight="bold" gutterBottom>
Welcome to OnChain
<Typography variant="h6" fontWeight="bold" gutterBottom color="primary">
Welcome to LogID
</Typography>
<Typography variant="body1" gutterBottom>
Please connect your wallet to continue.
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Identifiers/Attestation/Attestation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AttestPayload } from '../../../interfaces';
const steps = [
{ label: 'Authenticate' },
{ label: 'Attest' },
{ label: 'Transact' },
{ label: 'Complete' },
];

export default function Attestation() {
Expand Down Expand Up @@ -53,8 +53,8 @@ export default function Attestation() {
>
<Alert severity="info" sx={{ mb: 4 }}>
<AlertTitle>Link Your Social Media Accounts</AlertTitle>
Attest your social media accounts by linking them to your wallet
address. This allows you to prove ownership over these accounts.
Attest the social media accounts you own by linking them to your
wallet address. This allows you to prove ownership.
</Alert>
<CustomStepper steps={steps} activeStep={activeStep} />

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Permissions/Permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export function Permissions() {
</Typography>
<Alert severity="info" sx={{ mb: 2 }}>
<b>Note</b>: The process of revoking or granting access to
applications may take some time.
applications may take 1-2 minutes to process.
</Alert>
<CustomTable
xcolumns={providers}
Expand Down
Loading