navbar completed
This commit is contained in:
parent
72325791d6
commit
bd92806f0a
@ -47,7 +47,7 @@
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"linebreak-style": ["warn", "unix"],
|
||||
"linebreak-style": ["warn", "windows"],
|
||||
"quotes": ["error", "double", { "avoidEscape": true }],
|
||||
"semi": ["error", "always"]
|
||||
}
|
||||
|
||||
10
declaration.d.ts
vendored
Normal file
10
declaration.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
declare module '*.svg' {
|
||||
import React = require('react');
|
||||
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
||||
declare module "*.png" {
|
||||
const value: any;
|
||||
export default value;
|
||||
}
|
||||
@ -24,6 +24,7 @@
|
||||
"build-dev": "BUILD_ENV=DEV webpack --config webpack.config.ts",
|
||||
"build-prod": "BUILD_ENV=PROD webpack --config webpack.config.ts",
|
||||
"lint": "eslint src",
|
||||
"lint-fix": "eslint src --ext .tsx --fix",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
import { ENV } from "./constants/env";
|
||||
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
|
||||
import React from "react";
|
||||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||
|
||||
import Home from "./components/home/Home";
|
||||
import Contacts from "./components/contacts/Contacts";
|
||||
import Calendar from "./components/calendar/Calendar";
|
||||
import Navbar from "./components/navbar/Navbar";
|
||||
import { ThemeProvider } from "@emotion/react";
|
||||
|
||||
import Theme from "./Theme";
|
||||
|
||||
const App: React.FC = () => {
|
||||
return (
|
||||
<ThemeProvider theme={Theme}>
|
||||
<Router>
|
||||
<Navbar />
|
||||
<Routes>
|
||||
@ -16,6 +20,7 @@ const App: React.FC = () => {
|
||||
<Route path="/calendar" element={<Calendar />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
14
src/Theme.tsx
Normal file
14
src/Theme.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
|
||||
export default createTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
// white
|
||||
main: "#ffffff",
|
||||
},
|
||||
secondary: {
|
||||
// red
|
||||
main: "#DB00116",
|
||||
},
|
||||
},
|
||||
});
|
||||
BIN
src/assets/logo-png.png
Normal file
BIN
src/assets/logo-png.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
1
src/assets/logo.svg
Normal file
1
src/assets/logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 50 KiB |
@ -1,5 +1,3 @@
|
||||
import { ENV } from "../../constants/env";
|
||||
|
||||
const Calendar: React.FC = () => {
|
||||
return <span>Calendar</span>;
|
||||
};
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import { ENV } from "../../constants/env";
|
||||
|
||||
const Contacts: React.FC = () => {
|
||||
return <span>Contacts</span>;
|
||||
};
|
||||
|
||||
@ -1,7 +1,60 @@
|
||||
import { ENV } from "../../constants/env";
|
||||
import React from "react";
|
||||
import { Box, Button } from "@mui/material";
|
||||
import GroupsIcon from "@mui/icons-material/Groups";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import CallIcon from "@mui/icons-material/Call";
|
||||
import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";
|
||||
|
||||
const Home: React.FC = () => {
|
||||
return <span>Home</span>;
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
height: "75%",
|
||||
}}
|
||||
>
|
||||
<Box sx={{ flexGrow: 1 }}>hi</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
flexGrow: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "space-evenly",
|
||||
}}
|
||||
>
|
||||
<Box>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="outlined"
|
||||
startIcon={<GroupsIcon />}
|
||||
></Button>
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="outlined"
|
||||
startIcon={<GroupsIcon />}
|
||||
></Button>
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="outlined"
|
||||
startIcon={<GroupsIcon />}
|
||||
></Button>
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="outlined"
|
||||
startIcon={<GroupsIcon />}
|
||||
></Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
||||
|
||||
49
src/components/navbar/Clock.tsx
Normal file
49
src/components/navbar/Clock.tsx
Normal file
@ -0,0 +1,49 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import Box, { BoxProps } from "@mui/material/Box";
|
||||
import { styled } from "@mui/material/styles";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
|
||||
import AccessTimeIcon from "@mui/icons-material/AccessTime";
|
||||
|
||||
const FormattedBox = styled(Box)<BoxProps>(({ theme }) => ({
|
||||
marginRight: 12,
|
||||
}));
|
||||
|
||||
const Clock: React.FC = () => {
|
||||
const [date, setDate] = useState<Date>(new Date());
|
||||
|
||||
useEffect(() => {
|
||||
setInterval(() => setDate(new Date()), 30000);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Box sx={{ display: "flex" }}>
|
||||
<FormattedBox sx={{ mt: 0.5 }}>
|
||||
<CalendarTodayIcon />
|
||||
</FormattedBox>
|
||||
<FormattedBox>
|
||||
<Typography variant="h6" color="inherit">
|
||||
{date.toLocaleDateString("en-GB", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
})}
|
||||
</Typography>
|
||||
</FormattedBox>
|
||||
<FormattedBox sx={{ mt: 0.5 }}>
|
||||
<AccessTimeIcon />
|
||||
</FormattedBox>
|
||||
<FormattedBox>
|
||||
<Typography variant="h6" color="inherit">
|
||||
{date.toLocaleString("en-US", {
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
hour12: true,
|
||||
})}
|
||||
</Typography>
|
||||
</FormattedBox>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Clock;
|
||||
@ -1,21 +1,40 @@
|
||||
import { ENV } from "../../constants/env";
|
||||
import React from "react";
|
||||
import { AppBar, Box, IconButton, Toolbar, Typography } from "@mui/material";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
import Clock from "./Clock";
|
||||
import pngLogo from "../../assets/logo-png.png";
|
||||
import { Page } from "./Page";
|
||||
|
||||
const pages: Page[] = [
|
||||
{ name: "Home", url: "/" },
|
||||
{ name: "Contacts", url: "/contacts" },
|
||||
{ name: "Calendar", url: "/calendar" },
|
||||
];
|
||||
|
||||
const Navbar: React.FC = () => {
|
||||
return (
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<Link to="/">Home</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link to="/contacts">Contacts</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link to="/calendar">Calendar</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<AppBar position="static">
|
||||
<Toolbar variant="dense" disableGutters>
|
||||
<IconButton disableRipple sx={{ mr: 2 }}>
|
||||
<img src={pngLogo} alt="Kitty Katty!" style={{ maxWidth: 130 }} />
|
||||
</IconButton>
|
||||
{pages.map((page, i) => (
|
||||
<Box flexGrow={i == pages.length - 1 ? 1 : 0} sx={{ mr: 3 }}>
|
||||
<Typography
|
||||
variant="h6"
|
||||
color="inherit"
|
||||
component={Link}
|
||||
to={page.url}
|
||||
sx={{ textDecoration: "none" }}
|
||||
>
|
||||
{page.name}
|
||||
</Typography>
|
||||
</Box>
|
||||
))}
|
||||
<Clock />
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
6
src/components/navbar/Page.tsx
Normal file
6
src/components/navbar/Page.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
interface Page {
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type { Page };
|
||||
@ -1,5 +1,3 @@
|
||||
import { ENV } from "../../constants/env";
|
||||
|
||||
const Sidebar: React.FC = () => {
|
||||
return <span>Sidebar</span>;
|
||||
};
|
||||
|
||||
@ -66,6 +66,6 @@
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||
"types": ["node", "webpack-env"]
|
||||
},
|
||||
"include": ["src"],
|
||||
"include": ["src", "declaration.d.ts"],
|
||||
"exclude": ["node_modules", "build"]
|
||||
}
|
||||
|
||||
@ -61,6 +61,13 @@ const baseConfig: Configuration = {
|
||||
test: /\.svg$/,
|
||||
use: ["@svgr/webpack"],
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|jp2|webp)$/,
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user