Merge pull request #4 from Fluffy-Bean/deepsource-transform-5891e056

style: format code with Prettier
This commit is contained in:
Michał 2024-05-04 16:28:53 +01:00 committed by GitHub
commit 31a31a43e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 131 additions and 105 deletions

View file

@ -1,13 +1,13 @@
import TestData from '%/lib/test-data.ts'; import TestData from "%/lib/test-data.ts";
export async function getPopularToday() { export async function getPopularToday() {
const res = await fetch("/api/items") const res = await fetch("/api/items");
const data = res.json() const data = res.json();
if (res.ok) { if (res.ok) {
return data return data;
} else { } else {
throw new Error("Failed to fetch popular today") throw new Error("Failed to fetch popular today");
} }
} }

View file

@ -1,9 +1,8 @@
import { type Writable, get, writable } from "svelte/store"; import { type Writable, get, writable } from "svelte/store";
import {type CartItem, type Item } from './types'; import { type CartItem, type Item } from "./types";
import { getItemByUUID, postVerifyCart } from "./test-api"; import { getItemByUUID, postVerifyCart } from "./test-api";
// Load content from localstorage // Load content from localstorage
let local: Record<string, CartItem> = {}; let local: Record<string, CartItem> = {};
try { try {
@ -16,7 +15,7 @@ try {
throw error; // Hot potato style throw error; // Hot potato style
}); });
} catch { } catch {
console.error("Failed to load cart") console.error("Failed to load cart");
} }
// Store function // Store function
@ -30,14 +29,15 @@ function createCartStore() {
return cart; return cart;
}); });
} else { } else {
await getItemByUUID(uuid) await getItemByUUID(uuid).then((data: Item) => {
.then((data: Item) => {
cart.update((cart: Record<string, CartItem>) => cart.update((cart: Record<string, CartItem>) =>
Object.assign({}, cart, {[uuid]: { Object.assign({}, cart, {
[uuid]: {
uuid: uuid, uuid: uuid,
amount: amount, amount: amount,
data: data, data: data,
}}) },
})
); );
}); });
} }
@ -47,7 +47,7 @@ function createCartStore() {
delete cart[uuid]; delete cart[uuid];
} }
return cart; return cart;
}) });
} }
function getEntries(): [string, CartItem][] { function getEntries(): [string, CartItem][] {
@ -69,7 +69,7 @@ function createCartStore() {
function getTotalPrice(): number { function getTotalPrice(): number {
let totalCartPrice: number = 0; let totalCartPrice: number = 0;
Object.values(get(cart)).forEach((item: CartItem) => { Object.values(get(cart)).forEach((item: CartItem) => {
totalCartPrice += (item.amount * item.data.price); totalCartPrice += item.amount * item.data.price;
}); });
return totalCartPrice; return totalCartPrice;
} }
@ -78,7 +78,7 @@ function createCartStore() {
cart.update((cart) => { cart.update((cart) => {
delete cart[uuid]; delete cart[uuid];
return cart; return cart;
}) });
} }
return { return {
@ -89,7 +89,7 @@ function createCartStore() {
getTotalLength, getTotalLength,
getTotalPrice, getTotalPrice,
removeByUUID, removeByUUID,
} };
} }
// Create store // Create store

View file

@ -1,18 +1,15 @@
import { type CartItem, type Item } from './types'; import { type CartItem, type Item } from "./types";
import TestData from './test-data'; import TestData from "./test-data";
let cache: Record<string, any> = {}; let cache: Record<string, any> = {};
// @ts-ignore // @ts-ignore
async function fakeDelay(timeout: number = 1000) { async function fakeDelay(timeout: number = 1000) {
// @ts-ignore // @ts-ignore
await new Promise((resolve: TimerHandler) => setTimeout(resolve, timeout)); await new Promise((resolve: TimerHandler) => setTimeout(resolve, timeout));
} }
export async function getAnnouncements(): Promise<{ image: string }> {
export async function getAnnouncements(): Promise<{image: string}> {
if (cache["announcement_banner"] !== undefined) { if (cache["announcement_banner"] !== undefined) {
return cache["announcement_banner"]; return cache["announcement_banner"];
} }
@ -26,7 +23,6 @@ export async function getAnnouncements(): Promise<{image: string}> {
return data; return data;
} }
export async function getPopularToday(): Promise<Item[]> { export async function getPopularToday(): Promise<Item[]> {
if (cache["popular_today"] !== undefined) { if (cache["popular_today"] !== undefined) {
return cache["popular_today"]; return cache["popular_today"];
@ -39,8 +35,9 @@ export async function getPopularToday(): Promise<Item[]> {
return data; return data;
} }
export async function getMenuItems(): Promise<
export async function getMenuItems(): Promise<{name: string, items: Item[]}[]> { { name: string; items: Item[] }[]
> {
await fakeDelay(20); await fakeDelay(20);
return [ return [
{ {
@ -58,7 +55,6 @@ export async function getMenuItems(): Promise<{name: string, items: Item[]}[]> {
]; ];
} }
export async function getItemsByUUID(items: string[]): Promise<Item[]> { export async function getItemsByUUID(items: string[]): Promise<Item[]> {
await fakeDelay(200); await fakeDelay(200);
@ -79,7 +75,6 @@ export async function getItemsByUUID(items: string[]): Promise<Item[]> {
return data; return data;
} }
export async function getItemByUUID(uuid: string): Promise<Item> { export async function getItemByUUID(uuid: string): Promise<Item> {
let data: Item[]; let data: Item[];
@ -98,8 +93,11 @@ export async function getItemByUUID(uuid: string): Promise<Item> {
return data[0]; return data[0];
} }
export async function postContactEmail(
export async function postContactEmail(name: string, email: string, message: string): Promise<string> { name: string,
email: string,
message: string
): Promise<string> {
await fakeDelay(200); await fakeDelay(200);
if (!name) { if (!name) {
@ -117,7 +115,9 @@ export async function postContactEmail(name: string, email: string, message: str
return "Check your email to confirm the message!"; return "Check your email to confirm the message!";
} }
export async function postVerifyCart(currentCartData: Record<string, CartItem>): Promise<Record<string, CartItem>> { export async function postVerifyCart(
currentCartData: Record<string, CartItem>
): Promise<Record<string, CartItem>> {
let verifiedItems: Item[] = []; let verifiedItems: Item[] = [];
await getItemsByUUID(Object.keys(currentCartData)) await getItemsByUUID(Object.keys(currentCartData))

View file

@ -1,4 +1,4 @@
import type { Item } from './types'; import type { Item } from "./types";
import { Labels } from "./types"; import { Labels } from "./types";
const TestData: Item[] = [ const TestData: Item[] = [

View file

@ -7,18 +7,18 @@ export enum Labels {
} }
export interface Item { export interface Item {
uuid: string, uuid: string;
name: string, name: string;
price: number, price: number;
detail?: string, detail?: string;
labels: Labels[], labels: Labels[];
image?: string, image?: string;
} }
// UUID is stored in both Item and CartItem, this isn't the best, I don't like it // UUID is stored in both Item and CartItem, this isn't the best, I don't like it
// But it's the simplest way of doing this shit // But it's the simplest way of doing this shit
export interface CartItem { export interface CartItem {
uuid: string, uuid: string;
amount: number, amount: number;
data: Item, data: Item;
} }

View file

@ -1,6 +1,6 @@
export function expandOnTyping(element) { export function expandOnTyping(element) {
element.oninput = (event) => { element.oninput = (event) => {
event.target.style.height = ""; event.target.style.height = "";
event.target.style.height = (event.target.scrollHeight + 2) + "px"; event.target.style.height = event.target.scrollHeight + 2 + "px";
} };
} }

View file

@ -1,8 +1,8 @@
import './styles/main.scss' import "./styles/main.scss";
import App from './App.svelte' import App from "./App.svelte";
const app = new App({ const app = new App({
target: document.getElementById('app'), target: document.getElementById("app"),
}) });
export default app export default app;

View file

@ -9,53 +9,53 @@ const routes = {
asyncComponent: () => import("./pages/PageIndex.svelte"), asyncComponent: () => import("./pages/PageIndex.svelte"),
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"/menu": wrap({ "/menu": wrap({
asyncComponent: () => import("./pages/PageMenu.svelte"), asyncComponent: () => import("./pages/PageMenu.svelte"),
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: true, }, userData: { showNavBar: true, fullWidth: true },
}), }),
"/item/:uuid": wrap({ "/item/:uuid": wrap({
asyncComponent: () => import("./pages/PageItem.svelte"), asyncComponent: () => import("./pages/PageItem.svelte"),
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: true, }, userData: { showNavBar: true, fullWidth: true },
}), }),
"/contact": wrap({ "/contact": wrap({
asyncComponent: () => import("./pages/PageContact.svelte"), asyncComponent: () => import("./pages/PageContact.svelte"),
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"/about": wrap({ "/about": wrap({
component: PageLoading, component: PageLoading,
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"/cart": wrap({ "/cart": wrap({
asyncComponent: () => import("./pages/PageCart.svelte"), asyncComponent: () => import("./pages/PageCart.svelte"),
loadingComponent: PageLoading, loadingComponent: PageLoading,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"/ForOhFor": wrap({ "/ForOhFor": wrap({
component: Page404, component: Page404,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"/ServerError": wrap({ "/ServerError": wrap({
component: Page500, component: Page500,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
"*": wrap({ "*": wrap({
component: Page404, component: Page404,
conditions: [], conditions: [],
userData: { showNavBar: true, fullWidth: false, }, userData: { showNavBar: true, fullWidth: false },
}), }),
} };
export default routes; export default routes;

View file

@ -7,7 +7,7 @@
overflow: hidden; overflow: hidden;
img{ img {
width: 100%; width: 100%;
height: 400px; height: 400px;

View file

@ -1,6 +1,6 @@
.container { .container {
border-radius: $border-radius-normal; border-radius: $border-radius-normal;
background-image: url('/BackgroundTextureAlt.svg'); background-image: url("/BackgroundTextureAlt.svg");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 200px 250px; background-size: 200px 250px;
background-position: 5px -43px; background-position: 5px -43px;

View file

@ -6,16 +6,16 @@
height: 4px; height: 4px;
border-radius: 999px; border-radius: 999px;
overflow: hidden; overflow: hidden;
animation: start .3s ease-in; animation: start 0.3s ease-in;
&.bottom { &.bottom {
top: unset; top: unset;
bottom: 2px bottom: 2px;
} }
.bar { .bar {
position: absolute; position: absolute;
transition: transform .2s linear; transition: transform 0.2s linear;
left: 0; left: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
@ -24,12 +24,16 @@
&.bar-1 { &.bar-1 {
background-color: $color-dark; background-color: $color-dark;
animation: growBar1 2.5s infinite, moveBar1 2.5s infinite; animation:
growBar1 2.5s infinite,
moveBar1 2.5s infinite;
} }
&.bar-2 { &.bar-2 {
background-color: $color-primary; background-color: $color-primary;
animation: growBar2 2.5s infinite, moveBar2 2.5s infinite; animation:
growBar2 2.5s infinite,
moveBar2 2.5s infinite;
} }
} }
} }
@ -62,7 +66,12 @@
} }
69.15% { 69.15% {
left: 21.5%; left: 21.5%;
animation-timing-function: cubic-bezier(0.30244, 0.38135, 0.55, 0.95635); animation-timing-function: cubic-bezier(
0.30244,
0.38135,
0.55,
0.95635
);
} }
100% { 100% {
left: 95.44444%; left: 95.44444%;
@ -70,15 +79,30 @@
} }
@keyframes growBar2 { @keyframes growBar2 {
0% { 0% {
animation-timing-function: cubic-bezier(0.20503, 0.05705, 0.57661, 0.45397); animation-timing-function: cubic-bezier(
0.20503,
0.05705,
0.57661,
0.45397
);
transform: scaleX(0.1); transform: scaleX(0.1);
} }
19.15% { 19.15% {
animation-timing-function: cubic-bezier(0.15231, 0.19643, 0.64837, 1.00432); animation-timing-function: cubic-bezier(
0.15231,
0.19643,
0.64837,
1.00432
);
transform: scaleX(0.57); transform: scaleX(0.57);
} }
44.15% { 44.15% {
animation-timing-function: cubic-bezier(0.25776, -0.00316, 0.21176, 1.38179); animation-timing-function: cubic-bezier(
0.25776,
-0.00316,
0.21176,
1.38179
);
transform: scaleX(0.91); transform: scaleX(0.91);
} }
100% { 100% {

View file

@ -1,4 +1,6 @@
*, *::before, *::after { *,
*::before,
*::after {
margin: 0; margin: 0;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
box-sizing: border-box; box-sizing: border-box;
@ -10,7 +12,8 @@ html {
font-family: $font-family; font-family: $font-family;
} }
body, #app { body,
#app {
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -23,8 +26,12 @@ body {
color: $color-on-background; color: $color-on-background;
} }
h1,
h1, h2, h3, h4, h5, h6 { h2,
h3,
h4,
h5,
h6 {
padding-bottom: $spacing-small; padding-bottom: $spacing-small;
text-shadow: 0 1px 0.5px rgba($color-dark, 0.3); text-shadow: 0 1px 0.5px rgba($color-dark, 0.3);
} }

View file

@ -5,7 +5,7 @@ $color-dark: #443023;
$color-on-dark: #e1dcd3; $color-on-dark: #e1dcd3;
$color-light: #fff8eb; $color-light: #fff8eb;
$color-on-light: #33251a; $color-on-light: #33251a;
$color-primary: #6A9343; $color-primary: #6a9343;
$color-on-primary: #fffbf4; $color-on-primary: #fffbf4;
$color-error: #ab5642; $color-error: #ab5642;
$color-on-error: #fffbf4; $color-on-error: #fffbf4;
@ -33,7 +33,7 @@ $spacing-normal: 16px;
$spacing-large: 32px; $spacing-large: 32px;
// FONT // FONT
$font-family: 'Erode', serif; $font-family: "Erode", serif;
$font-size-very-fucking-big: 50px; $font-size-very-fucking-big: 50px;
$font-size-h1: 32.44px; $font-size-h1: 32.44px;

View file

@ -1,11 +1,8 @@
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import { phosphorSvelteOptimize } from "phosphor-svelte/preprocessor" import { phosphorSvelteOptimize } from "phosphor-svelte/preprocessor";
export default { export default {
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess // Consult https://svelte.dev/docs#compile-time-svelte-preprocess
// for more information about preprocessors // for more information about preprocessors
preprocess: [ preprocess: [phosphorSvelteOptimize(), vitePreprocess()],
phosphorSvelteOptimize(), };
vitePreprocess()
],
}

View file

@ -1,12 +1,10 @@
import { defineConfig } from 'vite' import { defineConfig } from "vite";
import { svelte } from '@sveltejs/vite-plugin-svelte' import { svelte } from "@sveltejs/vite-plugin-svelte";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
base: './', base: "./",
plugins: [ plugins: [svelte()],
svelte(),
],
optimizeDeps: { optimizeDeps: {
exclude: ["phosphor-svelte"], exclude: ["phosphor-svelte"],
}, },
@ -15,4 +13,4 @@ export default defineConfig({
// '%': __dirname + '/src', // '%': __dirname + '/src',
// } // }
// }, // },
}) });