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

Chrome extension #1

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
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
512 changes: 512 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.8.5",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"aos": "^3.0.0-beta.6",
"font-awesome": "^4.7.0",
"react": "^18.2.0",
"react-axios": "^2.0.6",
"react-dom": "^18.2.0",
"react-redux": "^8.0.2",
"react-scripts": "5.0.1",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
13 changes: 10 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { useSelector } from "react-redux";
import { BgWrapper, GlobalStyle } from "./components";
import MainPage from "./page/MainPage";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use barrel exports here too.

import WelcomePage from "./page/WelcomePage";

function App() {
const name = useSelector((state) => state.extData.name);
return (
<div className="App">
<h1>hello</h1>
</div>
<>
<GlobalStyle />
<BgWrapper>{name ? <MainPage /> : <WelcomePage />}</BgWrapper>
</>
);
}

Expand Down
Binary file added src/assests/bgImage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions src/components/CountDown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { useRef, useState, useEffect } from "react";
import { ColumnWrap, CountDownWrapper } from "./style/Elements";

const SpecialCountdown = (props) => {
const [timerDays, setTimerDays] = useState("00");
const [timerHours, setTimerHours] = useState("00");
const [timerMinutes, setTimerMinutes] = useState("00");
const [timerSeconds, setTimerSrconds] = useState("00");
const { date, year, month } = JSON.parse(localStorage.getItem("date"));
let interval = useRef();

const startTimer = () => {
const countdownDate = new Date(
`${month} ${date} ${year} 00:00:00`
).getTime();

interval = setInterval(() => {
const now = new Date().getTime();
const distance = countdownDate - now;

const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);

if (distance < 0) {
clearInterval(interval.current);
} else {
setTimerDays(days);
setTimerHours(hours);
setTimerMinutes(minutes);
setTimerSrconds(seconds);
}
}, 1000);
};

useEffect(() => {
startTimer();
return () => {
clearInterval(interval.current);
};
});

return (
<CountDownWrapper>
<ColumnWrap>
<span>{timerDays}</span>
<span>
<p>Days</p>
</span>
</ColumnWrap>
<small>:</small>
<ColumnWrap>
<span>{timerHours}</span>
<span>
<p>Hours</p>
</span>
</ColumnWrap>
<small>:</small>
<ColumnWrap>
<span>{timerMinutes}</span>
<span>
<p>Min</p>
</span>
</ColumnWrap>
<small>:</small>
<ColumnWrap>
<span>{timerSeconds}</span>
<span>
<p>Sec</p>
</span>
</ColumnWrap>
</CountDownWrapper>
);
};

export default SpecialCountdown;
25 changes: 25 additions & 0 deletions src/components/Greetings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { getDataActions } from "../store/extData";

const Greetings = () => {
const dispatch = useDispatch();
const greeting = useSelector((state) => state.extData.greetings);
const name = localStorage.getItem("name");

useEffect(() => {
const hour = new Date().getHours();
if (hour < 4) dispatch(getDataActions.setGreetings("Good Night"));
else if (hour < 11) dispatch(getDataActions.setGreetings("Good Morning"));
else if (hour < 16) dispatch(getDataActions.setGreetings("Good Afternoon"));
else if (hour < 19) dispatch(getDataActions.setGreetings("Good Evening"));
else dispatch(getDataActions.setGreetings("Good Night"));
}, []);

return (
<h1>
{greeting},{name}
</h1>
);
};
export default Greetings;
18 changes: 18 additions & 0 deletions src/components/Time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TimeWrapper } from "./style/Elements";

const Time = () => {
const getime = () => {
return (
new Date()
.getHours()
.toLocaleString("en-US", { minimumIntegerDigits: 2 }) +
":" +
new Date()
.getMinutes()
.toLocaleString("en-US", { minimumIntegerDigits: 2 })
);
};
return <TimeWrapper>{getime()}</TimeWrapper>;
};

export default Time;
9 changes: 9 additions & 0 deletions src/components/documentTitle/Title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useEffect } from "react";

const Title = (title) => {
useEffect(() => {
document.title = `Vaspacx Chrome | ${title}`;
}, [title]);
};

export default Title;
26 changes: 26 additions & 0 deletions src/components/edit/Edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { useDispatch } from "react-redux";
import { getDataActions } from "../../store/extData";
import { SecBtn } from "../style/Button";
import { BottomWrapper } from "../style/Elements";

const Edit = () => {
const dispatch = useDispatch();
const name = localStorage.getItem("name");
const editDeadlineHandler = () => {
dispatch(getDataActions.setFlag());
};

const editNameHandler = () => {
dispatch(getDataActions.updateName(""));
localStorage.setItem("name", "");
};
return (
<BottomWrapper>
<SecBtn onClick={editDeadlineHandler}>Edit Deadline</SecBtn>
{name !== "" && <SecBtn onClick={editNameHandler}>Edit Name</SecBtn>}
</BottomWrapper>
);
};

export default Edit;
24 changes: 24 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export {
BgWrapper,
GlobalStyle,
CenterWrapper,
InputName,
DateContainer,
TimeWrapper,
CountDownWrapper,
DetailContainer,
ColumnWrap,
BottomWrapper,
TempWrapper,
TodoWrapper,
WeatherWrapper,
UpperBox,
InputCitySearch,
} from "./style/Elements";

export {
EffectButton,
TransparentBtn,
WeatherBtn,
SecBtn,
} from "./style/Button";
17 changes: 17 additions & 0 deletions src/components/quotes/Quotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { quotesDB } from "../../database/quotes";
import { QuotesWrapper } from "../style/Elements";

const randomQuotes = () => {
const randomNum = Math.floor(Math.random() * quotesDB.length);
return quotesDB[randomNum];
};
const Quotes = () => {
const quote = randomQuotes();
return (
<QuotesWrapper>
<h1>{quote.quoteText}</h1>
<p>-{quote.quoteAuthor}</p>
</QuotesWrapper>
);
};
export default Quotes;
57 changes: 57 additions & 0 deletions src/components/style/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import styled from "styled-components";

export const EffectButton = styled.button`
width: 70px;
background: linear-gradient(138deg, var(--sec-color) 65%, white 36%);
cursor: pointer;
transition: all 0.5s ease-in-out;
height: 40px;
display: flex;
font-weight: bold;
padding: 9px 10px;
margin: 1px;
border: none;
letter-spacing: 1px;
border-radius: 6px;
color: var(--primary-color);
justify-content: space-between;

&:hover {
justify-content: center;
background: linear-gradient(189deg, var(--sec-color) 75%, white 36%);
color: #ffffff;
}
i {
color: #ffffff;
}
`;

export const SecBtn = styled.div`
border: none;
color: var(--grey-color);
font-size: 15px;
background: transparent;
cursor: pointer;
`;

export const WeatherBtn = styled.div`
background-color: transparent;
border: none;
color: var(--grey-color);
text-align: end;
margin-top: 5px;

&:hover {
cursor: pointer;
color: var(--primary-color);
}
`;

export const TransparentBtn = styled.button`
background: transparent;
border: 2px solid var(--primary-color);
color: white;
cursor: pointer;
width: auto;
padding: 0.5rem;
`;
Loading