From 8ba9c7090c88c04d43ca727b7ed012cf5a6b58c8 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 16 May 2022 15:36:06 +0000 Subject: start adding really basic tooltip --- src/lib/AuctionPreviewTooltip.svelte | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/lib/AuctionPreviewTooltip.svelte (limited to 'src/lib/AuctionPreviewTooltip.svelte') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte new file mode 100644 index 0000000..226feee --- /dev/null +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -0,0 +1,22 @@ + + +{#if preview} +
+

uuid: {JSON.stringify(preview)}

+
+{/if} + + -- cgit From b6d23f4334eae873e7d32a4d5bb5f8b3a1a67ce5 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 16:20:20 +0000 Subject: improved auction price scatterplot --- src/lib/AuctionPreviewTooltip.svelte | 40 +++++++++++++++++--- src/lib/AuctionPriceScatterplot.svelte | 68 +++++++++++++++++++++------------- src/lib/utils.ts | 4 +- svelte.config.js | 18 ++++----- 4 files changed, 89 insertions(+), 41 deletions(-) (limited to 'src/lib/AuctionPreviewTooltip.svelte') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 226feee..223cec2 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -1,22 +1,52 @@ -{#if preview} -
-

uuid: {JSON.stringify(preview)}

+ + +{#if lastPreview} + {@const date = new Date(lastPreview.auction.ts * 1000)} +
+

{lastPreview.auction.coins.toLocaleString()} coins

+
{/if} diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index e416163..48a3fa5 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -1,34 +1,47 @@ @@ -38,20 +51,23 @@ - + {#each item.auctions as auction} - {@const timestampPercentage = - (auction.ts - earliestTimestamp) / (currentTimestamp - earliestTimestamp)} + {@const [x, y] = getAuctionCoordinates(auction)} showAuctionPreview(e, auction.id)} - on:click={e => showAuctionPreview(e, auction.id)} - on:mouseleave={hideAuctionPreview} + tabindex="-1" /> {/each} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c2e4b86..c094db4 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,3 +1,5 @@ +import type { SimpleAuctionSchema } from "./APITypes" + export const colorCodes: { [key: string]: string } = { '0': '#000000', // black '1': '#0000be', // blue @@ -224,5 +226,5 @@ export function skyblockTime(year: number, month = 1, day = 1) { export interface PreviewedAuctionData { pageX: number pageY: number - uuid: string + auction: SimpleAuctionSchema } diff --git a/svelte.config.js b/svelte.config.js index 23b0e12..222cd8f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -42,15 +42,15 @@ const config = { }, }, // if the user is on replit or gitpod, use a secure websocket - // server: - // process.env.REPL_ID || process.env.GITPOD_WORKSPACE_ID - // ? { - // hmr: { - // protocol: 'wss', - // port: 443, - // }, - // } - // : {}, + server: + process.env.REPL_ID || process.env.GITPOD_WORKSPACE_ID + ? { + hmr: { + protocol: 'wss', + port: 3001, + }, + } + : {}, }, } } -- cgit From f9bb90cab81e7c7f8c2a7e932bbf2ddbf7b51f1f Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 18:50:49 +0000 Subject: auction search and fixes --- src/lib/AuctionPreviewTooltip.svelte | 4 ++-- src/lib/AuctionPriceScatterplot.svelte | 15 ++++++++++++--- src/routes/auctionprices.svelte | 26 +++++++++++++++++--------- svelte.config.js | 11 +++++++---- 4 files changed, 38 insertions(+), 18 deletions(-) (limited to 'src/lib/AuctionPreviewTooltip.svelte') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 223cec2..417f8b3 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -5,7 +5,7 @@ import type { PreviewedAuctionData } from './utils' export let preview: PreviewedAuctionData | null - export let lastPreview: PreviewedAuctionData | null + let lastPreview: PreviewedAuctionData | null $: lastPreview = preview ?? lastPreview @@ -36,7 +36,7 @@ #auction-preview-tooltip { position: absolute; border: 1px solid rgba(255, 255, 255, 0.1); - background: var(--theme-lighter-background); + background: rgba(0, 0, 0, 0.1); padding: 0.5em; transition: left 200ms, top 200ms; pointer-events: none; diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 48a3fa5..1e774d0 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -25,7 +25,11 @@ let nearestDistance = Number.MAX_SAFE_INTEGER let nearestAuction: SimpleAuctionSchema | null = null for (const auction of item.auctions) { - const auctionCoords = getAuctionCoordinates(auction) + const auctionCoordsSvg = getAuctionCoordinates(auction) + const auctionCoords = [ + (auctionCoordsSvg[0] * rect.width) / 100, + (auctionCoordsSvg[1] * rect.height) / 100, + ] const distance = Math.pow(mouseCoords[0] - auctionCoords[0], 2) + Math.pow(mouseCoords[1] - auctionCoords[1], 2) @@ -35,7 +39,8 @@ } } if (nearestAuction) { - const [x, y] = getAuctionCoordinates(nearestAuction) + const [svgX, svgY] = getAuctionCoordinates(nearestAuction) + const [x, y] = [(svgX * rect.width) / 100, (svgY * rect.height) / 100] currentlyPreviewedAuction = { pageX: window.scrollX + rect.left + x, pageY: window.scrollY + rect.top + y, @@ -67,7 +72,7 @@ r="1" stroke-width="4" fill={auction.bin ? '#11b' : '#1b1'} - tabindex="-1" + class:selected-auction={currentlyPreviewedAuction?.auction?.id === auction?.id} /> {/each} @@ -78,4 +83,8 @@ height: 10em; width: 100%; } + + .selected-auction { + stroke: #06e7; + } diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index 4e7bfde..d07c533 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -3,11 +3,14 @@ import { API_URL } from '$lib/api' export const load: Load = async ({ params, fetch }) => { + const auctionItemsPromise = fetch(`${API_URL}auctionitems`).then(r => r.json()) const data = await fetch(`${API_URL}auctionprices`).then(r => r.json()) + const auctionItems = await auctionItemsPromise return { props: { data, + auctionItems, }, } } @@ -16,24 +19,29 @@ - + {#if lastPreview} - {@const date = new Date(lastPreview.auction.ts * 1000)}

{lastPreview.auction.coins.toLocaleString()} coins

- +
{/if} diff --git a/src/lib/AuctionPriceScatterplot.svelte b/src/lib/AuctionPriceScatterplot.svelte index 0532f97..cfdbe9b 100644 --- a/src/lib/AuctionPriceScatterplot.svelte +++ b/src/lib/AuctionPriceScatterplot.svelte @@ -57,7 +57,7 @@ diff --git a/src/lib/api.ts b/src/lib/api.ts index 689a952..1721d01 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,2 +1,3 @@ // the trailing slash is required export const API_URL = 'https://skyblock-api.matdoes.dev/' +// export const API_URL = 'http://localhost:8080/' diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index eccaab7..3c301d0 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -72,11 +72,11 @@
- {#each data as item (item._id)} + {#each data as item (item.id)} {@const binAuctions = item.auctions.filter(i => i.bin)} {@const normalAuctions = item.auctions.filter(i => !i.bin)}
-

{auctionItems[item._id]}

+

{auctionItems[item.id]}

{#if binAuctions.length > 0}

-- cgit From 1c711a9dfaff99ec27f3d7db11127dbc51f6efc6 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 23:27:38 -0500 Subject: rename auctions page & tooltip fade in --- src/lib/AuctionPreviewTooltip.svelte | 1 + src/routes/auctionprices.svelte | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/AuctionPreviewTooltip.svelte') diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index a3a73fb..39a2370 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -24,6 +24,7 @@ class:hidden={preview === null} style="left: {lastPreview.pageX}px; top: {lastPreview.pageY}px" out:fade={{ duration: 100 }} + in:fade={{ duration: 100 }} >

{lastPreview.auction.coins.toLocaleString()} coins

diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index e778330..33b6b86 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -62,7 +62,7 @@ } - +
-- cgit From 97688e22c8335642b72d200ce0a865353bef5207 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 18 May 2022 21:29:41 -0500 Subject: Fix lag --- package.json | 6 +- src/lib/AuctionPreviewTooltip.svelte | 27 ++++---- src/lib/AuctionPriceScatterplot.svelte | 109 ++++++++++++++++++--------------- src/routes/auctionprices.svelte | 9 ++- yarn.lock | 12 ++-- 5 files changed, 92 insertions(+), 71 deletions(-) (limited to 'src/lib/AuctionPreviewTooltip.svelte') diff --git a/package.json b/package.json index b2ba8a9..a2b2139 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,7 @@ "eslint-plugin-svelte3": "^4.0.0", "prettier": "^2.5.1", "prettier-plugin-svelte": "^2.5.0", - "svelte": "^3.46.4", "svelte-check": "^2.4.6", - "svelte-preprocess": "^4.10.4", "tslib": "^2.3.1", "typescript": "~4.6.4", "vite": "^2.8.6", @@ -38,10 +36,12 @@ "@sveltejs/adapter-node": "^1.0.0-next.68", "@sveltejs/adapter-static": "^1.0.0-next.28", "@sveltejs/adapter-vercel": "^1.0.0-next.43", - "@sveltejs/kit": "^1.0.0-next.330", + "@sveltejs/kit": "^1.0.0-next.335", "cookie": "^0.5.0", "dotenv": "^16.0.0", "skyblock-assets": "^2.0.8", + "svelte": "^3.48.0", + "svelte-preprocess": "^4.10.6", "typed-hypixel-api": "^1.1.0" }, "packageManager": "yarn@3.1.1" diff --git a/src/lib/AuctionPreviewTooltip.svelte b/src/lib/AuctionPreviewTooltip.svelte index 39a2370..26b01d9 100644 --- a/src/lib/AuctionPreviewTooltip.svelte +++ b/src/lib/AuctionPreviewTooltip.svelte @@ -5,9 +5,11 @@ export let preview: PreviewedAuctionData | null let lastPreview: PreviewedAuctionData | null - $: lastPreview = preview ?? lastPreview + $: { + lastPreview = preview ?? lastPreview + } - function onClick(e: MouseEvent) { + function onMouseMove(e: MouseEvent) { // commented out because it doesn't work: sometimes e.target is null when we click a point if (e.target && !(e.target as HTMLElement).closest('.item-auction-history')) { preview = null @@ -16,29 +18,32 @@ } - + {#if lastPreview}
-

{lastPreview.auction.coins.toLocaleString()} coins

- +
+

{lastPreview.auction.coins.toLocaleString()} coins

+ +
{/if} diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index 3c57e1e..9e7615c 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -30,7 +30,7 @@ export let data: ItemAuctionsSchema[] export let auctionItems: Record - let currentlyPreviewedAuction: PreviewedAuctionData | null + let currentlyPreviewedAuction: PreviewedAuctionData | null = null let query: string = '' @@ -89,6 +89,13 @@ loadingPage = false } } + + $: { + if (browser && !currentlyPreviewedAuction) { + for (const el of document.getElementsByClassName('selected-auction')) + el.classList.remove('selected-auction') + } + } diff --git a/yarn.lock b/yarn.lock index 758e549..dad6890 100644 --- a/yarn.lock +++ b/yarn.lock @@ -150,10 +150,10 @@ dependencies: esbuild "^0.14.21" -"@sveltejs/kit@^1.0.0-next.330": - version "1.0.0-next.330" - resolved "https://registry.yarnpkg.com/@sveltejs/kit/-/kit-1.0.0-next.330.tgz#1865ca9e38eb34633b0e469e833f4f51ebb5eb69" - integrity sha512-Wb95D5tOF8BViZuikqzZLAcupdS7TpXtadNPgpEOxKowmkrW8xjRrrfVdPIkNOLqAP1V+gKInmQ/gFYmnv5EjA== +"@sveltejs/kit@^1.0.0-next.335": + version "1.0.0-next.335" + resolved "https://registry.yarnpkg.com/@sveltejs/kit/-/kit-1.0.0-next.335.tgz#14bd4016633605b9edc8b7a77cd393ca778449db" + integrity sha512-iZutvIJSSNJJGceZOX2ZWqcyRqp9MIPnNWOgOLXqBG/Z/+KLoN8MRI0U79XIw232SAEXhhkwaJtB3UnXQSu85A== dependencies: "@sveltejs/vite-plugin-svelte" "^1.0.0-next.32" chokidar "^3.5.3" @@ -1608,7 +1608,7 @@ svelte-hmr@^0.14.11: resolved "https://registry.yarnpkg.com/svelte-hmr/-/svelte-hmr-0.14.11.tgz#63d532dc9c2c849ab708592f034765fa2502e568" integrity sha512-R9CVfX6DXxW1Kn45Jtmx+yUe+sPhrbYSUp7TkzbW0jI5fVPn6lsNG9NEs5dFg5qRhFNAoVdRw5qQDLALNKhwbQ== -svelte-preprocess@^4.0.0, svelte-preprocess@^4.10.4: +svelte-preprocess@^4.0.0, svelte-preprocess@^4.10.6: version "4.10.6" resolved "https://registry.yarnpkg.com/svelte-preprocess/-/svelte-preprocess-4.10.6.tgz#5f9a53e7ed3b85fc7e0841120c725b76ac5a1ba8" integrity sha512-I2SV1w/AveMvgIQlUF/ZOO3PYVnhxfcpNyGt8pxpUVhPfyfL/CZBkkw/KPfuFix5FJ9TnnNYMhACK3DtSaYVVQ== @@ -1620,7 +1620,7 @@ svelte-preprocess@^4.0.0, svelte-preprocess@^4.10.4: sorcery "^0.10.0" strip-indent "^3.0.0" -svelte@^3.46.4: +svelte@^3.48.0: version "3.48.0" resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.48.0.tgz#f98c866d45e155bad8e1e88f15f9c03cd28753d3" integrity sha512-fN2YRm/bGumvjUpu6yI3BpvZnpIm9I6A7HR4oUNYd7ggYyIwSA/BX7DJ+UXXffLp6XNcUijyLvttbPVCYa/3xQ== -- cgit