react-webdist-app: @mui initial integration
This commit is contained in:
parent
3190fbbceb
commit
b576c12bc4
6173
react-webdist-app/package-lock.json
generated
6173
react-webdist-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,11 @@
|
|||||||
"proxy": "http://buildvm01:5000",
|
"proxy": "http://buildvm01:5000",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@emotion/hash": "^0.9.0",
|
||||||
|
"@emotion/react": "^11.10.4",
|
||||||
|
"@emotion/styled": "^11.10.4",
|
||||||
|
"@mui/icons-material": "^5.10.9",
|
||||||
|
"@mui/material": "^5.10.9",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
@ -13,6 +18,8 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-bootstrap": "^2.5.0",
|
"react-bootstrap": "^2.5.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
"react-is": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.4.2",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
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="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<!--
|
<!-- for MaterialUI -->
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> <!--
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
Only files inside the `public` folder can be referenced from the HTML.
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
64
react-webdist-app/src/App.js
vendored
64
react-webdist-app/src/App.js
vendored
@ -1,29 +1,67 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import AppBar from '@mui/material/AppBar';
|
||||||
|
import Toolbar from '@mui/material/Toolbar';
|
||||||
|
import TypoGraphy from '@mui/material/Typography';
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import MenuIcon from "@mui/icons-material/Menu";
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import Latest from "./Latest"
|
import Latest from "./Latest"
|
||||||
|
import NavBar from "./NavBar"
|
||||||
|
|
||||||
function App() {
|
|
||||||
const [placeholder, setPlaceholder] = useState({});
|
|
||||||
|
|
||||||
useEffect(() => {
|
class App extends Component {
|
||||||
fetch('/api/v1/latest').then(res => res.json()).then(data => {
|
constructor(props){
|
||||||
setPlaceholder(data.result);
|
super(props)
|
||||||
});
|
// Set initial state
|
||||||
}, []);
|
this.state = { menuState: 0 }
|
||||||
|
// Binding this keyword
|
||||||
|
this.showLatest = this.showLatest.bind(this)
|
||||||
|
this.showHome = this.showHome.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
// var parse = require('html-react-parser');
|
showLatest() {
|
||||||
// var parsed = parse(placeholder);
|
this.setState({ menuState: 1 })
|
||||||
|
}
|
||||||
|
|
||||||
|
showHome() {
|
||||||
|
this.setState({ menuState: 0 })
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
|
<AppBar color="primary" position="static">
|
||||||
|
<Toolbar>
|
||||||
|
<IconButton
|
||||||
|
edge="start"
|
||||||
|
style={{
|
||||||
|
marginRight: 20,
|
||||||
|
}}
|
||||||
|
color="inherit"
|
||||||
|
aria-label="menu">
|
||||||
|
<MenuIcon />
|
||||||
|
</IconButton>
|
||||||
|
<TypoGraphy variant="h6" color="inherit">
|
||||||
|
WebDist
|
||||||
|
</TypoGraphy>
|
||||||
|
<NavBar showLatest={this.showLatest} showHome={this.showHome} />
|
||||||
|
</Toolbar>
|
||||||
|
</AppBar>
|
||||||
|
<br/>
|
||||||
|
<div>
|
||||||
|
<Button color="primary" variant="contained" onClick={this.showLatest}>
|
||||||
|
Click Me
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<h2>Welcome To WebDist</h2>
|
|
||||||
<a href="/">Home</a> | <a href="/latest">Latest packages</a>
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<Latest name={placeholder} />
|
{this.state.menuState === 1 && <Latest />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
18
react-webdist-app/src/Latest.js
vendored
18
react-webdist-app/src/Latest.js
vendored
@ -1,13 +1,20 @@
|
|||||||
import React from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
export default class Latest extends React.Component {
|
function Latest() {
|
||||||
render() {
|
|
||||||
|
const [placeholder, setPlaceholder] = useState({});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('/api/v1/latest').then(res => res.json()).then(data => {
|
||||||
|
setPlaceholder(data.result);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div className="row align-items-start">
|
<div className="row align-items-start">
|
||||||
<h1>Latest packages</h1>
|
<h1>Latest packages</h1>
|
||||||
{Object.entries(this.props.name).map(([repo,pkgs])=>(
|
{Object.entries(placeholder).map(([repo,pkgs])=>(
|
||||||
<div className="col align-items-start" key={repo}>
|
<div className="col align-items-start" key={repo}>
|
||||||
<h2 key={repo}>{repo}</h2>
|
<h2 key={repo}>{repo}</h2>
|
||||||
{pkgs.map(pkg =>(
|
{pkgs.map(pkg =>(
|
||||||
@ -20,5 +27,6 @@ export default class Latest extends React.Component {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Latest;
|
31
react-webdist-app/src/NavBar.js
vendored
Normal file
31
react-webdist-app/src/NavBar.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import List from '@mui/material/List';
|
||||||
|
import ListItem from '@mui/material/ListItem';
|
||||||
|
import ListItemButton from '@mui/material/ListItemButton';
|
||||||
|
import TypoGraphy from '@mui/material/Typography'
|
||||||
|
|
||||||
|
|
||||||
|
function NavBar(props) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<List component="nav">
|
||||||
|
<ListItem component="div">
|
||||||
|
<ListItemButton onClick={props.showHome}>
|
||||||
|
<TypoGraphy color="inherit" variant="h6">
|
||||||
|
Home
|
||||||
|
</TypoGraphy>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
<ListItemButton onClick={props.showLatest}>
|
||||||
|
<TypoGraphy color="inherit" variant="h6">
|
||||||
|
Latest
|
||||||
|
</TypoGraphy>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
</ListItem >
|
||||||
|
|
||||||
|
</List>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavBar;
|
Loading…
Reference in New Issue
Block a user