Skip to content

Commit

Permalink
Merge branch 'staging' into cart-page
Browse files Browse the repository at this point in the history
  • Loading branch information
thelmaboamah authored Sep 11, 2023
2 parents 0463122 + c035909 commit 908444d
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 69 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Binary file added client/public/strawberry-icecream.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default function App() {
return <div></div>;
}

Binary file added client/src/assets/images/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions client/src/assets/images/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Arrow from './assets/images/arrow.png'
import Strawberry from './assets/images/toppings/strawberry.png'

export {
Arrow,
Strawberry
};
Binary file added client/src/assets/images/toppings/caramel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/toppings/chocolate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/toppings/marshmallow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/toppings/nuts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/toppings/sprinkles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/toppings/strawberry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions client/src/components/ArrowButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.arrow-button {
width: 50px;
height: 50px;
margin-right: 10px;
}
18 changes: 18 additions & 0 deletions client/src/components/ArrowButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Arrow from "../assets/images/arrow.png"

import "./ArrowButton.css";

interface ArrowProps {
rotation: number // 0 points left, 90 points up, 180 points right, 270 points down
handleClick: (direction: string) => void
}

function ArrowButton(props: ArrowProps) {

return (
<img className='arrow-button' src={Arrow} style={{ transform: `rotate(${props.rotation}deg)` }}
onClick={() => props.handleClick(`${props.rotation < 180 ? 'left' : 'right'}`)} />
);
}

export default ArrowButton;
25 changes: 25 additions & 0 deletions client/src/components/FlavorThumbnail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styles from "./flavor-thumbnail.module.css";

export type Flavor = {
name: string,
price: number,
image: string,
};


export default function FlavorThumbnail( {flavor} : {flavor: Flavor}) {
return (
<>
<div className={styles.container}>
<img
className={styles.image}
src={flavor.image}
alt={`Photo of ${flavor.name}`}
/>
<p className={styles.text}><strong>{flavor.name}</strong></p>
<p className={styles.text}>${flavor.price}</p>
</div>
</>

);
}
17 changes: 17 additions & 0 deletions client/src/components/Suggestions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.suggestion-list {
text-align: center;
padding: 0;
margin-block: 5;
}

.suggestion-item {
width: 20%;
display: inline-block;
padding: 10px;
vertical-align: top;
}

.suggestion-image {
max-width: 100%;
height: auto;
}
32 changes: 32 additions & 0 deletions client/src/components/Suggestions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import "./Suggestions.css";

type SuggestionItemProps = {
id: number;
image: string;
urlLink: string;
};

type SuggestionListProps = {
itemList: SuggestionItemProps[];
};

function SuggestionItem(item: SuggestionItemProps) {
return (
<div className="suggestion-item">
<a href={item.urlLink} target="_blank" rel="noreferrer">
<img className="suggestion-image" src={item.image} alt="flavor" />
</a>
</div>
);
}

export default function Suggestions({ itemList }: SuggestionListProps) {
return (
<div className="suggestion-list">
<p>This flavor goes well with:</p>
{itemList.map((item) => (
<SuggestionItem key={item.id} {...item} />
))}
</div>
);
}
5 changes: 5 additions & 0 deletions client/src/components/ToppingButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.topping-img {
width: 50px;
height: 50px;
margin-right: 10px;
}
26 changes: 26 additions & 0 deletions client/src/components/ToppingButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useState } from "react";

import "./ToppingButton.css";

interface ToppingButtonProps {
url: string,
selected: boolean
}

ToppingButton.defaultProps = {
selected: false
}

function ToppingButton(props: ToppingButtonProps) {
const [selected, setSelected] = useState(false);
return (
<div key={props.url}>
<div onClick={() => setSelected(!selected)}>
<img className='topping-img' src={props.url} alt="" onClick={() => console.log(props.url)} />
<p style={{ marginTop: '0px' }}>{selected ? '✅' : '🥄'}</p>
</div>
</div>
);
}

export default ToppingButton;
3 changes: 3 additions & 0 deletions client/src/components/ToppingsBar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.toppingbar-title {
text-align: 'center';
}
18 changes: 18 additions & 0 deletions client/src/components/ToppingsBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useState } from "react";
import ToppingsCarousel from "./ToppingsCarousel";

import "./ToppingsBar.css";

function ToppingsBar() {

return (
<>
<div className='toppingbar-title'>
<strong>toppings</strong>
<ToppingsCarousel />
</div>
</>
);
}

export default ToppingsBar;
5 changes: 5 additions & 0 deletions client/src/components/ToppingsCarousel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.toppings-carousel {
display: flex;
flex-direction: row;
overflow: auto;
}
50 changes: 50 additions & 0 deletions client/src/components/ToppingsCarousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useState } from "react";
import ArrowButton from "./ArrowButton";
import ToppingButton from "./ToppingButton";
import Strawberry from "../assets/images/toppings/strawberry.png";
import Chocolate from "../assets/images/toppings/chocolate.png"
import Nuts from "../assets/images/toppings/nuts.png"
import Sprinkles from "../assets/images/toppings/sprinkles.png"
import Caramel from "../assets/images/toppings/caramel.png"
import Marshmallow from "../assets/images/toppings/marshmallow.png"

import "./ToppingsCarousel.css";

const left = 0
const right = 180

function ToppingsCarousel() {
const [toppingImgUrls, setToppingImgUrls] = useState([Caramel, Marshmallow, Strawberry, Chocolate, Nuts, Sprinkles]);
function rotateArr(direction: string): void {
// don't mutate original array. make a copy then mutate the copy
let newArr: string[] = toppingImgUrls.slice();
if (newArr.length > 1) {
if (direction == 'left') {
// .shift() removes and returns the first element of the array.
// .push() pushes the value onto the end of the array.
let x = newArr.shift();
if (x) newArr.push(x);
} else {
// .pop() removes and returns the last element of the array.
// .unshift() 'pushes' the value onto the beginning of the array.
let x = newArr.pop();
if (x) newArr.unshift(x);
}
}
setToppingImgUrls(newArr);
}

return (
<div className='toppings-carousel'>
<ArrowButton rotation={left} handleClick={rotateArr} />
{toppingImgUrls.map((url, index) => (
<div key={url} hidden={index > 4 ? true : false}>
<ToppingButton url={url} />
</div>
))}
<ArrowButton rotation={right} handleClick={rotateArr} />
</div>
);
}

export default ToppingsCarousel;
18 changes: 18 additions & 0 deletions client/src/components/flavor-thumbnail.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');

.container {
width: 200px;
height: 300px;
border: 1px solid lightgrey;
text-align: center;
}

.image {
width: 86%;
height: 66.6667%;
object-fit: contain;
}

.text {
font-family: 'Roboto', sans-serif;
}
69 changes: 0 additions & 69 deletions client/src/index.css

This file was deleted.

0 comments on commit 908444d

Please sign in to comment.