chore: fixing minor astro warnings
continuous-integration/drone/push Build is passing Details

main
parent b6ad4ebf4d
commit 33d7e654c5

@ -13,7 +13,7 @@
* @param {AppuntiCardProps} param0 * @param {AppuntiCardProps} param0
* @returns * @returns
*/ */
export const AppuntiCard = ({ image, course, title, author, courseYear }) => { export const AppuntiCard = ({ course, title, author, courseYear }) => {
return ( return (
<div class="appunti-item"> <div class="appunti-item">
<div class="thumbnail"></div> <div class="thumbnail"></div>

@ -1,4 +1,4 @@
import { effect, useComputed, useSignal } from '@preact/signals' import { useComputed, useSignal } from '@preact/signals'
import Fuse from 'fuse.js' import Fuse from 'fuse.js'
import { useEffect } from 'preact/hooks' import { useEffect } from 'preact/hooks'
import { ShowMore } from './Paginate' import { ShowMore } from './Paginate'
@ -67,22 +67,22 @@ export const UtentiPage = () => {
$filter.value === 'macchinisti' $filter.value === 'macchinisti'
? $utentiData.value.filter(user => MACCHINISTI.includes(user.uid)) ? $utentiData.value.filter(user => MACCHINISTI.includes(user.uid))
: $filter.value === 'rappstud' : $filter.value === 'rappstud'
? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid)) ? $utentiData.value.filter(user => RAPPSTUD.includes(user.uid))
: $utentiData.value, : $utentiData.value
) )
const $fuse = useComputed( const $fuse = useComputed(
() => () =>
new Fuse($filteredData.value, { new Fuse($filteredData.value, {
keys: ['gecos', 'uid'], keys: ['gecos', 'uid'],
}), })
) )
const $searchText = useSignal('') const $searchText = useSignal('')
const $searchResults = useComputed(() => const $searchResults = useComputed(() =>
$searchText.value.trim().length > 0 $searchText.value.trim().length > 0
? ($fuse.value?.search($searchText.value).map(result => result.item) ?? []) ? $fuse.value?.search($searchText.value).map(result => result.item) ?? []
: $filteredData.value, : $filteredData.value
) )
useEffect(() => { useEffect(() => {
@ -107,7 +107,7 @@ export const UtentiPage = () => {
<> <>
<span class="material-symbols-outlined">{v.icon}</span> {v.label} <span class="material-symbols-outlined">{v.icon}</span> {v.label}
</>, </>,
]), ])
)} )}
</ComboBox> </ComboBox>
<div class="search"> <div class="search">
@ -130,8 +130,8 @@ export const UtentiPage = () => {
{RAPPSTUD.includes(poissonUser.uid) {RAPPSTUD.includes(poissonUser.uid)
? 'account_balance' ? 'account_balance'
: MACCHINISTI.includes(poissonUser.uid) : MACCHINISTI.includes(poissonUser.uid)
? 'construction' ? 'construction'
: 'person'} : 'person'}
</span> </span>
</div> </div>
<div class="text">{poissonUser.gecos}</div> <div class="text">{poissonUser.gecos}</div>

@ -1,9 +1,9 @@
import { useEffect, useMemo, useState } from 'preact/hooks' import { useEffect, useState } from 'preact/hooks'
export const trottleDebounce = <T extends any[], R>( export const trottleDebounce = <T extends any[], R>(
fn: (...args: T) => R, fn: (...args: T) => R,
delay: number, delay: number,
options: { leading?: boolean; trailing?: boolean } = {}, options: { leading?: boolean; trailing?: boolean } = {}
): ((...args: T) => R | undefined) => { ): ((...args: T) => R | undefined) => {
let lastCall = 0 let lastCall = 0
let lastResult: R | undefined let lastResult: R | undefined

@ -60,8 +60,8 @@ const RENDERER_FPS = 30
function setup() { function setup() {
console.log('Setting up circuits art...') console.log('Setting up circuits art...')
$canvas.width = $canvas.clientWidth $canvas.width = $canvas.clientWidth * window.devicePixelRatio
$canvas.height = $canvas.clientHeight $canvas.height = $canvas.clientHeight * window.devicePixelRatio
const g = $canvas.getContext('2d')! const g = $canvas.getContext('2d')!
const state: State = { const state: State = {
@ -75,14 +75,19 @@ function setup() {
const handle = window.setInterval(() => { const handle = window.setInterval(() => {
const time = new Date().getTime() - startTime.getTime() 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) render(g, state, time)
}, 1000 / RENDERER_FPS) }, 1000 / RENDERER_FPS)
renderer = { timer: handle } 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 w = (width / CELL_SIZE) | 0
// const h = (height / CELL_SIZE) | 0 // const h = (height / CELL_SIZE) | 0
@ -166,14 +171,20 @@ const RENDER_CELL: Record<WireCell, (g: CanvasRenderingContext2D) => 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.clearRect(0, 0, g.canvas.width, g.canvas.height)
g.resetTransform() g.resetTransform()
g.scale(window.devicePixelRatio, window.devicePixelRatio)
g.scale(CELL_SIZE, CELL_SIZE) g.scale(CELL_SIZE, CELL_SIZE)
g.lineWidth = 3 / CELL_SIZE g.lineWidth = 3 / CELL_SIZE
const w = (g.canvas.width / CELL_SIZE) | 0 const w = (WIDTH / CELL_SIZE) | 0
const h = (g.canvas.height / CELL_SIZE) | 0 const h = (HEIGHT / CELL_SIZE) | 0
for (let y = 0; y <= h + 1; y++) { for (let y = 0; y <= h + 1; y++) {
for (let x = 0; x <= w + 1; x++) { for (let x = 0; x <= w + 1; x++) {
if (!state.grid.has([x, y])) continue if (!state.grid.has([x, y])) continue
@ -235,18 +246,6 @@ function randomChoice<T>(choices: T[]): T {
return choices[randomInt(0, choices.length - 1)] return choices[randomInt(0, choices.length - 1)]
} }
function randomWeightedChoice<T>(choices: [T, number][]) {
return
}
// 3 + 4 + 5 + 6
randomWeightedChoice([
['a', 3],
['b', 4],
['c', 5],
['d', 6],
])
const DIR_TO_VEC: Record<WireDirection, Point2> = { const DIR_TO_VEC: Record<WireDirection, Point2> = {
['down']: [0, 1], ['down']: [0, 1],
['down-left']: [-1, 1], ['down-left']: [-1, 1],
@ -277,14 +276,14 @@ const DIR_AVAILABLE_PREDICATE: Record<WireDirection, (pos: Point2, grid: Grid<Wi
function pruneDirections( function pruneDirections(
grid: Grid<WireCell>, grid: Grid<WireCell>,
position: Point2, position: Point2,
directions: WireDirection[], directions: WireDirection[]
): WireDirection[] { ): WireDirection[] {
return directions.filter(dir => DIR_AVAILABLE_PREDICATE[dir](position, grid)) return directions.filter(dir => DIR_AVAILABLE_PREDICATE[dir](position, grid))
} }
function generateWire( function generateWire(
grid: Grid<WireCell>, grid: Grid<WireCell>,
startingPoint: Point2, startingPoint: Point2
): { position: Point2; direction: WireCell }[] { ): { position: Point2; direction: WireCell }[] {
const segmentLength = Math.floor(1 - Math.random() ** 2) * 10 + 30 const segmentLength = Math.floor(1 - Math.random() ** 2) * 10 + 30
let currentPosition = startingPoint let currentPosition = startingPoint

Loading…
Cancel
Save