From 33d7e654c5c02ad3a55201c498865811d5bb9e36 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Mon, 18 Nov 2024 00:16:01 +0100 Subject: [PATCH] chore: fixing minor astro warnings --- src/client/Appunti.jsx | 2 +- src/client/UtentiPage.tsx | 18 ++++++++-------- src/client/lib/util.ts | 4 ++-- src/scripts/circuits-art.ts | 41 ++++++++++++++++++------------------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/client/Appunti.jsx b/src/client/Appunti.jsx index 415f73f..dfac3c0 100644 --- a/src/client/Appunti.jsx +++ b/src/client/Appunti.jsx @@ -13,7 +13,7 @@ * @param {AppuntiCardProps} param0 * @returns */ -export const AppuntiCard = ({ image, course, title, author, courseYear }) => { +export const AppuntiCard = ({ course, title, author, courseYear }) => { return (
diff --git a/src/client/UtentiPage.tsx b/src/client/UtentiPage.tsx index 7fe7345..8a71db9 100644 --- a/src/client/UtentiPage.tsx +++ b/src/client/UtentiPage.tsx @@ -1,4 +1,4 @@ -import { effect, useComputed, useSignal } from '@preact/signals' +import { useComputed, useSignal } from '@preact/signals' import Fuse from 'fuse.js' import { useEffect } from 'preact/hooks' import { ShowMore } from './Paginate' @@ -67,22 +67,22 @@ export const UtentiPage = () => { $filter.value === 'macchinisti' ? $utentiData.value.filter(user => MACCHINISTI.includes(user.uid)) : $filter.value === 'rappstud' - ? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid)) - : $utentiData.value, + ? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid)) + : $utentiData.value ) const $fuse = useComputed( () => new Fuse($filteredData.value, { keys: ['gecos', 'uid'], - }), + }) ) const $searchText = useSignal('') const $searchResults = useComputed(() => $searchText.value.trim().length > 0 - ? ($fuse.value?.search($searchText.value).map(result => result.item) ?? []) - : $filteredData.value, + ? $fuse.value?.search($searchText.value).map(result => result.item) ?? [] + : $filteredData.value ) useEffect(() => { @@ -107,7 +107,7 @@ export const UtentiPage = () => { <> {v.icon} {v.label} , - ]), + ]) )}
{poissonUser.gecos}
diff --git a/src/client/lib/util.ts b/src/client/lib/util.ts index 2acc7df..fc52ce1 100644 --- a/src/client/lib/util.ts +++ b/src/client/lib/util.ts @@ -1,9 +1,9 @@ -import { useEffect, useMemo, useState } from 'preact/hooks' +import { useEffect, useState } from 'preact/hooks' export const trottleDebounce = ( fn: (...args: T) => R, delay: number, - options: { leading?: boolean; trailing?: boolean } = {}, + options: { leading?: boolean; trailing?: boolean } = {} ): ((...args: T) => R | undefined) => { let lastCall = 0 let lastResult: R | undefined diff --git a/src/scripts/circuits-art.ts b/src/scripts/circuits-art.ts index 588f3ba..d9987c9 100644 --- a/src/scripts/circuits-art.ts +++ b/src/scripts/circuits-art.ts @@ -60,8 +60,8 @@ const RENDERER_FPS = 30 function setup() { console.log('Setting up circuits art...') - $canvas.width = $canvas.clientWidth - $canvas.height = $canvas.clientHeight + $canvas.width = $canvas.clientWidth * window.devicePixelRatio + $canvas.height = $canvas.clientHeight * window.devicePixelRatio const g = $canvas.getContext('2d')! const state: State = { @@ -75,14 +75,19 @@ function setup() { const handle = window.setInterval(() => { const time = new Date().getTime() - startTime.getTime() - update(state, g.canvas.width, g.canvas.height, time) + update( + state, + g.canvas.width / window.devicePixelRatio, + g.canvas.height / window.devicePixelRatio, + time + ) render(g, state, time) }, 1000 / RENDERER_FPS) renderer = { timer: handle } } -function update(state: State, width: number, height: number, time: number) { +function update(state: State, width: number, _height: number, _time: number) { const w = (width / CELL_SIZE) | 0 // const h = (height / CELL_SIZE) | 0 @@ -166,14 +171,20 @@ const RENDER_CELL: Record void> = { }, } -function render(g: CanvasRenderingContext2D, state: State, time: number) { +function render(g: CanvasRenderingContext2D, state: State, _time: number) { + const WIDTH = g.canvas.width / window.devicePixelRatio + const HEIGHT = g.canvas.height / window.devicePixelRatio + g.clearRect(0, 0, g.canvas.width, g.canvas.height) + g.resetTransform() + g.scale(window.devicePixelRatio, window.devicePixelRatio) g.scale(CELL_SIZE, CELL_SIZE) + g.lineWidth = 3 / CELL_SIZE - const w = (g.canvas.width / CELL_SIZE) | 0 - const h = (g.canvas.height / CELL_SIZE) | 0 + const w = (WIDTH / CELL_SIZE) | 0 + const h = (HEIGHT / CELL_SIZE) | 0 for (let y = 0; y <= h + 1; y++) { for (let x = 0; x <= w + 1; x++) { if (!state.grid.has([x, y])) continue @@ -235,18 +246,6 @@ function randomChoice(choices: T[]): T { return choices[randomInt(0, choices.length - 1)] } -function randomWeightedChoice(choices: [T, number][]) { - return -} - -// 3 + 4 + 5 + 6 -randomWeightedChoice([ - ['a', 3], - ['b', 4], - ['c', 5], - ['d', 6], -]) - const DIR_TO_VEC: Record = { ['down']: [0, 1], ['down-left']: [-1, 1], @@ -277,14 +276,14 @@ const DIR_AVAILABLE_PREDICATE: Record, position: Point2, - directions: WireDirection[], + directions: WireDirection[] ): WireDirection[] { return directions.filter(dir => DIR_AVAILABLE_PREDICATE[dir](position, grid)) } function generateWire( grid: Grid, - startingPoint: Point2, + startingPoint: Point2 ): { position: Point2; direction: WireCell }[] { const segmentLength = Math.floor(1 - Math.random() ** 2) * 10 + 30 let currentPosition = startingPoint