Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4523892
feat(local storage): now storing used themes very basically
Sep 6, 2022
679260d
feat(localstorage): a wobbly version one of making sure that the same…
claraewaisaksson Sep 7, 2022
2c51264
feat(localstorage): a more solid version of removing the used themes …
claraewaisaksson Sep 7, 2022
7859ca7
style(styling): the used themes are now displayed last in the dropdow…
claraewaisaksson Sep 7, 2022
4f4b0c9
style(effects): hid the dice buttons when they shouldn't be active
claraewaisaksson Sep 8, 2022
1625fa8
feat(localstorage): employees who have been randomised as office host…
claraewaisaksson Sep 8, 2022
975932a
feat(localstorage): Code from Pamp, help with creating a localStorage…
claraewaisaksson Sep 8, 2022
18c96e9
feat(localstorage): Pamp's code now works as expected regarding the t…
claraewaisaksson Sep 8, 2022
f5078bd
feat(localstorage): themes and office hosts that have been chosen/ran…
claraewaisaksson Sep 8, 2022
fac9cf5
fix(localstorage): fixed bug when employees array run out + fixed coh…
claraewaisaksson Sep 9, 2022
ce0f57a
refactor(codecompressing): cleaned up the code a little bit, mostly d…
claraewaisaksson Sep 9, 2022
ed9af6f
feat(localStorage): when a randomised theme gets 'de-selected' throug…
claraewaisaksson Sep 12, 2022
eafbcca
fix(localStorage): fixed the bug that removed the first item of the s…
claraewaisaksson Sep 12, 2022
414f370
feat(localStorage): the randomised theme that is de-selected by the u…
claraewaisaksson Sep 13, 2022
c943de7
feat(localStorage): the office host who is de-selected through a dice…
claraewaisaksson Sep 13, 2022
dd82ce4
refactor(localStorage): this app is now filled with bugs... the code …
claraewaisaksson Sep 13, 2022
d2d5c04
refactor(cleanerCode): made the if conditional of selecting random of…
claraewaisaksson Sep 13, 2022
c79932c
feat(localStorage): the themes that has already been are now safely r…
claraewaisaksson Oct 17, 2022
e573eea
feat(localStorage): used employees are now safely removed from the em…
claraewaisaksson Oct 17, 2022
e13fc1c
feat(localStorage): when all employees have been used up the employee…
claraewaisaksson Oct 17, 2022
854806d
refactor(small fix): developed the code so it reduces the risk of bugs
claraewaisaksson Oct 17, 2022
94826f6
feat(localStorage): the themes array is now safely restored when all …
claraewaisaksson Oct 17, 2022
72c0309
feat(localStorage): implemented a somewhat inadequate but working sol…
claraewaisaksson Oct 18, 2022
f5ce462
feat(localStorage): deselected persons are now added to the employees…
claraewaisaksson Oct 18, 2022
21ff44c
feat(localStorage): themes that are deselected by manually choosing a…
claraewaisaksson Oct 18, 2022
c5f8ade
feat(localStorage): themes that are deselected by selecting a new the…
claraewaisaksson Oct 18, 2022
142619e
refactor(gif): the confetti gif is now triggered by user actions, not…
claraiskssn Oct 18, 2022
dd218d0
refactor(new components): split the code up into more smaller components
claraiskssn Oct 19, 2022
914fda3
refactor(comment cleanup): removed non-working outcommented code
claraiskssn Oct 19, 2022
d5fbf0e
refactor(experiment): removed '?' and 'loading...' from the JSON list…
claraiskssn Oct 19, 2022
c208ebe
refactor(cleanup): comment cleanup and small bug avoidance (not allow…
claraiskssn Oct 19, 2022
511ae44
refactor/fix(localStorage): fixed the bug that allowed the same theme…
claraiskssn Oct 20, 2022
8e8e782
refactor(clean&prep): small cleanups of comments & preparations for p…
claraiskssn Oct 20, 2022
46a1364
refactor(small changes): itty bitty refactors of the code
claraiskssn Nov 4, 2022
e5dd179
feat(quote API): added a quote API that generates random famous quote…
claraiskssn Nov 10, 2022
126dbcf
style(responsiveness): tried to make the app more responsive.
claraiskssn Nov 18, 2022
67e3114
refactor(new state): added a useState for the background color becaus…
claraiskssn Nov 21, 2022
fcc6b69
style(responsiveness): added a slight padding to the randomise all bu…
claraiskssn Nov 21, 2022
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
398 changes: 250 additions & 148 deletions src/App.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/components/DiceButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Button from "./Button";

const DiceButton = ({ clickHandler }) => {
return (
<>
<Button
buttonImage={
<img
src={require("../images/dice.png")}
className="absolute -top-5 laptop:top-10 13tum:top-20 right-2 laptop:right-10 13tum:right-20 standingiPad:p-2 standingiPad:bg-mustard standingiPad:border-2 border-darkblue h-12 standingiPad:h-20 w-12 standingiPad:w-20 laptop:hover:drop-shadow-block-right"
/>
}
clickHandler={clickHandler}
/>
</>
);
};

export default DiceButton;
27 changes: 21 additions & 6 deletions src/components/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}

const Dropdown = ({ themes, handleSetTheme }) => {

const Dropdown = ({ themes, storedThemes, handleSetTheme }) => {
return (
<Menu as="div" className="relative">
<div>
<Menu.Button className="justify-between inline-flex text-left w-full bg-mustard p-2 border-2 border-darkblue hover:drop-shadow-block-right">
Pick new theme
<Menu.Button className="justify-between inline-flex text-left w-full bg-mustard p-2 border-2 border-darkblue laptop:hover:drop-shadow-block-right">
Pick a new theme &nbsp;
<div id="chevrondownicon">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -45,12 +44,17 @@ const Dropdown = ({ themes, handleSetTheme }) => {
<div>
{themes.map((theTheme) => {
return (
<Menu.Item onClick={() => handleSetTheme(theTheme.theme)} key={theTheme.theme}>
<Menu.Item
onClick={() => handleSetTheme(theTheme)}
key={theTheme.theme}
>
{({ active }) => (
<a
href="#"
className={classNames(
active ? "bg-mustard text-darkblue" : "bg-almostwhite",
active
? "bg-mustard text-darkblue"
: "bg-almostwhite text-darkblue",
"block px-4 py-2 text-base"
)}
>
Expand All @@ -60,6 +64,17 @@ const Dropdown = ({ themes, handleSetTheme }) => {
</Menu.Item>
);
})}
{storedThemes.map((storedTheme) => {
return (
<Menu.Item key={storedTheme}>
{
<p className="bg-chinesesilver text-gray block px-4 py-2 text-base">
{storedTheme}
</p>
}
</Menu.Item>
);
})}
</div>
</Menu.Items>
</Transition>
Expand Down
13 changes: 13 additions & 0 deletions src/components/Image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const Image = ({ clickHandler, name }) => {
return (
<>
<img
className="rounded-lg"
onClick={clickHandler}
src={require(`../images/${name === "?" ? "unknown" : name}.png`)}
/>
</>
);
};

export default Image;
11 changes: 11 additions & 0 deletions src/components/Name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const Name = ({ name }) => {
return (
<>
<h1 className="border-2 p-2 rounded-md bg-almostwhite text-md standingiPad:text-2xl">
{name}
</h1>
</>
);
};

export default Name;
55 changes: 31 additions & 24 deletions src/components/Person.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
import { useState, useLayoutEffect } from "react";
import Button from "./Button";
import { useState } from "react";
import Image from "./Image";
import Quote from "./Quote";
import Name from "./Name";

function makeRandom(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min);
}

//fetching the name and quote of the employee that is sent as a props from app.js
const Person = ({ name, quote }) => {
const Person = ({ name }) => {
//defining what should be targeted when state changes?
const [showQuote, setShowQuote] = useState(false);
const [quote, setQuote] = useState("");
const [author, setAuthor] = useState("");

//listens to whether showQuote is true or false, and makes the quote disappear from the screen after 3 seconds through changing the showQuote to false after 3 seconds when it has become true.
useLayoutEffect(() => {
async function handleShowQuote() {
await fetch("https://type.fit/api/quotes")
.then(function (response) {
return response.json();
})
.then(function (data) {
let quoteObj = data[makeRandom(0, data.length)];
setQuote(`"${quoteObj.text}"`);
if (quoteObj.author !== null) {
setAuthor(`-${quoteObj.author}`);
}
});
name !== "?" ? setShowQuote(true) : setShowQuote(false);
setTimeout(() => {
setShowQuote(false);
}, 5500);
}, [showQuote]);

//defining the image to be sent off to button through quote
const buttonImage = (
<img
className="rounded-lg"
src={require(`../images/${name === "?" ? "unknown" : name}.png`)}
/>
);
}

//calling the button with my quote component and displaying the employee name
return (
<div>
{showQuote && <Quote quote={quote} />}
<div id="image-container" className="p-10">
<Button
buttonImage={buttonImage}
clickHandler={() => setShowQuote(true)}
/>
<div className="tiltedPhone:p-8">
{showQuote && <Quote quote={quote} author={author} />}
<div id="image-container" className="pb-5">
<Image name={name} clickHandler={handleShowQuote} />
</div>
<h1 className="border-2 p-2 rounded-md bg-almostwhite text-2xl">
{name}
</h1>
<Name name={name} />
</div>
);
};
Expand Down
16 changes: 11 additions & 5 deletions src/components/Quote.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
//defining the quoteValue to employees.quote from person.js
const Quote = ({ quote }) => {

const Quote = ({ quote, author }) => {
//the button component is called and when the button is clicked showQuote turns true, which makes the quote appears on screen.
return (
<div className="">
<div className="absolute right-48 top-0 left-2 border-2 border-darkblue bg-almostwhite rounded-br-none rounded-lg">
<p className="p-2">{quote}</p>
<div className="absolute flex-wrap h-40 standingiPad:h-36 laptop:h-32 right-2 standingiPad:right-28 laptop:right-40 -top-44 standingiPad:-top-20 laptop:-top-2 left-2 border-2 text-sm iPad:text-xs 13tum:text-lg border-darkblue bg-almostwhite standingiPad:rounded-br-none rounded-lg">
<div className="flex items-center flex-wrap h-full">
<div className="justify-center">
<div className="p-2 pb-4">
<p>{quote}</p>
</div>
</div>
<div className="absolute pb-2 bottom-0 right-2">
<p>{author}</p>
</div>
</div>
</div>
);
};

Expand Down
23 changes: 2 additions & 21 deletions src/components/Theme.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
import { useState, useEffect } from "react";

//fetching the true/false value from randomise, and the theme that is picked randomly.
const Theme = ({ randomise, theme }) => {

//initiating the state and statehandler.
const [showTheme, setShowTheme] = useState(false);

//listening to when the randomise value changes and if it changes to true then I call the statehandler to change the showTheme value to true
useEffect(() => {
if (randomise) {
setShowTheme(true);
}
}, [randomise]);

//show the theme in text when showTheme is true
const Theme = ({ theme }) => {
return (
<>
{showTheme ? (
<>
<h1 className="pb-5">{theme}</h1>
</>
) : null}
<h1 className="pb-5 overflow-auto">{theme.theme}</h1>
</>
);
};
Expand Down
8 changes: 0 additions & 8 deletions src/data/employees.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
[
{
"name": "?",
"quote": "?"
},
{
"name": "loading...",
"quote": "loading"
},
{
"name": "Jenny Andersson",
"quote": "Be yourself; everyone else is already taken. - Oscar Wilde"
Expand Down
Loading