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

various small style edits to reusable components library #33

Merged
merged 5 commits into from
Apr 9, 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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"liveServer.settings.port": 5501
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"chroma-js": "^2.4.2",
"date-fns": "^2.30.0",
"dayjs": "^1.11.9",
"downshift": "^9.0.1",
"image-downloader": "^4.3.0",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"material-ui-image": "^3.3.2",
"mathjs": "^12.4.1",
"moment": "^2.29.4",
"notistack": "^3.0.1",
"polished": "^4.3.1",
Expand Down
25 changes: 14 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>

<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" type="image/png" href="/favicon.png" sizes="16x16" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="true"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>

<link
rel="canonical"
href="http://reedvogt.com/projects/enhanced-card-store"
/>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
76 changes: 30 additions & 46 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,58 @@
// App.js
import React, { useEffect } from 'react';
import './assets/css/index.css';
import './assets/css/card.css';
import './assets/css/page.css';
import Main from './Main';
import {
FormProvider,
ModalProvider,
UserProvider,
useMode,
CollectionProvider,
CardProvider,
DeckProvider,
CartProvider,
ChartProvider,
SidebarProvider,
AppContextProvider,
useAuthContext,
ErrorBoundary,
ConfiguratorProvider,
DataProvider,
} from './context';
import { ThemeProvider } from 'styled-components';
import { SnackbarProvider, useSnackbar } from 'notistack';
import { useNavigate } from 'react-router-dom';
import { CssBaseline, GlobalStyles } from '@mui/material';
import { ParallaxProvider } from 'react-scroll-parallax';
import { useLoading } from './context/hooks/useLoading';

// ==============================|| APP ||============================== //

const App = () => {
const { theme } = useMode();
const navigate = useNavigate();
const { resetLogoutTimer, logout, authUser, userId, isLoggedIn } =
useAuthContext();
const { isLoading, isPageLoading, error } = useLoading();

if (isPageLoading || error) {
return <div>Loading...</div>;
}
return (
<ErrorBoundary>
<ThemeProvider theme={theme}>
<CssBaseline />
<GlobalStyles />
<ParallaxProvider>
<ConfiguratorProvider>
<FormProvider>
<UserProvider>
<ModalProvider>
<CollectionProvider>
<CardProvider>
<DeckProvider>
<CartProvider>
<ChartProvider>
<SidebarProvider>
<AppContextProvider>
<Main />
</AppContextProvider>
</SidebarProvider>
</ChartProvider>
</CartProvider>
</DeckProvider>
</CardProvider>
</CollectionProvider>
</ModalProvider>
</UserProvider>
</FormProvider>
</ConfiguratorProvider>
</ParallaxProvider>
</ThemeProvider>
</ErrorBoundary>
<ThemeProvider theme={theme}>
<CssBaseline theme={theme} />
<GlobalStyles />
<ParallaxProvider>
<ConfiguratorProvider>
<UserProvider>
<ModalProvider>
<CollectionProvider>
<CardProvider>
<DeckProvider>
<CartProvider>
<SidebarProvider>
<AppContextProvider>
<DataProvider>
<Main />
</DataProvider>
</AppContextProvider>
</SidebarProvider>
</CartProvider>
</DeckProvider>
</CardProvider>
</CollectionProvider>
</ModalProvider>
</UserProvider>
</ConfiguratorProvider>
</ParallaxProvider>
</ThemeProvider>
);
};

Expand Down
117 changes: 40 additions & 77 deletions src/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,94 +1,57 @@
import React, { Suspense, lazy } from 'react';
import React, { Suspense, lazy, useEffect } from 'react';
import { Route, Routes } from 'react-router-dom';
import { useMediaQuery } from '@mui/material';
import PrivateRoute from './layout/PrivateRoute.jsx';
import LoginDialog from './components/dialogs/LoginDialog';
import { useAuthContext, useConfiguratorContext, useMode } from './context';
import PrivateRoute from './layout/navigation/PrivateRoute.jsx';
import LoginDialog from './pages/LoginDialog.jsx';
import { useConfiguratorContext, useMode } from './context';
import PageLayout from './layout/REUSABLE_COMPONENTS/PageLayout.jsx';
import Navigation from './layout/navigation/Navigation.jsx';
import LoadingIndicator from './layout/LoadingIndicator.js';
import Configurator from './layout/REUSABLE_COMPONENTS/Configurator/index.jsx';
import { CSSTransition, TransitionGroup } from 'react-transition-group';
import LoadingOverlay from './layout/LoadingOverlay.jsx';
import SelectionErrorDialog from './components/dialogs/SelectionErrorDialog.jsx';
import useDialogState from './context/hooks/useDialogState.jsx';
import useSelectedCollection from './context/MAIN_CONTEXT/CollectionContext/useSelectedCollection.jsx';

const ROUTE_CONFIG = [
{ path: '/', componentName: 'HomePage', isPrivate: false },
{ path: '/home', componentName: 'HomePage', isPrivate: false },
{ path: '/deckbuilder', componentName: 'DeckBuilderPage', isPrivate: false },
{ path: '/store', componentName: 'StorePage', isPrivate: false },
{ path: '/cart', componentName: 'CartPage', isPrivate: true },
{ path: '/collection', componentName: 'CollectionPage', isPrivate: true },
{ path: '/profile', componentName: 'ProfilePage', isPrivate: true },
{ path: '/login', componentName: 'LoginPage', isPrivate: false },
{ path: '/signup', componentName: 'SignupPage', isPrivate: false },
{ path: '/about', componentName: 'AboutPage', isPrivate: false },
{ path: '/contact', componentName: 'ContactPage', isPrivate: false },
{ path: '/terms', componentName: 'TermsPage', isPrivate: false },
{ path: '/privacy', componentName: 'PrivacyPage', isPrivate: false },
{ path: '*', componentName: 'NotFoundPage', isPrivate: false },
];
import LoadingOverlay from './layout/REUSABLE_COMPONENTS/system-utils/LoadingOverlay.jsx';
import useManageCookies from './context/hooks/useManageCookies.jsx';
import { ROUTE_CONFIG } from './data/route-config.jsx';

const LazyRoute = ({ componentName, ...rest }) => {
const Component = lazy(() => import(`./pages/${componentName}`));
return <Component {...rest} />;
};
const Main = () => {
const { theme } = useMode();
const isMobileView = useMediaQuery(theme.breakpoints.down('sm'));
const { isLoggedIn } = useAuthContext();
const { getCookie } = useManageCookies();
const { isLoggedIn, userId } = getCookie(['isLoggedIn', 'userId']);
const { isConfiguratorOpen, toggleConfigurator } = useConfiguratorContext();
const { dialogState, openDialog, closeDialog } = useDialogState({});
const { selectedCollection } = useSelectedCollection();
return (
<>
{!isLoggedIn ? (
<LoginDialog open={!isLoggedIn} />
) : (
<PageLayout
sx={{
backgroundColor: '#3D3D3D',
}}
>
<Navigation isLoggedIn={isLoggedIn} />
{isConfiguratorOpen && <Configurator />}
<TransitionGroup component={null} exit={false}>
<CSSTransition key={location.key} classNames="fade" timeout={300}>
<Suspense fallback={<LoadingOverlay />}>
<Routes>
{ROUTE_CONFIG.map(
({ path, componentName, isPrivate }, index) => (
<Route
key={index}
path={path}
element={
isPrivate ? (
<PrivateRoute>
<LazyRoute componentName={componentName} />
</PrivateRoute>
) : (
<LazyRoute componentName={componentName} />
)
}
/>
<PageLayout
sx={{
backgroundColor: '#3D3D3D',
}}
>
<Navigation isLoggedIn={isLoggedIn} />
{isConfiguratorOpen && <Configurator />}
<TransitionGroup component={null} exit={false}>
<CSSTransition key={location.key} classNames="fade" timeout={300}>
<Suspense fallback={<LoadingOverlay />}>
<Routes>
{ROUTE_CONFIG.map(({ path, componentName, isPrivate }, index) => (
<Route
key={index}
path={path}
element={
isPrivate ? (
<PrivateRoute>
<LazyRoute componentName={componentName} />
</PrivateRoute>
) : (
<LazyRoute componentName={componentName} />
)
)}
</Routes>
</Suspense>
</CSSTransition>
</TransitionGroup>
{dialogState.isSelectionErrorDialogOpen && (
<SelectionErrorDialog
open={dialogState.isSelectionErrorDialogOpen}
onClose={() => closeDialog('isSelectionErrorDialogOpen')}
selectedValue={selectedCollection?.name}
/>
)}
</PageLayout>
)}
</>
}
/>
))}
</Routes>
</Suspense>
</CSSTransition>
</TransitionGroup>
<LoginDialog />
</PageLayout>
);
};

Expand Down
97 changes: 97 additions & 0 deletions src/assets/css/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.base-card {
display: flex;
flex-direction: column;
min-width: 100px;
max-width: 100%;
max-height: 100%;
flex-grow: 1;
background-color: #fff;
border-radius: 4px; /* Replace with your theme's border radius */
justify-content: center;
transition: transform 0.3s ease-in-out;
position: relative; /* Ensure this is set to allow absolute children positioning */
}
.base-card:hover {
transform: scale(1.03);
}
/* BASE CARD QUANTITY */
.base-card-no-quantity {
position: initial;
width: 100%;
height: 100%;
max-height: 100%;
}
.card-deck {
position: relative;
width: calc(33.33% - 10px);
}
.card-deck-grid-item {
flex-basis: calc(
100% / 3 - 10px
); /* Default showing 3 items per row, adjust gap with -10px */
max-width: calc(
100% / 3 - 10px
); /* Same as flex-basis, ensures compatibility */
}
.card-group-flex-item {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: stretch;
gap: 10px;
}
/* ROW: 6 cards */
@media screen and (max-width: 1400px) {
/* EXPLANATION: 100% / 3 - 10px = 33.33% - 10px */
.card-deck-grid-item {
flex-basis: calc(50% - 10px);
max-width: calc(50% - 10px);
}
}
/* ROW: 4 cards */
@media screen and (max-width: 1200px) {
/* EXPLANATION: 100% / 3 - 10px = 33.33% - 10px */
.card-deck-grid-item {
flex-basis: calc(33.33% - 12.5px);
max-width: calc(33.33% - 12.5px);
}
}
/* ROW: 4 cards */
@media screen and (max-width: 992px) {
/* EXPLANATION: 100% / 4 - 10px = 25% - 10px */
.card-deck-grid-item {
flex-basis: calc(50% - 15px);
max-width: calc(50% - 15px);
}
}
/* ROW: 3 cards */
@media screen and (max-width: 768px) {
/* EXPLANATION: 100% / 6 - 10px = 16.66% - 10px */
.card-deck-grid-item {
flex-basis: calc(50% - 25px);
max-width: calc(50% - 25px);
}
}
/* ROW: 3 cards */
@media screen and (max-width: 576px) {
/* EXPLANATION: 100% / 8 - 10px = 12.5% - 10px */
.card-deck-grid-item {
flex-basis: calc(100% - 20px);
max-width: calc(100% - 20px);
}
}
.card-group-flex-item:nth-child(1) {
z-index: 300;
}
.card-group-flex-item:nth-child(2) {
z-index: 200;
}
.card-group-flex-item:nth-child(3) {
z-index: 100;
}
.card-group-flex-item .card-deck:not(:last-child) {
margin-right: -90%; /* Overlap cards by 90% */
}
.card-group-flex-item {
min-width: 60%;
}
Loading
Loading