Commit cc3f6915 authored by Noran Baskaran's avatar Noran Baskaran
Browse files

Merge branch 'issue-12-customization' into 'master'

Issue 12 customization

Closes #12

See merge request !13
parents e54faf11 e8023a42
/**
* Enum for keeping track of the colors
*/
export enum Color {
RANDOM = -1,
RED = 0,
GREEN = 1,
BLUE = 2,
}
import { Color } from "./Enums";
/**
* All the animation-functions will have a specification of color (or default = Color.RANDOM) and a boolean clear (or default = false)
*/
......@@ -35,8 +26,14 @@ const randomRGB = (specification: Color = Color.RANDOM): string => {
const greenMult: number = specification === Color.GREEN ? 255 : 50;
const blueMult: number = specification === Color.BLUE ? 255 : 50;
const red: string = toPaddedHexString(Math.floor(Math.random() * redMult), 2);
const green: string = toPaddedHexString(Math.floor(Math.random() * greenMult), 2);
const blue: string = toPaddedHexString(Math.floor(Math.random() * blueMult), 2);
const green: string = toPaddedHexString(
Math.floor(Math.random() * greenMult),
2
);
const blue: string = toPaddedHexString(
Math.floor(Math.random() * blueMult),
2
);
return red + green + blue;
};
......
html {
height: 100%;
width: 100%;
height: 100%;
width: 100%;
}
header {
padding-top: 2%;
padding-bottom: 2%;
margin-bottom: 2%;
background-color: #202040;
padding-top: 2%;
padding-bottom: 2%;
margin-bottom: 2%;
background-color: #202040;
}
body {
background-color: #1b1b36;
color: #e5e5e5;
text-align: center;
padding: 0.5%;
height: 100%;
line-height: 2;
font-size: 1.1rem;
font-family: Arial, Helvetica, sans-serif;
background-color: #1b1b36;
color: #e5e5e5;
text-align: center;
padding: 0.5%;
height: 100%;
line-height: 2;
font-size: 1.1rem;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
margin: auto;
line-height: 1.2;
margin: auto;
line-height: 1.2;
}
header > h1 {
text-decoration: none;
font-weight: 500;
font-size: 5.05rem;
header>h1 {
text-decoration: none;
font-weight: 500;
font-size: 5.05rem;
}
#lightfavouritebutton {
background: white;
}
h2 {
line-height: 1.2;
font-weight: 400;
font-size: 3.4rem;
text-decoration: underline;
line-height: 1.2;
font-weight: 400;
font-size: 3.4rem;
text-decoration: underline;
}
h3 {
line-height: 1.2;
font-size: 2.25rem;
line-height: 1.2;
font-size: 2.25rem;
}
#wrapperdiv {
padding-left: 5%;
padding-right: 5%;
height: 100%;
padding-left: 5%;
padding-right: 5%;
height: 100%;
}
button {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.6), 0 6px 20px 0 rgba(0, 0, 0, 0.6);
border: 1px solid #602080;
box-sizing: border-box;
font-weight: 300;
color: #e5e5e5;
text-align: center;
transition: all 0.2s ease-in-out;
background-color: #602080;
margin-bottom: 3%;
padding: 1%;
width: 20%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.6), 0 6px 20px 0 rgba(0, 0, 0, 0.6);
border: 1px solid #602080;
box-sizing: border-box;
font-weight: 300;
color: #e5e5e5;
text-align: center;
transition: all 0.2s ease-in-out;
background-color: #602080;
margin-bottom: 3%;
padding: 1%;
width: 20%;
}
button:hover {
color: #000000;
background-color: #e5e5e5;
transform: scale(1.1);
color: #000000;
background-color: #e5e5e5;
transform: scale(1.1);
}
.buttons {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: flex-start;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: flex-start;
}
.buttons2 {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: flex-start;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: flex-start;
}
#redbtn {
background-color: red;
background-color: red;
}
#greenbtn {
background-color: green;
background-color: green;
}
#bluebtn {
background-color: blue;
background-color: blue;
}
.navigation {
background-color: #b030b0;
background-color: #b030b0;
}
#muteButton {
display: flex;
flex-direction: row;
justify-content: space-evenly;
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
#canvasAndLines {
display: flex;
flex-direction: row-reverse;
justify-content: space-evenly;
display: flex;
flex-direction: row-reverse;
justify-content: space-evenly;
}
p {
font-family: Esteban;
font-weight: 350;
font-weight: 350;
}
#lines {
width: 50%;
width: 50%;
}
#wrapperdiv hr {
border: 0;
height: 1px;
background-image: linear-gradient(to right, #202040, #b030b0, #202040);
border: 0;
height: 1px;
background-image: linear-gradient(to right, #202040, #b030b0, #202040);
}
canvas {
border: 7px double #b030b0;
background: black;
width: 400px;
height: 500px;
margin-left: 10%;
margin-right: 10%;
border: 7px double #b030b0;
background: black;
width: 400px;
height: 500px;
margin-left: 10%;
margin-right: 10%;
}
.lds-ring {
display: inline-block;
position: center;
width: 80px;
height: 80px;
display: inline-block;
position: center;
width: 80px;
height: 80px;
}
.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid rgb(158, 45, 45);
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: #b030b0 transparent transparent transparent;
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid rgb(158, 45, 45);
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: #b030b0 transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/*Example width: ipad 768 width*/
@media only screen and (max-width: 770px) and (min-width: 550px) {
html {
height: 100vh;
width: 100vw;
margin: 0;
}
body {
margin: 0%;
padding: 0%;
width: 100vw;
height: 100vh;
}
button {
transition: 0.5s ease-in-out;
width: 100%;
border-radius: 12px;
}
.buttons {
flex-wrap: wrap;
}
/*
/*Example width: ipad 768 width*/
@media only screen and (max-width: 770px) and (min-width: 550px) {
html {
height: 100vh;
width: 100vw;
margin: 0;
}
body {
margin: 0%;
padding: 0%;
width: 100vw;
height: 100vh;
}
button {
transition: 0.5s ease-in-out;
width: 100%;
border-radius: 12px;
}
.buttons {
flex-wrap: wrap;
}
/*
No hover property on tablet and mobile devices.
*/
button:hover {
transform: unset;
background-color: #602080;
color: #e5e5e5;
}
header > h1 {
text-decoration: none;
font-weight: 500;
font-size: 4rem;
}
h2 {
line-height: 1.2;
font-weight: 400;
font-size: 2.6rem;
text-decoration: underline;
}
h3 {
line-height: 1.2;
font-size: 2rem;
}
#canvasAndLines {
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
#lines {
margin-top: 5%;
}
button:hover {
transform: unset;
background-color: #602080;
color: #e5e5e5;
}
header>h1 {
text-decoration: none;
font-weight: 500;
font-size: 4rem;
}
h2 {
line-height: 1.2;
font-weight: 400;
font-size: 2.6rem;
text-decoration: underline;
}
h3 {
line-height: 1.2;
font-size: 2rem;
}
#canvasAndLines {
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: wrap;
align-items: center;
}
#lines {
margin-top: 5%;
}
}
@media only screen and (max-width: 500px) {
html {
height: 100vh;
width: 100vw;
margin: 0;
}
body {
margin: 0%;
padding: 0%;
width: 100vw;
height: 100vh;
}
button {
transition: 0.5s ease-in-out;
width: 100%;
border-radius: 12px;
}
.buttons {
flex-wrap: wrap;
}
/*
html {
height: 100vh;
width: 100vw;
margin: 0;
}
body {
margin: 0%;
padding: 0%;
width: 100vw;
height: 100vh;
}
button {
transition: 0.5s ease-in-out;
width: 100%;
border-radius: 12px;
}
.buttons {
flex-wrap: wrap;
}
/*
No hover property on tablet and mobile devices.
*/
button:hover {
transform: unset;
background-color: #602080;
color: #e5e5e5;
}
#canvasAndLines {
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
}
#lines {
margin-top: 5%;
width: unset;
}
canvas {
width: 100%;
height: auto;
}
header > h1 {
text-decoration: none;
font-weight: 500;
font-size: 3rem;
}
h2 {
line-height: 1.2;
font-weight: 400;
font-size: 2rem;
text-decoration: underline;
}
h3 {
line-height: 1.2;
font-size: 1.3rem;
}
}
button:hover {
transform: unset;
background-color: #602080;
color: #e5e5e5;
}
#canvasAndLines {
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
}
#lines {
margin-top: 5%;
width: unset;
}
canvas {
width: 100%;
height: auto;
}
header>h1 {
text-decoration: none;
font-weight: 500;
font-size: 3rem;
}
h2 {
line-height: 1.2;
font-weight: 400;
font-size: 2rem;
text-decoration: underline;
}
h3 {
line-height: 1.2;
font-size: 1.3rem;
}
}
\ No newline at end of file
......@@ -3,9 +3,12 @@ import Exhibition from "./components/Exhibition";
import { fetchPoetryFromPoetryDB } from "./PoetryAPI";
import Header from "./components/Header";
import LocalStorageManager from "./LocalStorageManager";
import { animate, Color } from "./Animations";
import { animate } from "./Animations";
import { Color, Theme, Font } from "./Enums";
import "./App.css";
import SessionStorageManager from "./SessionStorageManager";
const ssm: SessionStorageManager = new SessionStorageManager();
/**
* Main function loaded into the page from index.tsx
*/
......@@ -26,23 +29,46 @@ const App: React.FC = () => {
* loading: boolean
* favourites: number[]
* theme: number
* font: Font = {
* ESTABAN = "Estaban",
* LOBSTER = "Lobster",
* }
* color: Color = {
* RANDOM = -1,
* RED = 0,
* GREEN = 1,
* BLUE = 2,
* }
* userEdit: boolean
* errorDisplay: boolean
* sessionStack: SessionConfig = {
* color: Color,
* font: Font,
* theme: Theme
* }
*/
const [installationList, setInstallationList] = useState<InstallationList>();
const [installation, setInstallation] = useState<Installation>();
const [currentIndex, setCurrentIndex] = useState<number>(0);
const [loading, setLoading] = useState<boolean>(false);
const [favourites, setFavourites] = useState<number[]>([]);
const [theme, setTheme] = useState<number>(0);
const [theme, setTheme] = useState<Theme>(Theme.DARK);
const [font, setFont] = useState<Font>(Font.ESTEBAN);
const [color, setColor] = useState<Color>(Color.RANDOM);
const [userEdit, setUserEdit] = useState<boolean>(true);
const [errorDisplay, setErrorDisplay] = useState<boolean>(false);
const [sessionStack, setSessionStack] = useState<SessionConfig[]>([]);
const lsm: LocalStorageManager = new LocalStorageManager();
/**
* Calls the loadPoetry method one time when the page is loaded.
*/
useEffect(() => {
loadPoetry();
fetchFromLocalStorage();
if (userEdit) {
loadPoetry();
fetchFromLocalStorage();
fetchFromSessionStorage();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
......@@ -50,20 +76,28 @@ const App: React.FC = () => {
* Will load the user state with the config saved in localstorage. If nothing is stored in the localstorage, it will use
* the default config constant located inside the LocalStorageManager.
*/
const fetchFromLocalStorage = () => {
const fetchFromLocalStorage = (): void => {
const config: UserConfig = lsm.getUserConfig();
setFavourites(config.favourites);
setTheme(config.theme);
console.log(
`Loading user with favourites: ${config.favourites} and theme: ${config.theme}`
);
};
const fetchFromSessionStorage = (): void => {
const stack: SessionConfig[] = ssm.parse();
if (!stack || stack.length < sessionStack.length) {
return;
}