diff --git a/front/src/components/DropDown.svelte b/front/src/components/DropDown.svelte
index 2ad8b56..811697f 100644
--- a/front/src/components/DropDown.svelte
+++ b/front/src/components/DropDown.svelte
@@ -6,12 +6,10 @@
-
+
@@ -28,6 +26,8 @@
.dropdown-header {
padding: $spacing-normal;
+ width: 100%;
+
position: relative;
display: flex;
@@ -35,12 +35,15 @@
justify-content: space-between;
align-items: center;
- p {
+ border: 0 solid transparent;
+ background-color: transparent;
+
+ .dropdown-text {
font-size: $font-size-h6;
font-weight: $font-weight-bold;
}
- button {
+ .dropdown-button {
padding: 0;
height: 100%;
@@ -62,9 +65,13 @@
color: $color-on-light;
transition: transform 0.1s ease-in-out;
+ }
- &:hover {
+ &:hover, &:focus-visible {
+ .dropdown-button {
color: $color-primary;
+ outline: 0 solid transparent;
+ transform: rotate(-15deg);
}
}
}
@@ -76,11 +83,15 @@
&.open {
.dropdown-header {
- //padding: $spacing-normal $spacing-normal $spacing-small;
-
- button {
+ .dropdown-button {
transform: rotate(-180deg);
}
+
+ &:hover, &:focus-visible {
+ .dropdown-button {
+ transform: rotate(calc(-180deg + 15deg));
+ }
+ }
}
.dropdown-content {
display: block;
diff --git a/front/src/lib/cart.ts b/front/src/lib/cart.ts
index 761f872..8b04d05 100644
--- a/front/src/lib/cart.ts
+++ b/front/src/lib/cart.ts
@@ -1,24 +1,23 @@
import { type Writable, get, writable } from "svelte/store";
-import { type CartItem, type Item } from "./types";
+import { type CartRecord, type CartItem, type Item } from "./types";
import { getItemByUUID, postVerifyCart } from "./test-api";
function createCartStore() {
let loaded = false;
- const cart: Writable
> = writable({});
+ const cart: Writable = writable({});
- async function init() {
- let localData: Record = {};
+ async function init(): Promise {
+ let localData: CartRecord = {};
try {
localData = JSON.parse(localStorage.getItem("basket")) || {};
} catch {
- console.error("Local Cart data fucked");
+ console.error("Local Cart data could not be parsed");
}
try {
- const newData: Record =
- await postVerifyCart(localData);
+ const newData: CartRecord = await postVerifyCart(localData);
cart.set(newData);
} catch (error) {
console.error("Could not load basket:", error);
@@ -28,18 +27,16 @@ function createCartStore() {
}
async function addToCart(uuid: string, amount: number) {
- if (!loaded) {
- return;
- }
+ if (!loaded) return;
if (get(cart)[uuid] !== undefined) {
- cart.update((cart: Record) => {
+ cart.update((cart: CartRecord) => {
cart[uuid].amount += amount;
return cart;
});
} else {
await getItemByUUID(uuid).then((data: Item) => {
- cart.update((cart: Record) =>
+ cart.update((cart: CartRecord) =>
Object.assign({}, cart, {
[uuid]: { uuid, amount, data },
})
@@ -47,13 +44,9 @@ function createCartStore() {
});
}
- cart.update((cart: Record) => {
- if (cart[uuid].amount <= 0) {
- delete cart[uuid]; // skipcq: JS-0320
- } else if (cart[uuid].amount > 99) {
- cart[uuid].amount = 99; // skipcq: JS-0320
- }
-
+ cart.update((cart: CartRecord) => {
+ if (cart.uuid.amount <= 0) delete cart.uuid;
+ if (cart.uuid.amount > 99) cart.uuid.amount = 99;
return cart;
});
}
@@ -82,12 +75,10 @@ function createCartStore() {
return totalCartPrice;
}
- function removeByUUID(uuid: string) {
- if (!loaded) {
- return;
- }
+ function removeByUUID(uuid: string): void {
+ if (!loaded) return;
- cart.update((cart) => {
+ cart.update((cart: CartRecord) => {
delete cart[uuid]; // skipcq: JS-0320
return cart;
});
@@ -110,7 +101,7 @@ const Cart = createCartStore();
export const cartLoaded = Cart.init();
// Make sure to update localstorage on any changes
-Cart.subscribe((value) => {
+Cart.subscribe((value: CartRecord) => {
localStorage.setItem("basket", JSON.stringify(value));
});
diff --git a/front/src/lib/test-api.ts b/front/src/lib/test-api.ts
index 391b87a..6e59fba 100644
--- a/front/src/lib/test-api.ts
+++ b/front/src/lib/test-api.ts
@@ -71,12 +71,14 @@ export async function getItemByUUID(uuid: string): Promise- {
export async function postContactEmail(
name: string,
email: string,
+ reason: string,
message: string
): Promise {
await fakeDelay(200);
if (!name) throw new Error("Name missing");
if (!email) throw new Error("Email missing");
+ if (!reason) throw new Error("Reason missing");
if (!message) throw new Error("Message missing");
if (message.length < 150) throw new Error("Message FUCKED");
diff --git a/front/src/lib/types.ts b/front/src/lib/types.ts
index 2af39c7..0e48926 100644
--- a/front/src/lib/types.ts
+++ b/front/src/lib/types.ts
@@ -21,6 +21,8 @@ export type CartItem = {
data: Item;
};
+export type CartRecord = Record
+
export type JSONResponse = {
data?: {
item: Item[]; // Todo Make this not just item type
diff --git a/front/src/pages/Contact.svelte b/front/src/pages/Contact.svelte
index 224a8d9..796fc4d 100644
--- a/front/src/pages/Contact.svelte
+++ b/front/src/pages/Contact.svelte
@@ -1,5 +1,5 @@
@@ -96,13 +97,41 @@
-
+
+
+
+