Skip to content

Commit 32f02ee

Browse files
authored
Merge pull request #17 from oslabs-beta/denton/link
Denton/link
2 parents 0507bbd + c425a8e commit 32f02ee

File tree

17 files changed

+116
-49
lines changed

17 files changed

+116
-49
lines changed

app/src/Dashboard/NavbarDash.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ export default function NavBar(props) {
9393
<div className={classes.root} style={style}>
9494
<AppBar position='static'>
9595
<Toolbar>
96-
<Avatar src={greenLogo}></Avatar>
97-
<Typography variant="h6" style={{ marginLeft: '1rem' }} className={classes.title}>
98-
ReacType
99-
</Typography>
100-
<div style ={ { textDecoration: 'none' } }>
96+
<Link to="/" style={{display: 'inline-flex', justifyContent: 'center', textDecoration: 'none'}}>
97+
<Avatar src={greenLogo}></Avatar>
98+
<Typography variant="h6" style={{ marginTop: '0.3rem', marginLeft: '0.5rem', color: 'silver' }} className={classes.title}>
99+
ReacType
100+
</Typography>
101+
</Link>
102+
<div style ={ { marginLeft: '0.5rem', textDecoration: 'none' } }>
101103
<Button
102104
variant='contained'
103105
color='primary'

app/src/components/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ export const App = (): JSX.Element => {
9393

9494
return (
9595
<div className="app">
96-
<DndProvider backend={HTML5Backend}>
96+
9797
<header
9898
style={{ height: '40px', width: '100%', backgroundColor: 'white' }}
9999
>
100100
ReacType
101101
</header>
102102

103103
<AppContainer />
104-
</DndProvider>
104+
105105
</div>
106106
);
107107
};

app/src/components/bottom/BottomPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ const BottomPanel = (props): JSX.Element => {
3636
}, []);
3737

3838
return (
39+
<>
3940
<div className="bottom-panel" id="resize" ref={node}>
4041
<div id="resize-drag" onMouseDown={mouseDownHandler} tabIndex={0}>
4142
......
4243
</div>
4344
<BottomTabs isThemeLight={props.isThemeLight} />
44-
</div>
45+
</div></>
4546
);
4647
};
4748

app/src/components/bottom/BottomTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const BottomTabs = (props): JSX.Element => {
4949
return (
5050
<div
5151
className={`${classes.root} ${classes.rootLight}`}
52-
style={{ backgroundColor: '#191919' }}
52+
style={{ backgroundColor: '#191919' , zIndex: 1, borderTop: '2px solid grey'}}
5353
>
5454
<Box
5555
display="flex"

app/src/components/left/Sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface SidebarProps {
1212
}
1313

1414
const Sidebar: React.FC<SidebarProps> = ({ value, setValue }) => {
15+
console.log('sidebar value', value);
1516
return (
1617
<Tabs
1718
orientation="vertical"

app/src/components/main/CanvasContainer.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,38 @@ function CanvasContainer(props): JSX.Element {
2525
const canvasContainerStyle = {
2626
width: '100%',
2727
backgroundColor: 'lightgrey',
28-
border: '2px Solid grey',
29-
overflow: 'auto',
28+
border: '2px solid grey',
29+
borderBottom: 'none',
30+
overflow: 'auto',
3031
};
3132

3233
const codePreviewStyle = {
33-
position: 'absolute',
34+
position: 'fixed',
3435
width: 'max-content',
3536
height: 'max-content',
3637
bottom: '100px',
3738
right: '51vw',
3839
textAlign: 'center',
3940
color: '#ffffff',
40-
backgroundColor: '#151515'
41+
backgroundColor: '#151515',
42+
zIndex: 0
43+
44+
45+
4146
} as const;
4247

4348
return (
4449
<div style={canvasContainerStyle}>
4550
{state.codePreview && <CodePreview theme={theme} setTheme={setTheme}/>}
4651
{!state.codePreview && <Canvas isThemeLight={props.isThemeLight}/>}
52+
4753
<Button
4854
style={codePreviewStyle}
4955
onClick={onClickCodePreview}
5056
>
5157
Code Preview
5258
</Button>
59+
5360
</div>
5461
);
5562
}

app/src/components/main/DemoRender.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const DemoRender = (): JSX.Element => {
2323
width: '100%',
2424
backgroundColor: '#FBFBFB',
2525
border: '2px Solid grey',
26+
borderBottom: 'none',
2627
overflow: 'auto'
2728
};
2829

app/src/components/marketplace/MarketplaceCard.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@ import React from 'react';
1818
import imageSrc from '../../../../resources/marketplace_images/marketplace_image.png';
1919
import { red } from '@mui/material/colors';
2020

21+
interface Project {
22+
comments: string[]
23+
createdAt: Date
24+
likes: number
25+
name: string
26+
project: object
27+
published: boolean
28+
userId: number
29+
username: string
30+
_id: number
31+
}
32+
2133
const ITEM_HEIGHT = 48;
22-
const MarketplaceCard = () => {
34+
const MarketplaceCard = ({proj} :{proj: Project}) => {
2335
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
2436
const open = Boolean(anchorEl);
2537
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
@@ -58,8 +70,8 @@ const MarketplaceCard = () => {
5870
<MoreVert />
5971
</IconButton>
6072
}
61-
title="Gradient Buttons"
62-
subheader="Liam Rohn"
73+
title={proj.name}
74+
subheader={proj.username}
6375
/>
6476
<Menu
6577
id="long-menu"

app/src/components/marketplace/MarketplaceCardContainer.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
import { Container, Grid } from '@mui/material';
22

33
import MarketplaceCard from './MarketplaceCard';
4-
import React from 'react';
4+
import React, {useEffect, useState} from 'react';
5+
import axios from 'axios';
56

67
const MarketplaceCardContainer = () => {
7-
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
8+
9+
const [marketplaceProjects, setMarketplaceProjects] = useState([]);
10+
useEffect(() => {
11+
async function marketplaceFetch() {
12+
try {
13+
const response = await axios.get('/getMarketplaceProjects', {
14+
headers: {
15+
'Content-Type': 'application/json',
16+
},
17+
withCredentials: true,
18+
});
19+
20+
setMarketplaceProjects(response.data);
21+
22+
} catch (error) {
23+
console.error('Error fetching MP data:', error);
24+
}
25+
}
26+
marketplaceFetch();
27+
28+
}, []);
29+
830
return (
931
<>
1032
<Container>
@@ -14,9 +36,10 @@ const MarketplaceCardContainer = () => {
1436
spacing={{ xs: 2, md: 3 }}
1537
columns={{ xs: 4, sm: 8, md: 12 }}
1638
>
17-
{numbers.map((num) => (
18-
<Grid item xs={4} sm={4} md={4} key={num}>
19-
<MarketplaceCard />
39+
{marketplaceProjects.map((proj, i) => (
40+
41+
<Grid item xs={4} sm={4} md={4} key={i}>
42+
<MarketplaceCard proj={proj}/>
2043
</Grid>
2144
))}
2245
</Grid>

app/src/components/top/NavBar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
2+
import { Link } from 'react-router-dom';
33
import Avatar from '@mui/material/Avatar';
44
import Button from '@mui/material/Button';
55
import MoreVertIcon from '@mui/icons-material/MoreVert';
@@ -58,12 +58,14 @@ const NavBar = () => {
5858
: { backgroundColor: '#151515' }
5959
}
6060
>
61+
<Link to="/" style={{ textDecoration: 'none' }}>
6162
<div className="main-logo">
6263
<Avatar src={logo}></Avatar>
6364
<h1 style={isDarkMode ? { color: 'white' } : { color: 'white' }}>
6465
ReacType
6566
</h1>
6667
</div>
68+
</Link>
6769
<div style={buttonContainerStyle}>
6870
<button style={buttonStyle}>Share</button>
6971
<NewExportButton />

app/src/containers/AppContainer.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import NavBar from '../components/top/NavBar';
1616
import { RootState } from '../redux/store';
1717

1818
import { setStyle } from '../redux/reducers/slice/styleSlice';
19-
19+
import { useHistory } from 'react-router-dom';
2020
declare module '@mui/styles/defaultTheme' {
2121
// eslint-disable-next-line @typescript-eslint/no-empty-interface
2222
interface DefaultTheme extends Theme {}
@@ -26,9 +26,11 @@ declare module '@mui/styles/defaultTheme' {
2626
const lightTheme = theme1;
2727
const darkTheme = theme2; // dark mode color in theme.ts not reached
2828
const AppContainer = () => {
29-
// setting state for changing light vs dark themes; linked to NavBar.tsx
30-
29+
//useHistory hook to grab the url, if it is /marketplace then selectively render MarketplaceContainer
30+
const urlAdd = useHistory();
31+
const isMarketplace = urlAdd.location.pathname === '/marketplace';
3132

33+
// setting state for changing light vs dark themes; linked to NavBar.tsx
3234
const { isDarkMode, style } = useSelector((store: RootState) => ({
3335
isDarkMode: store.darkMode.isDarkMode,
3436
style: store.styleSlice.style
@@ -51,8 +53,12 @@ const AppContainer = () => {
5153
<NavBar setTheme={setTheme} isThemeLight={isThemeLight} />
5254
</div>
5355
<div className="app-container">
54-
<LeftContainer isThemeLight={isThemeLight} />
55-
<MainContainer isThemeLight={isThemeLight} />
56+
{isMarketplace ? <MarketplaceContainer/> :
57+
<>
58+
<LeftContainer isThemeLight={isThemeLight} />
59+
<MainContainer isThemeLight={isThemeLight} />
60+
</>
61+
}
5662
</div>
5763
{/* <MarketplaceContainer /> */}
5864
</ThemeProvider>

app/src/containers/LeftContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BrowserRouter as Router } from 'react-router-dom';
55
import Sidebar from '../components/left/Sidebar';
66

77
function App() {
8-
const [value, setValue] = useState<number | null>(null);
8+
const [value, setValue] = useState<number | null>(5);
99

1010
return (
1111
<div style={{ display: 'flex' }}>

app/src/containers/MainContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const MainContainer = (props): JSX.Element => {
1212

1313
return (
1414
<div className="main-container" style={style}>
15-
<div className="main">
15+
<div className="main" >
1616
<CanvasContainer isThemeLight={props.isThemeLight} />
1717
<DemoRender />
1818
</div>
19-
<div className="bottom-hide">
19+
<div className="bottom-hide" >
2020
<BottomPanel isThemeLight={props.isThemeLight} />
2121
</div>
2222
</div>

app/src/containers/MarketplaceContainer.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import MarketplaceCardContainer from '../components/marketplace/MarketplaceCardContainer';
2-
import NavBar from '../components/top/NavBar';
3-
import React from 'react';
42
import SearchBar from '../components/marketplace/Searchbar';
3+
import React from 'react';
54

65
const MarketplaceContainer = () => {
6+
7+
8+
79
return (
810
<div style={containerStyles}>
9-
<NavBar />
1011
<div style={contentStyles}>
1112
<h1 style={headingStyles}>Discover components built with ReacType</h1>
1213
<p style={subheadingStyles}>
@@ -23,7 +24,10 @@ const MarketplaceContainer = () => {
2324
const containerStyles: React.CSSProperties = {
2425
backgroundColor: '#111',
2526
minHeight: '100vh',
26-
color: 'white'
27+
width: '100vw',
28+
color: 'white',
29+
paddingBottom: '15vh',
30+
overflow: 'auto',
2731
};
2832

2933
const contentStyles: React.CSSProperties = {

app/src/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
HashRouter as Router,
88
Switch
99
} from 'react-router-dom';
10-
10+
import { DndProvider } from 'react-dnd';
11+
import { HTML5Backend } from 'react-dnd-html5-backend';
1112
import App from './components/App';
1213
import Cookies from 'js-cookie';
1314
import FBPassWord from './components/login/FBPassWord';
@@ -49,9 +50,11 @@ ReactDOM.render(
4950
<Route exact path="/login" component={SignIn} />
5051
<Route exact path="/signup" component={SignUp} />
5152
<Route exact path="/password" component={FBPassWord} />
52-
<PrivateRoute exact path="/" component={App} />
53+
<DndProvider backend={HTML5Backend}>
54+
<Route exact path="/marketplace" component={App} />
55+
<PrivateRoute exact path="/" component={App} />
56+
</DndProvider>
5357
<Route exact path="/dashboard" component={ProjectDashboard} />
54-
<Route exact path="/marketplace" component={MarketplaceButton} />
5558
<Route exact path="/tutorial" component={Tutorial} />
5659
<Route exact path="/tutorialPage/:learn" component={TutorialPage} />
5760
</Switch>

app/src/public/styles/style.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ BOTTOM PANEL
493493
*/
494494

495495
.bottom-hide {
496-
max-height: 76px;
496+
max-height: 64px;
497497
box-sizing: border-box;
498498
transition: all 0.5s ease-in-out;
499499
}
@@ -521,26 +521,31 @@ BOTTOM PANEL
521521
}
522522

523523
#resize-drag {
524+
524525
cursor: row-resize;
525-
background-color: silver;
526-
height: 16px;
527-
top: 0;
528-
/* left: 50px; */
529-
width: 100%;
530-
border: 2px solid black;
531-
border-radius: 8px;
526+
height: 25px;
527+
width: 75px;
528+
background-color: rgb(0, 0, 0);
529+
outline: 2px solid rgba(192, 192, 192, 0.5);
530+
outline-offset: -5px;
532531
text-align: center;
533-
line-height: 0px;
532+
border-radius: 10px 10px 0 0;
533+
align-self: center;
534+
margin-top: -25px;
535+
color: silver;
534536
user-select: none;
535-
color: rgb(32, 32, 32);
536-
font-size: x-large;
537+
z-index: 1;
538+
537539
}
538540

539541
.bottom-panel {
540542
transition: width 250ms ease-in-out;
541543
background-color: #003366;
542544
width: 100%;
543545
height: 100%;
546+
display:flex;
547+
flex-direction: column;
548+
544549
}
545550

546551
.htmlattr {

server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ app.patch(
212212
//Get from Marketplace
213213
app.get(
214214
'/getMarketplaceProjects',
215-
sessionController.isLoggedIn,
215+
// sessionController.isLoggedIn, //Maybe don't need to check if they have a session since guests should still see?
216216
marketplaceController.getPublishedProjects,
217217
(req, res) => res.status(200).json(res.locals.publishedProjects)
218218
);

0 commit comments

Comments
 (0)