2021-05-08 18:49:08 +02:00
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import Icon from '../UI/Icon/Icon';
|
|
|
|
|
|
|
|
import classes from './Home.module.css';
|
|
|
|
import { Container } from '../UI/Layout/Layout';
|
2021-05-09 19:02:50 +02:00
|
|
|
import Headline from '../UI/Headlines/Headline/Headline';
|
|
|
|
import SectionHeadline from '../UI/Headlines/SectionHeadline/SectionHeadline';
|
|
|
|
import Apps from '../Apps/Apps';
|
2021-05-08 18:49:08 +02:00
|
|
|
|
|
|
|
const Home = (): JSX.Element => {
|
|
|
|
const dateAndTime = (): string => {
|
|
|
|
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
|
|
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
|
|
|
2021-05-09 19:02:50 +02:00
|
|
|
const now = new Date();
|
2021-05-08 18:49:08 +02:00
|
|
|
|
2021-05-09 19:02:50 +02:00
|
|
|
return `${days[now.getDay()]}, ${now.getDate()} of ${months[now.getMonth()]} ${now.getFullYear()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const greeter = (): string => {
|
|
|
|
const now = new Date().getHours();
|
|
|
|
let msg: string;
|
2021-05-08 18:49:08 +02:00
|
|
|
|
2021-05-09 19:02:50 +02:00
|
|
|
if (now > 18) {
|
|
|
|
msg = 'Good evening!';
|
|
|
|
} else if (now > 12) {
|
|
|
|
msg = 'Good afternoon!';
|
|
|
|
} else if (now > 6) {
|
|
|
|
msg = 'Good morning!';
|
|
|
|
} else if (now > 0) {
|
|
|
|
msg = 'Good night!';
|
|
|
|
} else {
|
|
|
|
msg = 'Hello!';
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
2021-05-08 18:49:08 +02:00
|
|
|
}
|
|
|
|
|
2021-05-09 19:02:50 +02:00
|
|
|
(() => {
|
|
|
|
const mdiName = 'book-open-blank-variant';
|
|
|
|
const expected = 'mdiBookOpenBlankVariant';
|
|
|
|
|
|
|
|
let parsedName = mdiName
|
|
|
|
.split('-')
|
|
|
|
.map((word: string) => `${word[0].toUpperCase()}${word.slice(1)}`)
|
|
|
|
.join('');
|
|
|
|
parsedName = `mdi${parsedName}`;
|
|
|
|
|
|
|
|
console.log(parsedName);
|
|
|
|
console.log(parsedName === expected);
|
|
|
|
})();
|
|
|
|
|
2021-05-08 18:49:08 +02:00
|
|
|
return (
|
|
|
|
<Container>
|
2021-05-09 19:02:50 +02:00
|
|
|
<header className={classes.Header}>
|
|
|
|
<p>{dateAndTime()}</p>
|
|
|
|
<h1>{greeter()}</h1>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<SectionHeadline title='Apps' />
|
|
|
|
<Apps />
|
|
|
|
|
|
|
|
<SectionHeadline title='Bookmarks' />
|
|
|
|
|
2021-05-08 18:49:08 +02:00
|
|
|
<Link to='/settings' className={classes.SettingsButton}>
|
|
|
|
<Icon icon='mdiCog' />
|
|
|
|
</Link>
|
|
|
|
</Container>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Home;
|